To obtain an Access Token, an ID Token, and optionally a Refresh Token, the RP (Client) sends a Token Request to the Token Endpoint to obtain a Token Response, as described in Section 3.2 of OAuth 2.0 [RFC6749], when using the Authorization Code Flow.
It responds with user attribute when service providers present access tokens that your Token endpoint issued.
Being built on top of OAuth 2.0, OpenID Connect uses tokens to provide a simple identity layer integrated with the underlying authorization framework. This integration implies the use of the following types of token:
ID Token: Specific to OIDC, the primary use of this token in JWT format is to provide information about the authentication operation’s outcome. Upon request, it may provide the identity data describing a user profile. The data about the authentication result and the user profile information are called claims. The user profile claims may be any data that is pertinent to the Relying Party for identification purposes, such as a persistent ID, email address, name, etc.
Access Token: Defined in OAuth2, this (optional) short lifetime token provides access to specific user resources as defined in the scope values in the request to the authorization server.
Refresh Token: Coming from OAuth2 specs, this token is usually long-lived and may be used to obtain new access tokens.
make the token available to the Pod at a configurable file path; and refresh the token as it approaches expiration.
The kubelet proactively requests rotation for the token if it is older than 80% of its total time-to-live (TTL), or if the token is older than 24 hours.
The application is responsible for reloading the token when it rotates. It’s often good enough for the application to load the token on a schedule (for example: once every 5 minutes), without tracking the actual expiry time.
The WebIdentityTokenCredentialsProvider using action sts:AssumeRoleWithWebIdentity to get temporary credential
the provider want to assume role arn:aws:iam::123456789012:role/test-role-for-service-account
the provider has a JWT token which injected to Pod
In some means, AWS STS checked with IAM and let the WebIdentityTokenCredentialsProvider assume role and return the temperory credential
The Pod application now use the temporary credential to access S3
Question:
What setting should we make on the role to allow sts:AssumeRoleWithWebIdentity ?
According to AWS IAM, A web identity session principal is a session principal that results from using the AWS STS AssumeRoleWithWebIdentity operation.
The trust relationship below would be attached to the AWS role arn:aws:iam::123456789012:role/test-role-for-service-account, which means the role trust the principal from AssumeRoleWithWebIdentity by the OIDC provider.
In other words, the service account test-service-account could assume the role arn:aws:iam::123456789012:role/test-role-for-service-account
After creating the OIDC identity provider, AWS IAM could authenticate AWS API calls with supported identity providers after receiving a valid OIDC JWT. This token can then be passed to AWS STS AssumeRoleWithWebIdentity API operation to get temporary IAM credentials.
$ aws iam create-open-id-connect-provider --url https://oidc.eks.us-west-2.amazonaws.com/id/55495BBBDD281DF88468ADFCFD2B3C2F ...
How to verify JWT from the OIDC identity provider?
The OIDC JWT token we have in our Kubernetes workload is cryptographically signed, and IAM should trust and validate these tokens before the AWS STS AssumeRoleWithWebIdentity API operation can send the temporary credentials.
As part of the Service Account Issuer Discovery feature of Kubernetes, EKS is hosting a public OpenID provider configuration document (Discovery endpoint) and the public keys to validate the token signature (JSON Web Key Sets – JWKS) at https://OIDC_PROVIDER_URL/.well-known/openid-configuration.