07-oauth2-ResourceServer-02

2020-06-24  本文已影响0人  16325

下面搭建一个与authServer分离的resourceServer

ResourceServerSecurityConfigurer

@Override
    public void configure(ResourceServerSecurityConfigurer resources)  throws Exception {
        RemoteTokenServices remoteTokenServices = new RemoteTokenServices();
        DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();
        UserAuthenticationConverter userTokenConverter = new CommonUserConverter();
        accessTokenConverter.setUserTokenConverter(userTokenConverter);
        remoteTokenServices.setCheckTokenEndpointUrl(resourceServerProperties.getTokenInfoUri());
        remoteTokenServices.setClientId(oAuth2ClientProperties.getClientId());
        remoteTokenServices.setClientSecret(oAuth2ClientProperties.getClientSecret());
        remoteTokenServices.setRestTemplate(restTemplate());
        remoteTokenServices.setAccessTokenConverter(accessTokenConverter);       resources.tokenServices(remoteTokenServices);
    }
上一篇 下一篇

猜你喜欢

热点阅读