微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用XML对Spring Security Oauth2启用/ oauth / check_token

我已经使用 spring-security 3.2.*和 javaconfig成功启用了’/ oauth / check_token’端点,但是目前我只限于spring-security 3.1.4,然后我坚持使用 XML配置. ‘/ oauth / token’端点正在按照我的意愿工作,但是我无法启用check_token端点,我找不到任何(非javaconfig)文档来解释要做什么.

Vanila授权服务器配置:

<oauth:authorization-server 
        client-details-service-ref="client-service" 
        token-services-ref="tokenServices" >
    <oauth:refresh-token disabled="false" />
    <oauth:client-credentials disabled="false" />
    <oauth:password authentication-manager-ref="userAuthenticationManager"  />       
</oauth:authorization-server>

http安全配置:

<sec:http 
        auto-config="true"
        pattern="/oauth/token" 
        create-session="stateless"
        authentication-manager-ref="clientAuthenticationManager">
    <sec:intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
    <sec:anonymous enabled="false"/>
    <sec:http-basic entry-point-ref="clientAuthenticationEntryPoint" />
</sec:http>

我试图添加以下http配置但没有成功.

<sec:http 
        auto-config="true"
        pattern="/oauth/check_token" 
        create-session="stateless"
        authentication-manager-ref="clientAuthenticationManager">
    <sec:intercept-url pattern="/oauth/check_token" access="IS_AUTHENTICATED_FULLY" />
    <sec:anonymous enabled="false"/>
    <sec:http-basic entry-point-ref="clientAuthenticationEntryPoint" />
</sec:http>

拜托,任何建议.一个工作的例子会很棒.

最好
./Kristofer

解决方法

使用spring oauth2的最新版本:

<dependency>
  <groupId>org.springframework.security.oauth</groupId>
  <artifactId>spring-security-oauth2</artifactId>
  <version>2.0.10.RELEASE</version>
</dependency>

确保spring security oauth文件配置中正在使用的正确版本的xsd:

http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd

在元素authorization-server中插入选项check-token-enabled =“true”:

<oauth:authorization-server ... check-token-enabled="true">
... 
</oauth:authorization-server>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。