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了,但我發現這個東西是一種自我設計的,看起來相當複雜。