Open douxiaofeng99 opened 6 years ago
+1
+1
It seems that you get the old refresh token. You can ask oauth to give new refresh_token by AuthorizationServerEndpointsConfigurer.reuseRefreshTokens(false).
@douxiaofeng99 did you manage to make this work?
@ Reza Nouri
No, I have no idea yet.
发件人: Reza Nouri notifications@github.com 答复: spring-projects/spring-security-oauth reply@reply.github.com 日期: 2019年4月17日 星期三 上午11:52 收件人: spring-projects/spring-security-oauth spring-security-oauth@noreply.github.com 抄送: "dou xiaofeng (窦晓峰)" douxf@asiainfo.com, Mention mention@noreply.github.com 主题: Re: [spring-projects/spring-security-oauth] Can JWTToken use RedisTokenStore? (#1267)
@douxiaofeng99 did you manage to make this work?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
I also was trying to do this and I think that the only way to make it work is just to implement TokenStore interface by yourself.
My scenery is using two oauth2 servers as sso endpoint.
package com.cmi.oauth2.sso;
import java.security.Principal;
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.filter.OrderedCharacterEncodingFilter; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.data.redis.connection.RedisClusterConfiguration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisSentinelConfiguration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.http.HttpMethod; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; import org.springframework.security.oauth2.provider.token.TokenStore; import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore; import org.springframework.security.web.csrf.CsrfFilter; import org.springframework.stereotype.Controller; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter;
import com.cmi.oauth2.sso.config.ConfidentialClientProperties; import com.cmi.oauth2.sso.config.CustomLogoutSuccessHandler; import com.cmi.oauth2.sso.config.PublicClientProperties; import com.cmi.oauth2.sso.config.TrustedClientProperties; import com.cmi.oauth2.sso.redis.ClusterProperties; import com.cmi.oauth2.sso.redis.SentinelProperties; import com.cmi.oauth2.sso.redis.SingleProperties; import com.cmi.oauth2.sso.user.CustomUserDetailsService;
import redis.clients.jedis.JedisPoolConfig;
@ComponentScan(basePackages = "com.cmi.oauth2.sso") @SpringBootApplication @Controller public class OauthSSOApplication extends SpringBootServletInitializer {
}
I want to use redis to store access_token and refresh_token, also i want to use JWT token to reduce the resource server accessing the sso servers. when i use these two together, the login and the first time to get access_token are ok. The problem is occurred when the access_token is expired, i can use the first time gotten refresh_token to refresh access_token. then i log out, the refresh and access token are renewed, then if i use the new refresh_token to get new access_token, the oauth will throw invalid refresh token. In the redis, the refresh:xxx-xxx do not update ,it is the first refresh_token.