【问题标题】:spring security oauth2 check_token using Xmlspring security oauth2 check_token 使用 XML
【发布时间】:2016-02-23 08:13:42
【问题描述】:

我正在尝试使用 outh/check_token 启用,但遇到了一些困难 根据这个答案How to enable /oauth/check_token with Spring Security Oauth2 using XML

您需要创建一个 CheckTokenEndpoint 类型的 bean。 我们如何做到这一点,我将它包含在我的 spring security.xml 中

<bean id="checkTokenEndpoint" class="org.springframework.security.oauth2.provider.endpoint.CheckTokenEndpoint">
        <constructor-arg name="resourceServerTokenServices" ref="tokenServices"/>
    </bean>

这个类 org.springframework.security.oauth2.provider.endpoint.CheckTokenEndpoint 正在抛出错误

Multiple annotations found at this line:
    - Class 'org.springframework.security.oauth2.provider.endpoint.CheckTokenEndpoint' not found
    - Class 'org.springframework.security.oauth2.provider.endpoint.CheckTokenEndpoint' not found [config set: AuthenticationApp/web-
     context]

这就是全部

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:sec="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd 
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd ">

有人可以帮助所有示例都使用 spring boot 和 java config,但我必须使用 xml config

【问题讨论】:

    标签: java spring spring-mvc spring-security spring-security-oauth2


    【解决方案1】:

    使用最新版本的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:

    <beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd>
                           http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
    

    在元素 authentication-server 中插入选项 check-token-enabled="true":

    <oauth:authorization-server check-token-enabled="true" client-details-service-ref="jdbcClientDetailsService"/>
    

    【讨论】:

      猜你喜欢
      • 2015-01-01
      • 2015-04-22
      • 2020-09-05
      • 2018-05-01
      • 2019-09-25
      • 2019-04-29
      • 2019-01-03
      • 2017-09-11
      • 2014-09-15
      相关资源
      最近更新 更多