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

fix:Multiple bypass keys #2668

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions keep/identitymanager/authverifierbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ def __init__(self, scopes: list[str] = []) -> None:
self.key_last_used_updates = {}
# check if read only instance
self.read_only = config("KEEP_READ_ONLY", default="false") == "true"
self.read_only_bypass_key = config("KEEP_READ_ONLY_BYPASS_KEY", default="")
self.read_only_bypass_keys = config("KEEP_READ_ONLY_BYPASS_KEY", default="")
self.read_only_bypass_keys = self.read_only_bypass_keys.split(",")
# if read_only is enabled, read_only_bypass_key must be set
if self.read_only and not self.read_only_bypass_key:
if self.read_only and not self.read_only_bypass_keys:
raise ValueError(
"KEEP_READ_ONLY_BYPASS_KEY must be set if KEEP_READ_ONLY is enabled"
)
Expand Down Expand Up @@ -113,7 +114,7 @@ def __call__(
HTTPException: If authentication or authorization fails.
"""
self.logger.debug("Starting authentication process")
if self.read_only and api_key != self.read_only_bypass_key:
if self.read_only and api_key not in self.read_only_bypass_keys:
# check if the scopes have scopes other than only read
if any([scope.split(":")[0] != "read" for scope in self.scopes]):
self.logger.error("Read only instance, but non-read scopes requested")
Expand Down
Loading