flytekit.clients.auth.auth_client
Authorization client that stores the credentials in keyring and uses oauth2 standard flow to retrieve the
credentials. NOTE: This will open an web browser to retrieve the credentials.
class AuthorizationClient(
endpoint: str,
auth_endpoint: str,
token_endpoint: str,
audience: typing.Optional[str] = None,
scopes: typing.Optional[typing.List[str]] = None,
client_id: typing.Optional[str] = None,
redirect_uri: typing.Optional[str] = None,
endpoint_metadata: typing.Optional[EndpointMetadata] = None,
verify: typing.Optional[typing.Union[bool, str]] = None,
session: typing.Optional[requests.Session] = None,
request_auth_code_params: typing.Optional[typing.Dict[str, str]] = None,
request_access_token_params: typing.Optional[typing.Dict[str, str]] = None,
refresh_access_token_params: typing.Optional[typing.Dict[str, str]] = None,
add_request_auth_code_params_to_request_access_token_params: typing.Optional[bool] = False,
)
Create new AuthorizationClient
| Parameter |
Type |
Description |
endpoint |
str |
str endpoint to connect to |
auth_endpoint |
str |
str endpoint where auth metadata can be found |
token_endpoint |
str |
str endpoint to retrieve token from |
audience |
typing.Optional[str] |
Audience parameter for Auth0 |
scopes |
typing.Optional[typing.List[str]] |
list[str] oauth2 scopes |
client_id |
typing.Optional[str] |
oauth2 client id |
redirect_uri |
typing.Optional[str] |
oauth2 redirect uri |
endpoint_metadata |
typing.Optional[EndpointMetadata] |
EndpointMetadata object to control the rendering of the page on login successful or failure |
verify |
typing.Optional[typing.Union[bool, str]] |
Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to True. When set to False, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Setting verify to False may be useful during local development or testing. |
session |
typing.Optional[requests.Session] |
A custom requests.Session object to use for making HTTP requests. If not provided, a new Session object will be created. |
request_auth_code_params |
typing.Optional[typing.Dict[str, str]] |
dict of parameters to add to login uri opened in the browser |
request_access_token_params |
typing.Optional[typing.Dict[str, str]] |
dict of parameters to add when exchanging the auth code for the access token |
refresh_access_token_params |
typing.Optional[typing.Dict[str, str]] |
dict of parameters to add when refreshing the access token |
add_request_auth_code_params_to_request_access_token_params |
typing.Optional[bool] |
Whether to add the request_auth_code_params to the parameters sent when exchanging the auth code for the access token. Defaults to False. Required e.g. for the PKCE flow with flyteadmin. Not required for e.g. the standard OAuth2 flow on GCP. |
def get_creds_from_remote()
This is the entrypoint method. It will kickoff the full authentication
flow and trigger a web-browser to retrieve credentials. Because this
needs to open a port on localhost and may be called from a
multithreaded context (e.g. pyflyte register), this call may block
multiple threads and return a cached result for up to 60 seconds.
def refresh_access_token(
credentials: Credentials,
) -> Credentials
| Parameter |
Type |
Description |
credentials |
Credentials |
|
class AuthorizationCode(
code,
state,
)
| Parameter |
Type |
Description |
code |
|
|
state |
|
|
| Property |
Type |
Description |
code |
None |
|
state |
None |
|
This class can be used to control the rendering of the page on login successful or failure
class EndpointMetadata(
endpoint: str,
success_html: typing.Optional[bytes] = None,
failure_html: typing.Optional[bytes] = None,
)
| Parameter |
Type |
Description |
endpoint |
str |
|
success_html |
typing.Optional[bytes] |
|
failure_html |
typing.Optional[bytes] |
|
A simple wrapper around BaseHTTPServer.BaseHTTPRequestHandler that handles a callback URL that accepts an
authorization token.
class OAuthCallbackHandler(
request,
client_address,
server,
)
| Parameter |
Type |
Description |
request |
|
|
client_address |
|
|
server |
|
|
def handle_login(
data: dict,
)
| Parameter |
Type |
Description |
data |
dict |
|
A simple wrapper around the BaseHTTPServer.HTTPServer implementation that binds an authorization_client for handling
authorization code callbacks.
class OAuthHTTPServer(
server_address: typing.Tuple[str, int],
remote_metadata: EndpointMetadata,
request_handler_class: typing.Type[_BaseHTTPServer.BaseHTTPRequestHandler],
bind_and_activate: bool = True,
redirect_path: str = None,
queue: Queue = None,
)
Constructor. May be extended, do not override.
| Parameter |
Type |
Description |
server_address |
typing.Tuple[str, int] |
|
remote_metadata |
EndpointMetadata |
|
request_handler_class |
typing.Type[_BaseHTTPServer.BaseHTTPRequestHandler] |
|
bind_and_activate |
bool |
|
redirect_path |
str |
|
queue |
Queue |
|
| Property |
Type |
Description |
redirect_path |
str |
|
remote_metadata |
EndpointMetadata |
|
def handle_authorization_code(
auth_code: str,
)
| Parameter |
Type |
Description |
auth_code |
str |
|
def handle_request(
queue: Queue = None,
) -> typing.Any
Handle one request, possibly blocking.
Respects self.timeout.
| Parameter |
Type |
Description |
queue |
Queue |
|