0
我有一个使用Feign客户端的spring启动项目,并通过OAuth和JSON Web令牌处理授权。授权后,您必须通过GET参数发送访问令牌。但不是将它作为GET参数发送,我想在标题内发送它。我找不到一个办法。任何人都知道吗?Spring Boot:在标题中发送JWT(OAuth)
我的配置:
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
@Autowired
@Qualifier("authenticationManagerBean")
private AuthenticationManager authenticationManager;
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient(oAuth2ClientName)
.authorizedGrantTypes("password", "authorization_code", "refresh_token", "implicit")
.authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")
.scopes("read", "write", "trust")
.secret(oAuth2ClientSecret)
.accessTokenValiditySeconds(oAuth2AccessTokenValidSecs).
refreshTokenValiditySeconds(oAuth2RefreshTokenValidSecs);
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore())
.accessTokenConverter(accessTokenConverter())
.authenticationManager(authenticationManager);
}
@Bean
public TokenStore tokenStore() {
return new JwtTokenStore(accessTokenConverter());
}
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
converter.setSigningKey(jwtSigningKey);
return converter;
}
@Bean
@Primary
public DefaultTokenServices tokenServices() {
DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(tokenStore());
defaultTokenServices.setSupportRefreshToken(true);
return defaultTokenServices;
}
}
我已经GOOGLE了,但我发现这个东西是一种自我设计的,看起来相当复杂。