Skip to content
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

Do not check cookie authentication for /auth/saml/{configuration}/request/ #4982

Open
rolodato opened this issue Jan 8, 2025 · 0 comments
Open
Labels
api Issue related to the REST API front-end Issue related to the React Front End Dashboard

Comments

@rolodato
Copy link
Member

rolodato commented Jan 8, 2025

Is your feature request related to a problem? Please describe.

The Django SECRET_KEY is used as the JWT signing secret when COOKIE_AUTH_ENABLED is set but no COOKIE_AUTH_JWT_SIGNING_KEY was provided:

"SIGNING_KEY": env.str("COOKIE_AUTH_JWT_SIGNING_KEY", default=SECRET_KEY),

Our default Helm values does not define a secret key, so one gets randomly generated on each deployment: https://github.com/Flagsmith/flagsmith-charts/blob/65ce6fd59b9dc3189e44cc8f4766aa5d8e468724/charts/flagsmith/values.yaml#L39-L44

Because the /auth/saml/{configuration}/request/ endpoint validates cookies, the following can happen:

  1. Log in via SSO - a JWT cookie gets set
  2. Redeploy Flagsmith without a secret key - another secret key gets generated
  3. Try to log in via SSO again - because the user still has a cookie set with the old secret key, this gets rejected by /auth/saml/{configuration}/request and the user cannot log in until they clear their cookies

This is technically not a bug since users should be setting secret keys, but it is a quality-of-life improvement to avoid confusing behaviour when testing Flagsmith infrastructure.

Describe the solution you'd like.

/auth/saml/{configuration}/request is a public endpoint, so it should not validate cookies at all.

Describe alternatives you've considered

Alternatively, clear cookies even before login if they were rejected by having an invalid signature. This is a possibly more intrusive change, and is already handled correctly by the frontend after login.

Additional context

No response

@rolodato rolodato added api Issue related to the REST API front-end Issue related to the React Front End Dashboard labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

No branches or pull requests

1 participant