Skip to content

Conversation

edisile
Copy link
Contributor

@edisile edisile commented Oct 21, 2025

This PR updates logout logic to remove developer_token, exchanged_developer_token and csrf_token from the Flask session cookie. Currently the old values are never removed from the session and some brand store features (e.g. Models) become inaccessible after 24 hours even after logging out, unless the session cookie is removed manually by the user.

Done

  • updated logout logic to remove all data from the Flask session cookie
  • updated unit logout test to check the session is cleared correctly

How to QA

Ideally the best way to make sure that this fixes the issue is by logging in on the demo site and waiting for 24 hours for the macaroons to expire, then go though the SSO auth again to check if the developer_token gets refreshed correctly. This is quite cumbersome, so the next best thing to test is what happens when you log out (since this is effectively what happens when visiting publisher routes with an expired macaroon).

  • visit https://snapcraft-io-5429.demos.haus
  • log in and open a brand store
  • open the browser dev tools and head to the Cookies section
    • Chromium browsers: "Application" tab -> "Cookies" in the left sidenav
    • Firefox browsers: "Storage" tab -> "Cookies" in the left sidenav
  • look for the session cookie
    • it should be a few thousand characters long
  • go to the Network tab of the dev tools
  • log out
  • look for the navigation event to /logout and check the response cookies
    • the Set-Cookie header should start with session=;
  • go back to the Cookies section in dev tools
    • the session cookie should have disappeared

Testing

  • This PR has tests
  • No testing required (explain why):

Issue / Card

Fixes #5414 (WD-29847)

Screenshots

@webteam-app
Copy link

@edisile edisile force-pushed the WD-29847_model-service-macaroon-refresh branch from ec90005 to 13947bb Compare October 21, 2025 15:45
@alvaromateo alvaromateo self-requested a review October 21, 2025 16:13
Copy link
Contributor

@steverydz steverydz left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@alvaromateo alvaromateo left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Model Service won't appear without clearing cache

4 participants