【发布时间】:2015-10-04 18:46:17
【问题描述】:
我正在尝试向我的项目添加一个 oauth2 安全方案, oauth2 身份验证服务器已经由另一个项目实现,所以我只需要拦截相关请求并使用身份验证服务器进行登录, 另外,我想通过使用用户组在应用程序中具有角色来使用身份验证服务器作为授权提供程序, 我当前的 Spring Security xml 如下所示:
<security:http pattern="/resources/**" security="none" />
<security:http pattern="/loginError.html" security="none" />
<security:http use-expressions="true">
<security:intercept-url pattern="/login.html"
access="permitAll"/>
<security:form-login login-page="/login.html"
authentication-failure-url="/loginError.html"/>
<security:logout logout-success-url="/login.html"/>
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="user" password="p" authorities="VIEW"/>
<security:user name="admin" password="p" authorities="ALL, VIEW"/>
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
<security:global-method-security pre-post-annotations="enabled"/>
<oauth:resource-server id="oauthResourceServer" entry-point-ref="entry"/>
<bean id="entry" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<constructor-arg value="https://www.example.com" />
</bean>
此外,我们正在使用带有此过滤器的web.xml:
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
当前的身份验证管理器将移至开发配置文件,当然不会与 oauth 服务器一起使用。 我知道最好转到 spring 4 并像示例一样在代码中进行配置,但目前对我来说是不可能的,所以应该保持当前的配置机制
【问题讨论】:
标签: java xml spring oauth spring-security