Sync shared snapshot from de9b599
This commit is contained in:
1 parent
eb113a7029
commit
49e3c7d561
9 files changed
+697
-44
No files matched your search
@@ -61,6 +61,15 @@ DEFAULT_TIMEOUT = 5.0
|
||||
_BEARER_PREFIX = "Bearer "
|
||||
|
||||
|
||||
def _normalize_base_url(base_url: str) -> str:
|
||||
trimmed = str(base_url or "").strip().rstrip("/")
|
||||
if not trimmed:
|
||||
return trimmed
|
||||
if trimmed.lower().startswith(("http://", "https://")):
|
||||
return trimmed
|
||||
return f"https://{trimmed}"
|
||||
|
||||
|
||||
class InvalidSessionError(Exception):
|
||||
"""Raised by validate() / resolve_user() when AuthGuard reports the
|
||||
token/cookie as not currently valid (expired, unknown, or missing)."""
|
||||
@@ -170,11 +179,15 @@ class AuthClient:
|
||||
timeout: float = DEFAULT_TIMEOUT,
|
||||
) -> None:
|
||||
"""base_url is AuthGuard's base URL, e.g. "https://auth.example.com"
|
||||
(no trailing slash required). cookie_name is the cookie
|
||||
(no trailing slash required). May be given without a scheme (e.g.
|
||||
"auth.example.com" or "192.168.1.50:8080") -- "https://" is assumed
|
||||
in that case, so a deployment only needs to name the host, not repeat
|
||||
the scheme; an explicit "http://" (for a plain-HTTP local/LAN
|
||||
AuthGuard) is left as-is. cookie_name is the cookie
|
||||
token_from_request looks for when there is no Authorization header;
|
||||
it must match AuthGuard's SessionCookieName. timeout is the request
|
||||
timeout in seconds for the underlying blocking HTTP call."""
|
||||
self.base_url = str(base_url or "").strip().rstrip("/")
|
||||
self.base_url = _normalize_base_url(base_url)
|
||||
self.cookie_name = cookie_name
|
||||
self.timeout = timeout
|
||||
|
||||
|
||||
Reference in new issue
Block a user