-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Remove confusion about conflicting token expiration and cookie + session config settings #1711
Comments
Thanks for the detailed problem statement and recommendations, looks solid; here are some thoughts:
I think it would be very useful to correctly handle these cases and log actionable messages for OpenSearch cluster operators - should there be another recommendation or is it wrapped in one of the other bullets?
I think deprecating this setting in 2.x and removing in the 3.0 versions are a good path forward to remove this extraneous and non-functional option. If limiting the session length is an option we want to expose, it should be handled by the backend system to clearly separate responsibilities between FE/BE.
I'm not as familiar with the different operator scenarios where different configurations are desirable. Maybe it would be good to connect with the user base via a community meeting or outreach of some kind. I'd love to work backward from what cluster operators need vs what is already implemented. |
[Triage] Hi @jochen-kressin, thank you for filing this issue. This seems like a good change and something that should be improved. |
Hi @derek-ho reaching out to you after integrating the latest release 2.13 into our build hoping to fix the session issue. IDP Used: PingID Below is the config used in the opensearch
opensearch -> security config.yaml
Please let me know how to ensure the user session doesn't end after the token expiry has reached and he can continue until the |
Versions : Describe the issue:
and in security config.yml file for saml_auth_domain, sp section I set: what should I do to extend session expiration to aviod relogin? besides that anyone can help me how to decipher security_authentication_saml1, security_authentication token (btw I do not want to use log for seeing inside token, I already did it), as far as I know OS cahnges SAML response with light weight jwt and encrypt it with the exchange_key, but I could not decipher it with follwing python script:
|
Background
The OpenSearch Dashboard configuration contains multiple settings that affect how long user credentials are saved and valid in the browser cookie:
In addition, we may have credentials with an expiration time set on runtime, or rather provided by an external authentication, such as an Identity Provider (IdP).
Examples of this are when using JWT, OpenID, or SAML. The credentials in these cases contain a token, which may contain an "exp" property that denotes the lifespan of the given token.
The multiple settings for the credentials lifespan have lead to confusion and sometimes misconfigurations, as seen reported in multiple issues and forum discussions.
Related issues
Examples of issues related this are:
The settings in detail
cookie.ttl
This setting doesn't seem to have any effect. The expected result of using this setting would be to control the browser cookie's lifespan, but the setting is never passed on to the underlying cookie mechanism (hapi cookie).
Instead, the browser cookie will always be "Session", and the cookie will exists until the browser session is closed.
session.ttl
This setting adds a lifespan (time to live) in the form of a property - expiryTime - that is stored in the authentication cookie. On each request, this ttl is validated against the current time.
session.keepalive
If this setting is true, the lifespan (expiryTime) of the credentials are extended whenever Dashboards detects an authenticated request.
If the user is idle and no request is sent, the lifespan will not be extended.
The .exp property in a token
This denotes the lifespan of the token in seconds.
More info: https://openid.net/specs/openid-connect-core-1_0.html#IDToken
The underlying problem
First of all - the fact that the cookie.ttl setting does not have any effect may be unexpected for users looking to really limit the browser cookie's lifetime. While this isn't the main problem in the issues referenced, it might be worth fixing.
The main source of confusion comes when using OpenID, SAML and likely also JWT.
User expectancy: the IdP's token lifespan is not (always) used
The token lifespan can be set within the IdP, but that lifespan may be overridden by session.ttl
A user is logged out too early
If session.ttl is shorter that the token's actual lifespan, the user will be unauthenticated even though the token is still valid.
Differences between the authentication types
SAML does use a token's exp property when the user authenticates, and the cookie's expiryTime will be set with the token's exp value. However, if session.keepalive is true, this value will be overriden with session.ttl upon the first request
OpenID does not use expiryTime for storing the token's exp value.
JWT does not use exp at all.
JWT throws a 500 error if the token has expired
If session.ttl is greater than the token's actual lifespan, Dashboards will pass an expired token to the backend. The backend validates and throws an authentication error. This error is not handled in Dashboards at the moment, and the user will see a 500 error message.
The security backend's role in regards to the lifespan (exp)
Based on my tests, the backend also validates the token lifespan and correctly returns a 401 if the token has expired.
In most cases, Dashboards also validates the token lifespan, and an expired token will not reach the backend. An exception to this is JWT, as mentioned earlier in this issue.
Somewhat confusingly, the backend then seems to log this message:
in addition to
Should we decide to remove the frontend (Dashboards) validation and just rely on the backend validation, we need to make sure a 401 is always handled gracefully by Dashboards. This is a bit different to unauthenticated requests because Dashboards has what it "thinks" are valid credentials.
Based on my tests, the only thing needed is to make sure to catch a 401 here: https://github.com/opensearch-project/security-dashboards-plugin/blob/2.11.1.0/server/auth/types/authentication_type.ts#L207
(If multitenancy is enabled, this is already handled)
A note about differences between IdPs
One thing worth to mention, but probably out of scope for this issue, is that there may be differences between how IdPs pass on the token lifespan.
Related user comment: #159 (comment)
NB: In the case of SAML, OpenSearch security converts the SAMLResponse to a token.
Recommendations
Request for comments
Please feel very welcome to share your thoughts about this. Are there missing considerations? Do you have suggestions for further improvements? Do you have questions?
The text was updated successfully, but these errors were encountered: