Skip to content

KEYCLOAK-1267 Add dedicated SSO timeouts for Remember-Me#3161

Closed
thomasdarimont wants to merge 2 commits intokeycloak:masterfrom
thomasdarimont:issue/KEYCLOAK-1267-improve-rememberme
Closed

KEYCLOAK-1267 Add dedicated SSO timeouts for Remember-Me#3161
thomasdarimont wants to merge 2 commits intokeycloak:masterfrom
thomasdarimont:issue/KEYCLOAK-1267-improve-rememberme

Conversation

@thomasdarimont
Copy link
Copy Markdown
Contributor

@thomasdarimont thomasdarimont commented Aug 22, 2016

Previously remember-me sessions where tied to the SSO max session
timeout which could lead to unexpected early session timeouts.
We now allow SSO timeouts to be configured separately for sessions
with enabled remember-me.
This enables users to opt-in for longer session timeouts.

SSO Session Timeouts for RememberMe can now be configured in the
tokens tab in the realm admin console. Max SSO timeouts for Remember-me
need to be equal or greater than normal max SSO timeouts.

Note that most of the work for this PR was done by @cfsnyder and
is based on his earlier PR #2338.
I just adapted his code to the latest Keycloak API changes.

Signed-off-by: Thomas Darimont [email protected]

@cfsnyder
Copy link
Copy Markdown
Contributor

Awesome @thomasdarimont, thanks for following up and updating that one!

@thomasdarimont thomasdarimont force-pushed the issue/KEYCLOAK-1267-improve-rememberme branch from 08be42b to b9a4ecc Compare September 15, 2016 09:41
@stianst stianst self-assigned this Sep 20, 2016
Copy link
Copy Markdown
Contributor

@stianst stianst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that it took so long to get back to you on this one. Looks OK, but I've added a couple comments inline. We need 'ssoSessionIdleTimeoutRememberMe' as well. This gives more flexibility in how to configure things. For example remember me allows cookie to last 365 days, but still needs a user to use the session at least every 30 days, while a non-remember me session is 30 days and idle 1 day.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't introduce extra changeSet for a specific version, we only want one changeset per-version. Just append to existing changeSet element if there is one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I moved the changes to the current changelog.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be simpler to allow null and use ssoSessionMaxLifespan if not specified. Having SQL in these files worries me for compatibility reasons (in general, I think this particular SQL is fine though).

Previosuly remember-me sessions where tied to the SSO max session
timeout which could lead to unexpected early session timeouts.
We now allow SSO timeouts to be configured separately for sessions
with enabled remember-me.
This enables users to opt-in for longer session timeouts.

SSO Session Timeouts for RememberMe can now be configured in the
tokens tab in the realm admin console. Max SSO timeouts for Remember-me
need to be equal or greater than normal max SSO timeouts.

Note that most of the work for this PR was done by @cfsnyder and
is based on his earlier PR keycloak#2338.
I just adapted his code to the latest Keycloak API changes.

Signed-off-by: Thomas Darimont <[email protected]>
@thomasdarimont thomasdarimont force-pushed the issue/KEYCLOAK-1267-improve-rememberme branch from b9a4ecc to 8717142 Compare October 3, 2016 13:46
@thomasdarimont
Copy link
Copy Markdown
Contributor Author

FYI I updated the PR with an additional idle timeout for sso remember me.
Would you mind having a look @stianst and @cfsnyder ?

We now allow to control the idle timeout for a SSO
session created with "remember me".

Modified the jpa-changelog according to discussions in keycloak#3161.
@thomasdarimont thomasdarimont force-pushed the issue/KEYCLOAK-1267-improve-rememberme branch from 8717142 to d18b899 Compare October 3, 2016 13:51
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the default be 1 hour or 10 hours (as in the examples above e.g.: basicauthrealm.json)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what a better default would be here...

</addColumn>

<addColumn tableName="REALM">
<column name="SSO_MAX_LIFESPAN_REMEMBER_ME" type="INT" defaultValueNumeric="36000"/>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set this to 10 hours by default - can anyone think of a better default?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like having a default for this. Rather values for remember me should be optional and it should use non-remember me values if not specified.

boolean sessionMaxOk = (userSession.getStarted() + (userSession.isRememberMe() ? realm.getSsoSessionMaxLifespanRememberMe() : realm.getSsoSessionMaxLifespan())) > currentTime;
int maxRememberMeIdleSessionAge = userSession.getLastSessionRefresh() + realm.getSsoSessionIdleTimeoutRememberMe();
int maxSsoSessionAge = userSession.getLastSessionRefresh() + realm.getSsoSessionIdleTimeout();
boolean sessionIdleOk = (userSession.isRememberMe() && maxRememberMeIdleSessionAge > currentTime) || maxSsoSessionAge > currentTime;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I now take into account the ssoSessionIdleTimeoutRememberMe

