【问题标题】:what is the use of auto-config=true in spring securityspring security 中 auto-config=true 有什么用
【发布时间】:2013-09-04 09:07:34
【问题描述】:

在 Spring Security 中 auto-config=true 有什么用。 在哪种情况下我们应该使用它。 使用 auto-config=true 的实际用途是什么?

【问题讨论】:

标签: java spring spring-security


【解决方案1】:

auto-config="true" 等价于:

<http>
    <form-login />
    <http-basic />
    <logout />
</http>

因此它为您提供了一个非常基本的启动安全配置。

来源:https://docs.spring.io/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#ns-auto-config

【讨论】:

    【解决方案2】:

    auto-config='true' 表示 对于拦截 url 模式,spring security 提供了默认的登录屏幕

    【讨论】:

      【解决方案3】:

      这是我们使用auto-config = true的情况之一:

      <http auto-config='true'>
        <intercept-url pattern="/**" access="ROLE_USER" />
      </http>
      

      此声明意味着我们希望应用程序中的所有 URL 都受到保护,需要角色 ROLE_USER 才能访问它们。该元素是所有与 Web 相关的命名空间功能的父元素。该元素定义了一个模式,该模式使用 ant 路径样式语法与传入请求的 URL 匹配

      【讨论】:

        【解决方案4】:

        Spring 安全参考:

        “不建议使用此属性。请使用显式配置元素以避免混淆。”

        来源:https://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/html5/#nsa-http-attributes

        【讨论】:

          猜你喜欢
          • 2011-12-01
          • 2020-04-12
          • 1970-01-01
          • 1970-01-01
          • 2012-03-11
          • 2010-11-16
          • 2019-01-30
          • 2015-12-01
          • 1970-01-01
          相关资源
          最近更新 更多