Skip to content

Commit

Permalink
fix:Multiple bypass keys (#2668)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matvey-Kuk authored Nov 27, 2024
1 parent fb0bc90 commit bb57989
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit bb57989

Please sign in to comment.