Don't rely just on presence of the cookie to detect active user session #50634
Labels
blocker
Feature:NP Migration
Feature:Security/Authentication
Platform Security - Authentication
Team:Security
Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Currently we have a code in the login view route that decides whether it should render login view or not (and redirect to the Kibana root) solely based on the presence of the session cookie.
That worked well in the legacy world where we had only
basic
authentication provider, but now it has the following issues:saml\oidc
andbasic
providers are used presence of the session cookie may have 3 different meanings:basic
saml\oidc
And if user wishes to open login view in cases 2 or 3 it'd make sense to allow them to do that (and effectively fix #25257)
KibanaRequest
won't give us direct access to the cookie anymore (justifiesblocker
status for 8.0)It seems currently we have all the necessary pieces to finally fix that issue:
Authenticator
is able to extract session fromKibanaRequest
using internalsessionStorageFactory
even if the route that handles this request explicitly opted out from mandatory authentication. So essentially we can have a new method onAuthenticator
that would answer whether or not request is associated with the active session (not intermediate) and which provider owns this session using the code similar to one we have in theauthenticate
method.There are two questions we should answer first though:
do we want to treat requests with valid
Authorization
header (or any other header we may support in the future) the same as requests with valid cookie-based session (like we do for normal authentication)? If the answer isyes
, then we'll have to iterate through all providers trying to figure out which provider can authenticate the request and return user information.My current preference is to answer
no
to precisely replicate current behavior and keep code simpler. We should stop supporting this scenario in the authentication providers eventually anyway and use a dedicatedproxy-headers
authentication provider instead (once Reporting starts using API keys instead of request headers "snapshots" or we can add this special authentication provider automatically as the first one).are we okay with any side-effects that may happen when we call provider's
authenticate
just to know if the session is active (e.g. access token will be automatically refreshed if expired, maybe there are more side-effects)?cc @restrry
Supersedes: #41959
The text was updated successfully, but these errors were encountered: