fix(webui): gate bootstrap API token issuance
This commit is contained in:
1 parent
7204d88a4c
commit
88143a8bf0
16 files changed
+219
-85
No files matched your search
@@ -50,6 +50,12 @@ class GatewayTokenStore:
|
||||
self.api_tokens[token_value] = expiry
|
||||
return token_value
|
||||
|
||||
def issue_api_token(self, ttl_s: int | float) -> str:
|
||||
token_value = f"nbwt_{secrets.token_urlsafe(32)}"
|
||||
expiry = time.monotonic() + float(ttl_s)
|
||||
self.api_tokens[token_value] = expiry
|
||||
return token_value
|
||||
|
||||
def take_issued_token_if_valid(self, token_value: str | None) -> bool:
|
||||
if not token_value:
|
||||
return False
|
||||
|
||||
Reference in new issue
Block a user