1.16.28

flytekit.clients.auth_helper

Directory

Classes

Class Description
AuthenticationHTTPAdapter A custom HTTPAdapter that adds authentication headers to requests of a session.
RemoteClientConfigStore This class implements the ClientConfigStore that is served by the Flyte Server, that implements AuthMetadataService.

Methods

Method Description
bootstrap_creds_from_server() Retrieves the SSL cert from the remote and uses that.
get_authenticated_channel() Returns a new channel for the given config that is authenticated.
get_authenticator() Returns a new authenticator based on the platform config.
get_channel() Creates a new grpc.
get_proxy_authenticator()
get_session() Return a new session for the given platform config.
register_authenticator_plugin() Register an authenticator factory by name.
upgrade_channel_to_authenticated() Given a grpc.
upgrade_channel_to_proxy_authenticated() If activated in the platform config, given a grpc.
upgrade_session_to_proxy_authenticated() Given a requests.
wrap_exceptions_channel() Wraps the input channel with RetryExceptionWrapperInterceptor.

Variables

Property Type Description
AUTH_ENTRY_POINT_GROUP str

Methods

bootstrap_creds_from_server()

def bootstrap_creds_from_server(
    endpoint: str,
) -> grpc.ChannelCredentials

Retrieves the SSL cert from the remote and uses that. should be used only if insecure-skip-verify

Parameter Type Description
endpoint str

get_authenticated_channel()

def get_authenticated_channel(
    cfg: flytekit.configuration.PlatformConfig,
) -> grpc.Channel

Returns a new channel for the given config that is authenticated

Parameter Type Description
cfg flytekit.configuration.PlatformConfig

get_authenticator()

def get_authenticator(
    cfg: flytekit.configuration.PlatformConfig,
    cfg_store: flytekit.clients.auth.authenticator.ClientConfigStore,
) -> flytekit.clients.auth.authenticator.Authenticator

Returns a new authenticator based on the platform config.

Built-in auth types (PKCE, ClientSecret, ExternalCommand, DeviceFlow) are tried first. If auth_mode is a string that does not match any built-in type, the function falls back to entry-point discovery: any installed package can register an authenticator factory under the flytekit.auth entry point group and it will be loaded automatically.

Parameter Type Description
cfg flytekit.configuration.PlatformConfig
cfg_store flytekit.clients.auth.authenticator.ClientConfigStore

get_channel()

def get_channel(
    cfg: flytekit.configuration.PlatformConfig,
    **kwargs,
) -> grpc.Channel

Creates a new grpc.Channel given a platformConfig. It is possible to pass additional options to the underlying channel. Examples for various options are as below

get_channel(cfg=PlatformConfig(...))

Additional options to insecure / secure channel. Example options and compression refer to grpc guide

get_channel(cfg=PlatformConfig(...), options=..., compression=...)

Create secure channel with custom grpc.ssl_channel_credentials

get_channel(cfg=PlatformConfig(insecure=False,...), credentials=...)
Parameter Type Description
cfg flytekit.configuration.PlatformConfig PlatformConfig
**kwargs Optional arguments to be passed to channel method. Refer to usage example above

Returns: grpc.Channel (secure / insecure)

get_proxy_authenticator()

def get_proxy_authenticator(
    cfg: flytekit.configuration.PlatformConfig,
) -> flytekit.clients.auth.authenticator.Authenticator
Parameter Type Description
cfg flytekit.configuration.PlatformConfig

get_session()

def get_session(
    cfg: flytekit.configuration.PlatformConfig,
    **kwargs,
) -> requests.sessions.Session

Return a new session for the given platform config.

Parameter Type Description
cfg flytekit.configuration.PlatformConfig
**kwargs

register_authenticator_plugin()

def register_authenticator_plugin(
    name: str,
    factory: typing.Callable[[ForwardRef('PlatformConfig'), flytekit.clients.auth.authenticator.ClientConfigStore], flytekit.clients.auth.authenticator.Authenticator],
)

Register an authenticator factory by name.

