未验证 提交 2ce2ddf1 编写于 作者: N Nicky 提交者: GitHub

Merge pull request #51 from u014427391/1.1.0

1.1.0
......@@ -7,11 +7,11 @@ security.oauth2.resource.user-info-uri=http://localhost:8888/user
security.oauth2.client.use-current-uri=false
security.oauth2.client.pre-established-redirect-uri=http://localhost:8084/cms/login
security.oauth2.resource.token-info-uri= http://localhost:8888/oauth/check_token
security.oauth2.resource.jwt.key-uri=http://localhost:8888/oauth/token_key
#security.oauth2.resource.jwt.key-uri=http://localhost:8888/oauth/token_key
security.oauth2.authorization.check-token-access= http://localhost:8888/oauth/check_token
server.port=8084
server.servlet.context-path=/cms
# 预防cookie冲突,设置cookie name
server.servlet.session.cookie.name=OAUTH2-CMS-SESSIONID
server.servlet.session.cookie.name=OAUTH2-CLIENT-SESSIONID
......@@ -100,17 +100,17 @@ public class OAuth2Configuration extends AuthorizationServerConfigurerAdapter {
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(jwtTokenStore()).authenticationManager(authenticationManager)
.accessTokenConverter(accessTokenConverter())
//endpoints.tokenStore(jwtTokenStore()).authenticationManager(authenticationManager)
//.accessTokenConverter(accessTokenConverter())
//必须注入userDetailsService否则根据refresh_token无法加载用户信息
//.userDetailsService(userDetailsService)
//支持获取token方式
.allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST,HttpMethod.PUT,HttpMethod.DELETE,HttpMethod.OPTIONS)
//开启刷新token
.reuseRefreshTokens(true)
.tokenServices(tokenServices());
//.allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST,HttpMethod.PUT,HttpMethod.DELETE,HttpMethod.OPTIONS)
//刷新token
//.reuseRefreshTokens(false)
//.tokenServices(tokenServices());
// 使用内存保存生成的token
//endpoints.authenticationManager(authenticationManager).tokenStore(memoryTokenStore());
endpoints.authenticationManager(authenticationManager).tokenStore(memoryTokenStore());
}
/**
......@@ -155,26 +155,25 @@ public class OAuth2Configuration extends AuthorizationServerConfigurerAdapter {
return converter;
}
@Bean
public TokenStore jwtTokenStore() {
//基于jwt实现令牌(Access Token)保存
return new JwtTokenStore(accessTokenConverter());
}
// @Bean
// public TokenStore memoryTokenStore() {
// // 最基本的InMemoryTokenStore生成token
// return new InMemoryTokenStore();
// public TokenStore jwtTokenStore() {
// //基于jwt实现令牌(Access Token)保存
// return new JwtTokenStore(accessTokenConverter());
// }
@Bean
public TokenStore memoryTokenStore() {
// 最基本的InMemoryTokenStore生成token
return new InMemoryTokenStore();
}
@Bean
public DefaultTokenServices tokenServices() {
final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenEnhancer(accessTokenConverter());
defaultTokenServices.setTokenStore(jwtTokenStore());
defaultTokenServices.setSupportRefreshToken(true);
//(int) TimeUnit.DAYS.toSeconds(30) 30天
defaultTokenServices.setAccessTokenValiditySeconds(1);
defaultTokenServices.setTokenStore(memoryTokenStore());
defaultTokenServices.setSupportRefreshToken(false);
defaultTokenServices.setAccessTokenValiditySeconds((int) TimeUnit.DAYS.toSeconds(30));
return defaultTokenServices;
}
......
......@@ -87,7 +87,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.anyRequest().authenticated()
// 关闭跨域保护;
.and().csrf().disable();
http.addFilterBefore(simpleCORSFilter, SecurityContextPersistenceFilter.class);
//http.addFilterBefore(simpleCORSFilter, SecurityContextPersistenceFilter.class);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册