Skip to content

Conversation

IvanChalukov
Copy link
Contributor

@IvanChalukov IvanChalukov commented Jun 25, 2025

Changes proposed by this PR

Previously, the logout endpoint of the Concourse API only removed the skymarshal_auth and skymarshal_csrf cookies from the browser, without invalidating the access tokens issued to the user. As a result, users could still use their tokens to interact with the Concourse API even after logging out.

With this implementation, tokens are now explicitly removed from both the local cache and the database. This ensures that after logging out, users can no longer use their tokens to authenticate API requests.

I am opening the PR as a draft since I want to confirm this changes in SkyServer and I need to add tests cases as well.

closes #9215

  • Implement cleaning of tokens from Database
  • Implement cleaning of tokens from cache
  • Call Logout Endpoint on fly logout
  • Test Logout API
  • Test FLY logout

Notes to reviewer

I’ve renamed loginHandler to skyHandler to better reflect its broader responsibility, as it handles more than just login logic.
Details on how to reproduce the issue can be found in the linked issue.

Release Note

  • Ensures tokens are removed from local cache and database, preventing post-logout API access.

- Implemented DeleteAccessToken in claimsCacher to remove tokens from the cache.
- Added DeleteAccessToken method to AccessTokenFactory for database token removal.

Signed-off-by: IvanChalukov <ichalukov@gmail.com>
Rename LoginHandler to SkyHandler, since it is responsible on only for Login implementation.
Signed-off-by: IvanChalukov <ichalukov@gmail.com>
This way it will remote tokens not only from local flyrc file, but from server cache and Database as well.

Signed-off-by: IvanChalukov <ichalukov@gmail.com>
@IvanChalukov
Copy link
Contributor Author

Hi @taylorsilva, Could you please confirm if you're okay with the changes introduced by this PR (in Skyserver, ClaimsCacher, fly logout function, etc.)? Once I have your go-ahead, I’ll move forward with updating the tests.

Signed-off-by: IvanChalukov <ichalukov@gmail.com>
…ust tests

Signed-off-by: IvanChalukov <ichalukov@gmail.com>
Signed-off-by: IvanChalukov <ichalukov@gmail.com>
…a AccessTokenFactory

Signed-off-by: IvanChalukov <ichalukov@gmail.com>
… missing auth token and error cases during token deletion

Signed-off-by: IvanChalukov <ichalukov@gmail.com>
Copy link
Member

@taylorsilva taylorsilva left a comment

Choose a reason for hiding this comment

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

Hey, gave this a quick scan and it looks fine to me so far 👍

@IvanChalukov
Copy link
Contributor Author

Great, thanks so much for the feedback!
I've added test cases to cover the new logic, so I believe the PR is now ready for your review. Let me know if there's anything else you'd like me to adjust.

@IvanChalukov IvanChalukov marked this pull request as ready for review July 4, 2025 15:06
@IvanChalukov IvanChalukov requested a review from a team as a code owner July 4, 2025 15:06
Copy link
Contributor

@Kump3r Kump3r left a comment

Choose a reason for hiding this comment

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

Code review 👨‍💻:

I cannot speak on the code structure and conventions themselves, as I am not that in depth familiar with the whole codebase and common practices. In any case, they look way better than what I would have done 😅, so good job! What I could do though is play around with some testing.

Tests 🧪 :

I reproduced the behaviour from master and builded an image with your code for testing. What I ended up testing:

  1. Logout from API 🔒 :
  • invalidates the token from the cookies as before - ✅
  • invalidates the token from the db and cache - ✅
  1. fly logout (took me 2-3 minutes to figure out that I had to rebuild fly and was ready to start debugging, so I reproduced it as well)
    • single target (fly logout -t some-target) - ✅

    Note: Also tested that single target logout did not impact any of my other targets 🎯

    • multiple targets (fly logout -a), in my case 3 targets - ✅

Conclusion 🏁 :

I wasn't able to think of anything else to test, but will be more than happy to if someone can think of weird scenarios, as it was quite fast and easy to test this security enhancement. Very good job on the PR and thanks for making our favourite continuous thing-doer more secure 🔐 !

Signed-off-by: Taylor Silva <dev@taydev.net>
Copy link
Member

@taylorsilva taylorsilva left a comment

Choose a reason for hiding this comment

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

LGTM - I pushed a commit with some nitpick stuff, didn't change anything else you did though.

I manually tested and verified that logging out from the web UI and fly cli, results in the token being removed from the database. Thanks for improving Concourse's security! 🎉

@taylorsilva taylorsilva moved this from Todo to In Progress in Pull Requests Jul 7, 2025
@taylorsilva taylorsilva merged commit 47e930c into concourse:master Jul 8, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Pull Requests Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Logout does not invalidate access token in Concourse
3 participants