This is the primary registration mechanism and works in every environment (pip, Bazel, mono-repo vendoring, etc.). Entry-point discovery is attempted as a fallback when no explicit registration exists.

Parameter Type Description
name str
factory typing.Callable[[ForwardRef('PlatformConfig'), flytekit.clients.auth.authenticator.ClientConfigStore], flytekit.clients.auth.authenticator.Authenticator]

upgrade_channel_to_authenticated()

def upgrade_channel_to_authenticated(
    cfg: flytekit.configuration.PlatformConfig,
    in_channel: grpc.Channel,
) -> grpc.Channel

Given a grpc.Channel, preferably a secure channel, it returns a composed channel that uses Interceptor to perform an Oauth2.0 Auth flow

Parameter Type Description
cfg flytekit.configuration.PlatformConfig PlatformConfig
in_channel grpc.Channel grpc.Channel Precreated channel

Returns: grpc.Channel. New composite channel

upgrade_channel_to_proxy_authenticated()

def upgrade_channel_to_proxy_authenticated(
    cfg: flytekit.configuration.PlatformConfig,
    in_channel: grpc.Channel,
) -> grpc.Channel

If activated in the platform config, given a grpc.Channel, preferably a secure channel, it returns a composed channel that uses Interceptor to perform authentication with a proxy in front of Flyte

Parameter Type Description
cfg flytekit.configuration.PlatformConfig PlatformConfig
in_channel grpc.Channel grpc.Channel Precreated channel

Returns: grpc.Channel. New composite channel

upgrade_session_to_proxy_authenticated()

def upgrade_session_to_proxy_authenticated(
    cfg: flytekit.configuration.PlatformConfig,
    session: requests.sessions.Session,
) -> requests.sessions.Session

Given a requests.Session, it returns a new session that uses a custom HTTPAdapter to perform authentication with a proxy in front of Flyte

Parameter Type Description
cfg flytekit.configuration.PlatformConfig PlatformConfig
session requests.sessions.Session requests.Session Precreated session

Returns: requests.Session. New session with custom HTTPAdapter mounted

wrap_exceptions_channel()

def wrap_exceptions_channel(
    cfg: flytekit.configuration.PlatformConfig,
    in_channel: grpc.Channel,
) -> grpc.Channel

Wraps the input channel with RetryExceptionWrapperInterceptor. This wrapper will cover all exceptions and raise Exception from the Family flytekit.exceptions

This channel should be usually the outermost channel. This channel will raise a FlyteException

Parameter Type Description
cfg flytekit.configuration.PlatformConfig PlatformConfig
in_channel grpc.Channel grpc.Channel

Returns: grpc.Channel

flytekit.clients.auth_helper.AuthenticationHTTPAdapter

A custom HTTPAdapter that adds authentication headers to requests of a session.

Parameters

class AuthenticationHTTPAdapter(
    authenticator,
    *args,
    **kwargs,
)
Parameter Type Description
authenticator
*args
**kwargs

Methods

Method Description
add_auth_header() Adds authentication headers to the request.
send() Sends the request with added authentication headers.

add_auth_header()

def add_auth_header(
    request,
)

Adds authentication headers to the request.

Parameter Type Description
request The request object to add headers to.

send()

def send(
    request,
    *args,
    **kwargs,
)

Sends the request with added authentication headers. If the response returns a 401 status code, refreshes the credentials and retries the request.

Parameter Type Description
request The request object to send.
*args
**kwargs

Returns: The response object.

flytekit.clients.auth_helper.RemoteClientConfigStore

This class implements the ClientConfigStore that is served by the Flyte Server, that implements AuthMetadataService

Parameters

class RemoteClientConfigStore(
    secure_channel: grpc.Channel,
)
Parameter Type Description
secure_channel grpc.Channel

Methods

Method Description
get_client_config() Retrieves the ClientConfig from the given grpc.

get_client_config()

def get_client_config()

Retrieves the ClientConfig from the given grpc.Channel assuming AuthMetadataService is available