Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: