【问题标题】:Spring Security this kind of http://localhost:8080/WEB/edit-employee/{ID} url not authenticatingSpring Security 这种 http://localhost:8080/WEB/edit-employee/{ID} url 没有进行身份验证
【发布时间】:2015-12-10 13:14:23
【问题描述】:

我已经通过使用 intecept-url 为我的项目配置了一个 spring 安全上下文,我能够验证所有 URL,但是当我通过 URL 传递一些 ID 时,验证不会发生。

<intercept-url pattern="/**" access="isAuthenticated()"/>

工作网址

http://localhost:8080/WEB/add-employee
http://localhost:8080/WEB/view-employee

网址无效

http://localhost:8080/WEB/edit-employee/1
http://localhost:8080/WEB/edit-employee/2

1 和 2 是通过 URL 传递的 ID,上述 URL 模式不起作用(这意味着当我通过 URL 传递 ID 时)

我在拦截 URL 中尝试了许多组合,但我没有得到正确的结果。

<http use-expressions="true">
        <intercept-url pattern="/**" access="isAuthenticated()"/> <!-- this means all URL in this app will be checked if user is authenticated -->

        <!-- We will just use the built-in form login page in Spring -->
        <form-login login-page="/" login-processing-url="/j_spring_security_check"  default-target-url="/home" authentication-failure-url="/"/>
        <logout logout-url="/logout" logout-success-url="/"/> <!-- the logout url we will use in JSP -->
    </http>

【问题讨论】:

    标签: spring spring-security spring-security-oauth2


    【解决方案1】:

    删除 &lt;intercept-url pattern="/edit-employee/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/&gt; 行以禁止匿名访问该 URL。

    【讨论】:

    • 我已删除该行,但问题仍然存在。
    • @DON:你能提供一些背景信息吗?具体来说,什么样的内容映射到 URL localhost:8080/WEB/edit-employee/2 ?这似乎是 REST URL。
    • 我有一个名为员工列表的页面,其中列出了所有注册员工,其中列出了每个员工的查看详细信息按钮。当我单击员工的查看详细信息按钮时,该用户的相应 ID 将通过使用 localhost:8080/WEB/edit-employee/{ID} 传递给“edit-emplyee”。我可以在该页面中编辑员工详细信息,但无法在 localhost:8080/WEB/edit-employee/{ID} 这个 url 下获得相应的员工角色。
    猜你喜欢
    • 2012-03-06
    • 2013-02-23
    • 2014-02-01
    • 2016-09-13
    • 2011-02-11
    • 2012-11-27
    • 2019-02-07
    • 2011-10-17
    相关资源
    最近更新 更多