r/SpringBoot • • Mar 26 '26
Question What controls how long you stay logged in when using OAuth2 OIDC flow?
I'm on Spring Boot 3.5.x and acting as both the resource server and the client. I have something like this for my SecurityFilterChain ....
@Configuration
@EnableWebSecurity
public class OAuth2LoginSecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.oauth2Login(withDefaults());
return http.build();
}
}
What controls how long users have before they have to login again? I thought it was server.servlet.session.timeout. But apparently that's just the idle timeout? What about server.servlet.session.cookie.max-age?
8
Upvotes
5
u/bikeram Mar 26 '26
You’ll be logged in until your token expires. It’ll be a setting in auth0/keycloak or whatever provider you’re using.
1
u/perfectstrong Mar 29 '26
I find it a little confusing in your setup. In your other comments, you said the provider does not allow more than 30m for an access_token, without refresh_token. This seems strange to me since by default, an end-user should have both to avoid re-login every 30m. Which begs the question : what flow of OIDC between your server and the third-party API you're trying to use ? If it is client_credentials, the provider is right : you are obliged to relogin every time, since this flow is meant for B2B channels. And the end-user's token must not be used for this flow.