Pyjo.AWS.Credentials.Login - Credentials of aws login¶
from Pyjo.AWS.Credentials.Login import Login
credentials = Login().credentials()
# Or import the module, as in Google Python Style Guide
import Pyjo.AWS.Config
import Pyjo.AWS.Credentials.Login
provider = Pyjo.AWS.Credentials.Login.new(config=Pyjo.AWS.Config.new(profile='console'))
provider.credentials_p().then(lambda credentials: print(credentials.expiration)).wait()
Pyjo.AWS.Credentials.Login is the provider of the credentials of a
profile of aws login, the credentials of a session of the AWS Management
Console, as the SDKs of AWS get them: the credentials of the cache of the AWS
CLI, in ~/.aws/login/cache, of the login_session of the profile, which
aws login writes:
[profile console]
login_session = arn:aws:sts::123456789012:assumed-role/Admin/alice
region = eu-central-1
The credentials, of 15 minutes, are refreshed before they expire with
CreateOAuth2Token of the sign-in service of AWS in the region of the
environment or the profile, with the refresh token of the cache and the proof of possession of
its key, of DPoP, of RFC 9449, which Pyjo.AWS.ECDSA signs, and written
back to the cache, as the AWS CLI does, for the hours of the session of the
console.
A session that is not in the cache is an error, and so is one whose refresh
token has expired, which tells to run aws login.
See also¶
Pyjo.AWS.Credentials.Provider, Pyjo.AWS.Credentials.Profile,
Pyjo.AWS.ECDSA,
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sign-in.html.
Classes¶
- class Pyjo.AWS.Credentials.Login.Pyjo_AWS_Credentials_Login(*, config: Pyjo_AWS_Config | None = None, profile: str | None = None, cache_dir: str | None = None, **kwargs: Any)[source]¶
Pyjo.AWS.Credentials.Logininherits all attributes and methods fromPyjo.AWS.Credentials.Providerand implements the following new ones.- __init__(*, config: Pyjo_AWS_Config | None = None, profile: str | None = None, cache_dir: str | None = None, **kwargs: Any) None[source]¶
provider = Pyjo.AWS.Credentials.Login.new() provider = Pyjo.AWS.Credentials.Login.new(config=Pyjo.AWS.Config.new(profile='console')) provider = Pyjo.AWS.Credentials.Login.new(profile='console', cache_dir='/tmp/login')
Construct a new
Pyjo.AWS.Credentials.Loginobject, with the options ofPyjo.AWS.Credentials.Provider.
- cache_dir¶
path = provider.cache_dir
The
Pyjo.Fileobject of the directory of the cache of the sessions, of theAWS_LOGIN_CACHE_DIRECTORYenvironment variable, or~/.aws/login/cacheof the AWS CLI by default.
- cache_file(session: str) Pyjo_File[source]¶
path = provider.cache_file('arn:aws:sts::123456789012:assumed-role/Admin/alice')
The file of a session in
cache_dir, of the SHA-256 of its name, as the AWS CLI names it.
- config¶
config = provider.config
The shared files, a new
Pyjo.AWS.Configobject by default.
- endpoint_url() str[source]¶
url = provider.endpoint_url()
The URL of the sign-in service, the one of the ID
Signinthat the environment or the profile configures, or the one of the region of the environment or the profile, ashttps://eu-central-1.signin.aws.amazon.com, ofamazonaws.cnin the regions of China.
- async fetch() Pyjo_AWS_Credentials | None[source]¶
credentials = await provider.fetch()
The credentials of the session of the profile, refreshed before they expire, or
Noneof a profile withoutlogin_session.
- Pyjo.AWS.Credentials.Login.dpop(key: Pyjo_AWS_ECDSA, url: str, method: str = 'POST') str[source]¶
proof = Pyjo.AWS.Credentials.Login.dpop(key, 'https://eu-central-1.signin.aws.amazon.com/v1/token')
The proof of possession of a key of DPoP, of RFC 9449, for a request, a JSON Web Token of ES256 with the public key, as the sign-in service of AWS wants it.