小编Ale*_*lex的帖子

带有Spring Boot REST应用程序的OAuth2 - 无法使用令牌访问资源

我想将OAuth2用于我的REST spring启动项目.使用一些示例我已经为OAuth2创建了配置:

@Configuration
public class OAuth2Configuration {

    private static final String RESOURCE_ID = "restservice";

    @Configuration
    @EnableResourceServer
    protected static class ResourceServerConfiguration extends
          ResourceServerConfigurerAdapter {

        @Override
        public void configure(ResourceServerSecurityConfigurer resources) {
            // @formatter:off
            resources
                    .resourceId(RESOURCE_ID);
            // @formatter:on
        }

        @Override
        public void configure(HttpSecurity http) throws Exception {
            // @formatter:off
            http
                    .anonymous().disable()
                    .authorizeRequests().anyRequest().authenticated();
            // @formatter:on
        }

    }

    @Configuration
    @EnableAuthorizationServer
    protected static class AuthorizationServerConfiguration extends
             AuthorizationServerConfigurerAdapter {

        private TokenStore tokenStore = new InMemoryTokenStore();

        @Autowired
        @Qualifier("authenticationManagerBean")
        private AuthenticationManager authenticationManager;

        @Autowired
        private UserDetailsServiceImpl userDetailsService;

        @Override
        public void …
Run Code Online (Sandbox Code Playgroud)

java rest spring oauth-2.0 spring-boot

6
推荐指数
1
解决办法
7339
查看次数

标签 统计

java ×1

oauth-2.0 ×1

rest ×1

spring ×1

spring-boot ×1