Copy link
Copy Markdown
Contributor

@stianst stianst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments inline. In general I think it would be better to use non-remember me values by default and optionally allow setting different values for remember-me.

"accessCodeLifespanUserAction": 300,
"ssoSessionIdleTimeout": 600,
"ssoSessionMaxLifespan": 36000,
"ssoSessionIdleTimeoutRememberMe": 36000,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add to existing realm files. That should not be required.

"accessCodeLifespanUserAction": 300,
"ssoSessionIdleTimeout": 600,
"ssoSessionMaxLifespan": 36000,
"ssoSessionIdleTimeoutRememberMe": 36000,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add to existing realm files. That should not be required.

"accessCodeLifespanUserAction": 300,
"ssoSessionIdleTimeout": 600,
"ssoSessionMaxLifespan": 36000,
"ssoSessionIdleTimeoutRememberMe": 36000,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add to existing realm files. That should not be required.

"accessCodeLifespanUserAction": 300,
"ssoSessionIdleTimeout": 600,
"ssoSessionMaxLifespan": 36000,
"ssoSessionIdleTimeoutRememberMe": 36000,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add to existing realm files. That should not be required.


<addColumn tableName="ADMIN_EVENT_ENTITY">
<column name="RESOURCE_TYPE" type="VARCHAR(64)"></column>
<column name="RESOURCE_TYPE" type="VARCHAR(64)"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change code that is not relevant to your changes

.ssoSessionIdleTimeout(3000)
.accessTokenLifespan(10000)
.ssoSessionMaxLifespan(10000)
.ssoSessionMaxLifespanRememberMe(10000)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be required to set this in existing tests. This test has nothing to do with your changes.

"registrationAllowed": true,
"resetPasswordAllowed": true,
"editUsernameAllowed" : true,
"rememberMe" : false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing this?


public void loginToMasterRealmAdminConsoleAs(UserRepresentation user) {
loginToAdminConsoleAs(adminConsolePage, loginPage, user);
loginToAdminConsoleAs(adminConsolePage, loginPage, user, false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the point in adding this. This is not the correct place to test remember me.

"accessTokenLifespanForImplicitFlow" : 900,
"ssoSessionIdleTimeout" : 2,
"ssoSessionMaxLifespan" : 36000,
"ssoSessionIdleTimeoutRememberMe" : 36000,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add to irrelevant tests

testStrategy.testLoginSSOMax();
}

@Test
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapter tests are not the correct place to test this. Rather use LoginTest or something else from the base tests inside the new Arquillian testsuite. Please remove all changes to the adapter tests inside testsuite/integration

@stianst stianst added 3.x and removed Incomplete labels Nov 28, 2016
@stianst stianst closed this Mar 14, 2017
sguilhen pushed a commit to sguilhen/keycloak that referenced this pull request Nov 14, 2018
Previously remember-me sessions where tied to the SSO max session
timeout which could lead to unexpected early session timeouts.
We now allow SSO timeouts to be configured separately for sessions
with enabled remember-me. This enables users to opt-in for longer
session timeouts.

SSO session timeouts for remember-me can now be configured in the
tokens tab in the realm admin console. This new configuration is
optional and will tipically host values larger than the regular
max SSO timeouts. If no value is specified for remember-me timeouts
then the regular max SSO timeouts will be used.

Work based on PR keycloak#3161 by
Thomas Darimont <[email protected]>
mposolda pushed a commit that referenced this pull request Nov 15, 2018
Previously remember-me sessions where tied to the SSO max session
timeout which could lead to unexpected early session timeouts.
We now allow SSO timeouts to be configured separately for sessions
with enabled remember-me. This enables users to opt-in for longer
session timeouts.

SSO session timeouts for remember-me can now be configured in the
tokens tab in the realm admin console. This new configuration is
optional and will tipically host values larger than the regular
max SSO timeouts. If no value is specified for remember-me timeouts
then the regular max SSO timeouts will be used.

Work based on PR #3161 by
Thomas Darimont <[email protected]>
thomasdarimont added a commit to thomasdarimont/keycloak that referenced this pull request May 16, 2019
Previously remember-me sessions where tied to the SSO max session
timeout which could lead to unexpected early session timeouts.
We now allow SSO timeouts to be configured separately for sessions
with enabled remember-me. This enables users to opt-in for longer
session timeouts.

SSO session timeouts for remember-me can now be configured in the
tokens tab in the realm admin console. This new configuration is
optional and will tipically host values larger than the regular
max SSO timeouts. If no value is specified for remember-me timeouts
then the regular max SSO timeouts will be used.

Work based on PR keycloak#3161 by
Thomas Darimont <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants