academy.exchange.cloud.authenticate¶
Authenticate users from request headers.
Authenticator
¶
Bases: Protocol
Authenticate users from request headers.
authenticate_user
¶
Authenticate user from request headers.
Warning
This method must be thread safe!
Parameters:
Returns:
-
UUID
–A user id upon authentication success.
Raises:
-
ForbiddenError
–user is authenticated but is missing permissions or accessing forbidden resources.
-
UnauthorizedError
–user authentication fails.
Source code in academy/exchange/cloud/authenticate.py
NullAuthenticator
¶
GlobusAuthenticator
¶
GlobusAuthenticator(
client_id: str | None = None,
client_secret: str | None = None,
*,
audience: str = resource_server,
auth_client: ConfidentialAppAuthClient | None = None
)
Globus Auth authorizer.
Parameters:
-
client_id
(str | None
, default:None
) –Globus application client ID. If either
client_id
orclient_secret
isNone
, the values will be read from the environment variables as described inget_confidential_app_auth_client
. Ignored ifauth_client
is provided. -
client_secret
(str | None
, default:None
) –Globus application client secret. See
client_id
for details. Ignored ifauth_client
is provided. -
audience
(str
, default:resource_server
) –Intended audience of the token. This should typically be the resource server of the the token was issued for. E.g., the UUID of the ProxyStore Relay Server application.
-
auth_client
(ConfidentialAppAuthClient | None
, default:None
) –Optional confidential application authentication client which is used for introspecting client tokens.
Source code in academy/exchange/cloud/authenticate.py
authenticate_user
¶
Authenticate a Globus Auth user from request header.
This follows from the Globus Sample Data Portal example.
The underlying auth client is not thread safe, but this method is made thread safe using a lock.
Parameters:
Returns:
-
UUID
–Globus Auth identity returned via token introspection.
Raises:
-
UnauthorizedError
–if the authorization header is missing or the header is malformed.
-
ForbiddenError
–if the tokens have expired or been revoked.
-
ForbiddenError
–if
audience
is not included in the token's audience.
Source code in academy/exchange/cloud/authenticate.py
get_authenticator
¶
get_authenticator(
config: ExchangeAuthConfig,
) -> Authenticator
Create an authenticator from a configuration.
Parameters:
-
config
(ExchangeAuthConfig
) –Configuration.
Returns:
-
Authenticator
–Authenticator.
Raises:
-
ValueError
–if the authentication method in the config is unknown.
Source code in academy/exchange/cloud/authenticate.py
get_token_from_headers
¶
Extract token from websockets headers.
The header is expected to have the format Authorization: Bearer <TOKEN>
.
Parameters:
Returns:
-
str
–String token.
Raises:
-
UnauthorizedError
–if the authorization header is missing.
-
UnauthorizedError
–if the authorization header is malformed.