代码之家  ›  专栏  ›  技术社区  ›  Seth

是否需要通过https和spring security进行身份验证?

  •  2
  • Seth  · 技术社区  · 14 年前

    section 9.2.1 of the documentation spells that out ). 因此,我需要通过https进行身份验证。

    由于潜在的处理开销,我希望将尽可能多的通信量保留在常规http中。有没有办法让spring对未经身份验证的请求使用https,然后在身份验证完成后使用http?我想这是用某种ChannelProcessingFilter完成的,但我对细节感到困惑。

    这是我的申请表-安全.xml当前的文件:

    <beans:beans xmlns="http://www.springframework.org/schema/security"
        xmlns:beans="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
    
        <http use-expressions="true">
            <intercept-url pattern="/**" access="isAuthenticated()" />
            <http-basic />
        </http>
    
        <authentication-manager>
            <authentication-provider user-service-ref="myUserDetailsService">
                <password-encoder hash="sha"/>
            </authentication-provider>
        </authentication-manager>
    
        <beans:bean id="myUserDetailsService"
            class="path.to.myUserDetailsServiceImpl">
        </beans:bean>
    
    </beans:beans>
    

    谢谢你的帮助。

    2 回复  |  直到 14 年前
        1
  •  6
  •   rook    14 年前

    如果在任何时候您通过HTTP传递会话id,那么您就违反了 OWASP A9 . 如果攻击者拥有会话id,则不需要密码。我不会在你的应用程序中实现此功能,https非常轻,我认为你应该考虑在不意味着你的客户端将被黑客攻击的地方节省资源。

        2
  •  3
  •   Eric Warriner    14 年前

    我不知道如何使用springmvc来实现它,但是我确实使用Grails和springsecurity3实现了这一点……如果您感兴趣,可以查看我的博客文章 here

    因为这对你没什么帮助…我在谷歌上搜索了一下,发现 this 张贴正确的,并说要配置您的网站.xml:

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext-security.xml
        </param-value>
    </context-param>
    
         <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    

      <beans:beans xmlns="http://www.springframework.org/schema/security"
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">
    
        <http>
            <intercept-url pattern="/url1.htm"
            access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https" />
            <intercept-url pattern="/url2.htm"
            access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https" />
            <intercept-url pattern="/**"
            access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="http" />
    
            <anonymous />
            <http-basic/>
        </http>
    
        <!-- This bean is optional; it isn't used by any other bean as it only listens and logs -->
        <beans:bean id="loggerListener" class="org.springframework.security.event.authentication.LoggerListener"/>
    
    </beans:beans>
    

    也看看这个 site