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

Port V13 backoffice cookie validation to V14 #15886

Merged
merged 2 commits into from
Mar 15, 2024

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Mar 14, 2024

Prerequisites

  • I have added steps to test this contribution in the description below

Description

Right now, the cookie validation for V14 is lacking a lot of basic stuff. For starters, if a user has authenticated against one database, the user authentication survives swapping out the entire DB with another DB (or delete and recreate the DB), as long as the user exist by the same email in both databases 🤦

This PR ports over all (almost all) the current cookie validation from V13 to V14, to handle these silly things.

A few things have been explicitly omitted, because they seems to have little meaning in the Management API. Please consider if this is as meaningful as I think 😆

Notice that this PR brings back the V13 backoffice cookie name (default UMB_UCONTEXT, configurable in security settings) - it has up until now been hardcoded to the name UmbracoBackOffice in V14.

image

Testing this PR

Swagger

  1. Authenticate Swagger against the Management API.
  2. Stop the site without signing out from swagger.
  3. Delete and recreate the database using unintended install.
  4. Perform any operation in Swagger without reloading swagger first. This should fail with a 401 because the previously issued token does not exist in the newly created DB.
  5. Sign out from Swagger.
  6. Re-authenticate Swagger against the Management API. Verify that you are indeed asked to sign in again.

Backoffice

  1. Sign into the backoffice.
  2. Stop the site without signing out from the backoffice.
  3. Delete and recreate the database using unintended install.
  4. Reload the backoffice. You should be alerted that your session has expired, because all issued tokens (including the refresh tokens) no longer exist.
  5. Go to /umbraco/login. Verify that you are indeed asked to sign in again.

Copy link
Member

@bergmania bergmania left a comment

Choose a reason for hiding this comment

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

Works as expected 💪

@bergmania bergmania merged commit 072903c into v14/dev Mar 15, 2024
16 checks passed
@bergmania bergmania deleted the v14/fix/backoffice-cookie-validation branch March 15, 2024 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants