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

Encryption in JWT for single-user password mode #2111

Merged
merged 4 commits into from
Aug 14, 2024

Conversation

timothycarambat
Copy link
Member

Pull Request Type

  • ✨ feat
  • πŸ› fix
  • ♻️ refactor
  • πŸ’„ style
  • πŸ”¨ chore
  • πŸ“ docs

Relevant Issues

resolves #xxx

What is in this change?

As a convenience, we have always just included the plaintext password in the JWT so we can quickly compare with requests on the backend. While this does work and is mostly safe, if for whatever reason, the JWT was taken from the user's browser, then it could be used to directly login to the instance without needing to do a JWT replay.

This is very unlikely and only applies to single-user instances that are using simple password protection.

Now, we encrypt and decrypt this p value in the JWT, as a consequence any currently logged-in sessions under these conditions will be logged out as their previous token will not pass validation. All that needs to be done is for the user to log back in to get a compliant token.

@timothycarambat timothycarambat marked this pull request as ready for review August 14, 2024 00:54
@timothycarambat timothycarambat merged commit 4430ddb into master Aug 14, 2024
1 check passed
@timothycarambat timothycarambat deleted the encrypt-jwt-value branch August 14, 2024 00:54
TuanBC pushed a commit to TuanBC/anything-llm that referenced this pull request Aug 26, 2024
* wip encrypting jwt value

* Encrypt/Decrypt pass in JWT value for verification in single-user password mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant