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

feat/1260/secure auth and jwt #1357

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

norton120
Copy link
Contributor

@norton120 norton120 commented May 8, 2024

Please describe the purpose of this pull request.
This PR is the first feature adding a secure token auth option to the Memgpt Server.
Secure tokens (denoted with sks- prefix for "secret key secure") are HS256 encrypted so they are not compromised in the event of a data breach.

For example, here's a secure API key:
sks-MTpjNDYwMjA5N2I2NDU0MWU3YWQ5NGVhMmQ3OGI5ZGMyNw

Here is how the key decodes:
key_id=1, raw_secret='c4602097b64541e7ad94ea2d78b9dc27'

And this is what's stored in the database for row # 1:
id=1, token='$2b$12$ZL85RPO49B4JVHqsFgsgKexfysUAnNQQr7ZoN8KzPli6pq5nMs6s6'

If someone gets their hands on database creds, they can steal all the tokens and the API keys are still theoretically secure.

How to test
Run the test suite and include the TestAuthUnit test class (included by default).

Have you tested this PR?
New tests are added in the PR.

Related issues or PRs
#898 #1260

Additional context
More to come this is still WIP. Need to:

  • integrate this secure API auth flow with the rest api
  • add jwt support across all endpoints
  • add a API key / jwt handoff
  • add jwt refresh endpoints
  • integration testing via httpx client

@norton120 norton120 changed the title Feat/1260/secure auth and jwt feat/1260/secure auth and jwt May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To triage
Development

Successfully merging this pull request may close these issues.

None yet

1 participant