java—资源服务器如何检查我使用SpringSecurity在另一台服务器中创建的jwt令牌?

bqucvtff  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(227)

有一个模块,其中启用了Spring Security 。在该模块中,有一种配置允许我执行单一登录并将登录的用户保存在内存中。在customsuccesshandler中,我更改令牌的值并保存它(覆盖sso返回的令牌),然后将新令牌发送到一个页面。

@Configuration
@EnableWebSecurity(debug = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private CustomAuthenticationSuccessHandler customAuthenticationSuccessHandler;

    @Override
    public void configure(HttpSecurity httpSecurity) throws Exception {

        httpSecurity.csrf().and().cors().disable().authorizeRequests()
        .anyRequest().authenticated()
        .and()
        .oauth2Login()
        .redirectionEndpoint()
        .baseUri("/baseUri")
        .and()
        .authorizationEndpoint()
        .baseUri("/oauth2/authorize")  
        .authorizationRequestRepository(customAuthorizationRequestRepository())
        .and()
        .successHandler(customAuthenticationSuccessHandler);

    }

    @Bean
    public AuthorizationRequestRepository<OAuth2AuthorizationRequest> customAuthorizationRequestRepository() {
        return new HttpSessionOAuth2AuthorizationRequestRepository();
    }

}

现在有另一个模块,其中包含一些我想要保护的API。我想发送上一个令牌(从angular)并验证它发送到存储用户信息(访问令牌、主体等)的模块。
实际上,如果我不更改令牌(因此我使用sso返回的令牌),我可以通过设置属性自动对其进行验证:

spring.security.oauth2.resourceserver.jwt.jwk-set-uri= https://example.provider.com/oauth2/key/jwks

我可以在我的服务器上复制类似的东西吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题