Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a basic token-based authentication option alongside no-auth and OAuth2, including CLI commands, backend support, configuration, and documentation.
- Introduced TokenInfo model and bcrypt-backed token generation, hashing, and verification in
auth.py. - Implemented a new
tokenCLI group withadd,list,show, andremovecommands incli.py. - Extended settings, docs, and tests to cover token authentication (added
auth_mode,token_auth_enabled, bcrypt dependency).
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| agent_memory_server/auth.py | Added TokenInfo model, token generation, hashing, verification, and integrated token auth into get_current_user and verify_auth_config. |
| agent_memory_server/cli.py | Implemented token CLI commands (add, list, show, remove) with Redis storage and bcrypt hashing. |
| agent_memory_server/config.py | Added auth_mode and token_auth_enabled settings to support token authentication. |
| agent_memory_server/utils/keys.py | Added helper methods for token Redis keys (auth_token_key, auth_tokens_list_key). |
| pyproject.toml | Added bcrypt dependency for token hashing. |
| docs/configuration.md | Documented environment variables and settings for token authentication. |
| docs/cli.md | Added CLI documentation for the new token command group. |
| docs/authentication.md | Updated main authentication documentation to include token auth. |
| tests/test_token_cli.py | Added integration tests for all token CLI commands. |
| tests/test_token_auth.py | Added unit tests for token auth generation, hashing, and verification. |
| tests/test_auth.py | Extended existing auth tests to cover new settings (auth_mode, token_auth_enabled). |
Comments suppressed due to low confidence (4)
agent_memory_server/cli.py:306
- [nitpick] This function is named
list, which shadows the built-inlisttype. Consider renaming it tolist_tokensto avoid confusion and potential issues.
def list():
agent_memory_server/cli.py:262
- The
get_redis_connfunction is not imported in this module, leading to a NameError. Addfrom agent_memory_server.utils.redis import get_redis_connat the top of the file.
redis = await get_redis_conn()
agent_memory_server/cli.py:392
- This error message is inconsistent with the partial-hash branch and the tests. Tests expect
No token found matching. Update this toclick.echo(f"No token found matching '{token_hash}'").
click.echo(f"Token not found: {token_hash}")
agent_memory_server/auth.py:372
- Missing checks for absent or empty credentials. Before verifying a token or JWT, you should raise an HTTPException with status 401 for missing authorization header and missing bearer token, matching existing test expectations.
# Determine authentication mode
Collaborator
Author
|
You've heard of oAuth, but have you heard of No Auth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In addition to "no auth" and oAuth, we should have a basic token-based system.