AWS CLI authentication
authentik: 2025.12.0+
You can use the authentik Agent to authenticate to the AWS CLI with authentik credentials. The Agent exchanges them for temporary AWS credentials through one of two federation methods:
- SAML federation: reuses the SAML application and provider from the AWS Classic IAM integration. The Agent calls AWS STS
AssumeRoleWithSAML. - OIDC federation: uses a dedicated OAuth2/OpenID Connect application and provider for AWS. The Agent calls AWS STS
AssumeRoleWithWebIdentity.
Both methods also work for Amazon EKS.
SAML federation requires authentik 2026.11 or later. authentik Agent 0.72.5 or later is required for SAML federation and aws-eks authentication.
Prerequisites
- The authentik Agent must be deployed on your device with its
authentik-cliOAuth2 provider configured.
Both federation methods use the Agent's authentik-cli provider. SAML federation reuses your AWS SAML provider instead of adding a second OAuth2/OpenID Connect provider.
authentik configuration
- SAML
- OIDC
Allow token exchange to the SAML provider
If you already use authentik for AWS Classic IAM console SSO, reuse that application and provider. Otherwise, complete the AWS Classic IAM integration guide first, including its AWS role and role session name property mappings. This method does not use AWS IAM Identity Center.
Allow the Agent's provider to exchange its tokens for a SAML response from the AWS SAML provider:
- Log in to authentik as an administrator and open the authentik Admin interface.
- Navigate to Applications > Providers and edit the
authentik-cliOAuth2 provider used by the Agent. - Under Protocol settings > Grant Types, select Token exchange and keep the existing grant types selected.
- Click Save Changes.
- Edit the AWS SAML provider.
- Expand Machine-to-Machine authentication settings and add the
authentik-cliprovider to Federated OAuth2/OpenID Providers. - Click Save Changes.
The SAML application's bindings must allow the user.
Create an application and provider for AWS CLI
-
Log in to authentik as an administrator and open the authentik Admin interface.
-
Navigate to Applications > Applications and click New Application to create an application and provider pair. (Alternatively you can first create a provider separately, then create the application and connect it with the provider.)
- Application: provide a descriptive name, set the Slug to
authentik-aws-cli, and configure an optional group, the policy engine mode, and optional UI settings. - Choose a Provider Type: select OAuth2/OpenID Connect as the provider type.
- Configure the Provider: provide a name (or accept the auto-provided name), the authorization flow to use for this provider, and the following required configurations.
- Set the Client Type to
Public. - Set the Client ID to
authentik-aws-cli. - Select any available signing key.
- Expand Machine-to-Machine authentication settings and add the
authentik-cliprovider to Federated OAuth2/OpenID Providers.
- Set the Client Type to
- Configure Bindings (optional): you can create a binding (policy, group, or user) to manage access to the application.
- Application: provide a descriptive name, set the Slug to
-
Click Create Application to save the new application and provider.
AWS configuration
- SAML
- OIDC
Configure the IAM role for SAML federation
- Reuse an IAM role from your AWS Classic IAM integration, or create an IAM role for SAML federation.
- Verify the role trust policy. It must trust the IAM SAML identity provider for
sts:AssumeRoleWithSAML. - Bind the user to the application entitlement whose name matches this role. The user's SAML assertion only includes roles from their entitlements.
- Take note of the role ARN and the SAML identity provider ARN. You need both for the AWS CLI configuration.
Configure authentik CLI as an IdP in AWS
- Log in to the AWS Management Console as an administrator that has permissions to create IAM roles and identity providers.
- Open the IAM Console and in the left sidebar under Access Management, click Identity providers.
- Click Add provider and configure the following fields:
- Provider type:
OpenID Connect - Provider URL:
https://authentik.company/application/o/authentik-aws-cli/ - Audience:
authentik-aws-cli
- Provider type:
- Click Add provider.
Configure the IAM role for OIDC federation
-
Open the IAM Console and in the left sidebar under Access Management, click Roles.
-
Either create or edit a role that you want authentik users to be able to use.
-
Open the Trust relationships tab.
-
Click Edit trust policy and add the following, replacing
<account_id>with your AWS account ID andauthentik.companywith your authentik hostname:{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Principal": {"Federated": "arn:aws:iam::<account_id>:oidc-provider/authentik.company/application/o/authentik-aws-cli/"},"Action": "sts:AssumeRoleWithWebIdentity","Condition": {"StringEquals": {"authentik.company/application/o/authentik-aws-cli/:aud": "authentik-aws-cli"}}}]} -
Click Update policy.
-
Take note of the role ARN. You need it for the AWS CLI configuration.
The role's permissions policies decide what the user can do in AWS.
AWS CLI configuration
On the device where you run the AWS CLI, configure the default profile in ~/.aws/config to get temporary credentials from the authentik Agent through an external credential process. If ak is not on your PATH, use its full path in credential_process.
- SAML
- OIDC
[default]
region = <region>
credential_process = ak auth aws --audience <application_slug> --principal-arn arn:aws:iam::<account_id>:saml-provider/<saml_provider_name> --role-arn arn:aws:iam::<account_id>:role/<role_name> --region <region>
| Setting | Value |
|---|---|
--audience | Slug or UUID of the authentik SAML application. |
--principal-arn | ARN of the SAML identity provider in AWS IAM. |
--role-arn | ARN of the IAM role to assume. It must match a role and provider pair in the user's SAML assertion. |
--region | AWS region that the Agent uses for STS. |
region | Default AWS region that the AWS CLI uses for this profile. |
These settings are independent: region sets the AWS CLI's default region, while --region selects the region for the Agent's STS requests. The examples use the same value for both.
--audience identifies the authentik application. It is not the SAML provider's Audience setting, which is urn:amazon:webservices for AWS.
[default]
region = <region>
credential_process = ak auth aws --client-id authentik-aws-cli --role-arn arn:aws:iam::<account_id>:role/<role_name> --region <region>
| Setting | Value |
|---|---|
--client-id | Client ID of the authentik OAuth2/OpenID Connect provider for AWS, authentik-aws-cli. |
--role-arn | ARN of the IAM role to assume. It must trust the OIDC identity provider. |
--region | AWS region that the Agent uses for STS. |
region | Default AWS region that the AWS CLI uses for this profile. |
These settings are independent: region sets the AWS CLI's default region, while --region selects the region for the Agent's STS requests. The examples use the same value for both.
To verify, run:
aws sts get-caller-identity
The command outputs the assumed role:
{
"UserId": "<role_id>:<session_name>",
"Account": "<account_id>",
"Arn": "arn:aws:sts::<account_id>:assumed-role/<role_name>/<session_name>"
}
With SAML federation, the session name comes from the RoleSessionName property mapping. With OIDC federation, it is the user's preferred_username. This command checks that the Agent can get credentials, not that the role can access any AWS resources.
Amazon EKS authentication
ak auth aws-eks is a kubectl exec credential plugin that authenticates to Amazon EKS through AWS IAM. Unlike ak auth kubectl, it does not require OIDC configuration on the Kubernetes API server.
The command gets AWS credentials through SAML or OIDC federation, the same way as ak auth aws, and returns an EKS token to kubectl. It does not use the AWS CLI profile.
Authorize the IAM role in EKS
An IAM role does not have Kubernetes permissions by default. Grant the role access to the cluster with an EKS access entry, which requires the cluster's authentication mode to be API or API_AND_CONFIG_MAP. Associate an EKS access policy, or Kubernetes groups with RBAC permissions, that grants only what the user needs. If the cluster uses ConfigMap authentication, you can map the role in the aws-auth ConfigMap instead.
Use the IAM role ARN, arn:aws:iam::<account_id>:role/<role_name>, not an STS assumed-role ARN.
Configure kubectl for EKS
-
Complete the authentik configuration and AWS configuration for your federation method.
-
Add a user to your kubeconfig, usually
~/.kube/config. This example uses SAML federation:users:- name: authentik-eksuser:exec:apiVersion: client.authentication.k8s.io/v1command: akargs:- auth- aws-eks- --audience=<application_slug>- --principal-arn=arn:aws:iam::<account_id>:saml-provider/<saml_provider_name>- --role-arn=arn:aws:iam::<account_id>:role/<role_name>- --region=<region>- --cluster=<cluster_name>interactiveMode: IfAvailableSet
--clusterto the EKS cluster name and--regionto the cluster's AWS region. The other arguments are the same as in the AWS CLI configuration. For OIDC federation, replace--audienceand--principal-arnwith--client-id=authentik-aws-cli.The
client.authentication.k8s.io/v1exec credential plugin API requiresinteractiveMode. -
Add a context that pairs the
authentik-eksuser with the EKS cluster, and switch to it. If your kubeconfig has no entry for the cluster yet, add one with the cluster's API server endpoint and certificate authority data from the EKS console oraws eks describe-cluster. -
To verify, run a command that the role's cluster permissions allow, for example:
kubectl get namespaces