awsapilib.authentication package

Submodules

awsapilib.authentication.authentication module

Main code for authentication.

class awsapilib.authentication.authentication.Authenticator(arn, session_duration=3600, region=None)[source]

Bases: BaseAuthenticator

Interfaces with aws authentication mechanisms, providing pre signed urls, or authenticated sessions.

property assumed_role_credentials

Valid credentials for an assumed session.

Returns:

A properly structured dictionary of an assumed session credentials.

Return type:

credentials (dict)

get_billing_authenticated_session()[source]

Authenticates to billing and returns an authenticated session.

Returns:

An authenticated session with headers and cookies set.

Return type:

session (requests.Session)

get_cloudformation_authenticated_session()[source]

Authenticates to cloudformation and returns an authenticated session.

Returns:

An authenticated session with headers and cookies set.

Return type:

session (requests.Session)

get_signed_url(domain='Example.com', destination=None)[source]

Returns a pre signed url that is authenticated.

Parameters:
  • domain (str) – The domain to request the session as.

  • destination (str) – The service to redirect to after successful redirection.

Returns:

An authenticated pre signed url.

Return type:

url (str)

get_sso_authenticated_session()[source]

Authenticates to Single Sign On and returns an authenticated session.

Returns:

An authenticated session with headers and cookies set.

Return type:

session (requests.Session)

property session_credentials

Valid credentials for a session.

Returns:

A properly structured dictionary of session credentials.

Return type:

credentials (dict)

class awsapilib.authentication.authentication.BaseAuthenticator(region=None)[source]

Bases: LoggerMixin

Interfaces with aws authentication mechanisms, providing pre signed urls, or authenticated sessions.

class awsapilib.authentication.authentication.CsrfTokenData(entity_type: str, attributes: dict, attribute_value: str, headers_name: str)[source]

Bases: object

Object modeling the data required for csrf token filtering.

attribute_value: str
attributes: dict
entity_type: str
headers_name: str
class awsapilib.authentication.authentication.Domains(region: str, root: str = 'aws.amazon.com', sign_in: str = 'signin.aws.amazon.com', console: str = 'console.aws.amazon.com')[source]

Bases: object

Dataclass holding the domains required for authenticating.

console: str = 'console.aws.amazon.com'
region: str
property regional_console

The domain of the regional console.

Returns:

The regional console domain.

Return type:

regional_console (str)

root: str = 'aws.amazon.com'
sign_in: str = 'signin.aws.amazon.com'
class awsapilib.authentication.authentication.FilterCookie(name: str, domain: str = '', exact_match: bool = False)[source]

Bases: object

Object modeling a cookie for filtering.

domain: str = ''
exact_match: bool = False
name: str
class awsapilib.authentication.authentication.LoggerMixin[source]

Bases: object

Logger.

property logger

Exposes the logger to be used by objects using the Mixin.

Returns:

The properly named logger.

Return type:

logger (logger)

class awsapilib.authentication.authentication.Urls(region: str, scheme: str = 'https://', root_domain: str = 'aws.amazon.com', root: str = 'https://aws.amazon.com', sign_in: str = 'https://signin.aws.amazon.com', console: str = 'https://console.aws.amazon.com', console_home: str = 'https://console.aws.amazon.com/console/home', billing_home: str = 'https://console.aws.amazon.com/billing/home', billing_rest: str = 'https://console.aws.amazon.com/billing/rest', iam_home: str = 'https://console.aws.amazon.com/iam/home', iam_api: str = 'https://console.aws.amazon.com/iam/api', federation: str = 'https://signin.aws.amazon.com/federation')[source]

Bases: object

Dataclass holding the urls required for authenticating.

billing_home: str = 'https://console.aws.amazon.com/billing/home'
billing_rest: str = 'https://console.aws.amazon.com/billing/rest'
console: str = 'https://console.aws.amazon.com'
console_home: str = 'https://console.aws.amazon.com/console/home'
federation: str = 'https://signin.aws.amazon.com/federation'
property global_billing_home

The url of the global billing console.

Returns:

The url of the global billing console.

Return type:

global_billing (str)

property global_iam_home

The url of the global IAM console.

Returns:

The url of the global IAM console.

Return type:

global_iam_home (str)

iam_api: str = 'https://console.aws.amazon.com/iam/api'
iam_home: str = 'https://console.aws.amazon.com/iam/home'
region: str
property regional_console

The url of the regional console.

Returns:

The regional console url.

Return type:

regional_console (str)

property regional_console_home

The url of the regional console home page.

Returns:

The regional console home page url.

Return type:

regional_console (str)

property regional_control_tower

The url of the regional control tower service.

Returns:

The regional control tower on url.

Return type:

regional_control_tower (str)

property regional_relay_state

The regional relay state url.

Returns:

The regional relay state url.

Return type:

relay_state (str)

property regional_single_sign_on

The url of the regional single sign on.

Returns:

The regional single sign on url.

Return type:

regional_single_sign_on (str)

root: str = 'https://aws.amazon.com'
root_domain: str = 'aws.amazon.com'
scheme: str = 'https://'
sign_in: str = 'https://signin.aws.amazon.com'

awsapilib.authentication.authenticationexceptions module

Custom exception code for authentication.

exception awsapilib.authentication.authenticationexceptions.ExpiredCredentials[source]

Bases: Exception

Credentials used to assume the role has expired.

exception awsapilib.authentication.authenticationexceptions.InvalidCredentials[source]

Bases: Exception

No credentials or the credentials provided are not correct.

exception awsapilib.authentication.authenticationexceptions.NoSigninTokenReceived[source]

Bases: Exception

No Signing token was received.

awsapilib.authentication.utils module

Main code for utils.

class awsapilib.authentication.utils.HarParser(har_file)[source]

Bases: object

Parses a provided har file.

get_communication_for_billing()[source]

Returns a text of the communication of a valid login to billing.

Returns:

Returns a text of the communication of a valid login to billing.

Return type:

text (str)

get_communication_for_cloudformation()[source]

Returns a text of the communication of a valid login to cloud formation service.

Returns:

Returns a text of the communication of a valid login to cloud formation service.

Return type:

text (str)

get_communication_for_console()[source]

Returns a text of the communication of a valid login to console.

Returns:

Returns a text of the communication of a valid login to console.

Return type:

text (str)

get_communication_for_control_tower()[source]

Returns a text of the communication of a valid login to control tower.

Returns:

Returns a text of the communication of a valid login to control tower.

Return type:

text (str)

get_communication_for_iam()[source]

Returns a text of the communication of a valid login to iam service.

Returns:

Returns a text of the communication of a valid login to iam service.

Return type:

text (str)

get_communication_for_sso()[source]

Returns a text of the communication of a valid login to single sign on.

Returns:

Returns a text of the communication of a valid login to single sign on.

Return type:

text (str)

render_communication_for_billing()[source]

Prints a text of the communication of a valid login to billing.

Returns:

None

render_communication_for_cloudformation()[source]

Prints a text of the communication of a valid login to cloud formation service.

Returns:

None

render_communication_for_console()[source]

Prints a text of the communication of a valid login to console.

Returns:

None

render_communication_for_control_tower()[source]

Prints a text of the communication of a valid login to control tower.

Returns:

None

render_communication_for_iam()[source]

Prints a text of the communication of a valid login iam service.

Returns:

None

render_communication_for_sso()[source]

Prints a text of the communication of a valid login to single sign on.

Returns:

None

Module contents

awsauthenticationlib package.

Import all parts from awsauthenticationlib here