AWS OIDC Authentication

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up aws oidc authentication by linking an external identity provider to AWS IAM. Your app or pipeline then trades a signed web token for temporary AWS role keys. Many teams start by storing long-lived AWS keys inside CI tools or local config files. Those static keys never expire on their own and often leak in logs or code repos. Even when teams switch to federated roles, they often grant broad admin rights to avoid errors. If a bad actor steals that broad role session, they can read or de

K8s OIDC Authentication + AWS IAM Policies: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up aws oidc authentication by linking an external identity provider to AWS IAM. Your app or pipeline then trades a signed web token for temporary AWS role keys. Many teams start by storing long-lived AWS keys inside CI tools or local config files. Those static keys never expire on their own and often leak in logs or code repos. Even when teams switch to federated roles, they often grant broad admin rights to avoid errors. If a bad actor steals that broad role session, they can read or delete production data.

How aws oidc authentication works in practice

The workflow starts when you add your identity provider URL to your AWS account. You also give AWS the client ID that represents your build platform or user portal. AWS fetches the public keys from that provider so it can check token signatures later. Next, you create an IAM role and attach a trust policy to it. This trust policy names the identity provider and sets strict rules on incoming token claims. For example, a rule can check that a build runs from one specific git branch.

When a job or user runs, the identity provider signs a JSON web token. The client sends this signed token to the AWS Security Token Service. AWS checks the digital signature and reads the claims inside the token. If the claims match the trust policy rules, AWS issues a short-lived session credential. This credential holds an access key, a secret key, and a session token. Your app or engineer uses these temporary keys to make AWS API calls until they expire.

Why federated roles still leave a runtime gap

Trading static keys for short-lived tokens stops leaks of permanent secrets in your code repos. You no longer need to rotate static IAM user keys every ninety days by hand. Your identity provider becomes the single place to turn off a user or build pipeline. Still, AWS IAM and OIDC only check identity at the moment the session starts.

Once AWS issues the temporary credential, IAM only controls which cloud APIs the role can call. IAM does not inspect the actual queries sent inside a database or server session. If a developer assumes a role to reach a database, they get full query access. They can run a broad select query that pulls thousands of user emails and phone numbers. They can also run a drop table command by mistake during a late night fix. Cloud logs will show that the role started a session, not the SQL commands executed.

K8s OIDC Authentication + AWS IAM Policies: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Scoping trust rules and session limits

To keep your cloud accounts safe, you must write narrow conditions in every trust policy. Never allow every repo or every user group in your provider to assume one shared role. Check the subject claim in the token to lock the role to one repo or team. Check the audience claim so tokens meant for other apps cannot open an AWS session. Set the maximum session duration on the IAM role to the shortest time your task needs. Short sessions shrink the window of risk if a token leaks on a local machine.

You also need a way to govern what happens after the cloud role check passes. Teams need controls that inspect individual database queries and shell commands while they run in flight. Adding command-level checks and field masking for card numbers or national IDs closes this runtime gap.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

What is the difference between OIDC and SAML in AWS?

OIDC uses lightweight JSON web tokens built for modern web apps and CI pipelines. SAML uses heavy XML assertions that older corporate portals often use for browser logins.

How long do temporary AWS OIDC credentials last?

AWS sets a default time limit on role sessions, and you can adjust the maximum duration. Once the timer runs out, the keys stop working and the client must request new ones.

Can I use OIDC to log in to AWS from a CI pipeline?

Yes, most modern build platforms act as an OIDC provider and issue tokens to running jobs. Your build job trades that token for temporary AWS keys without storing any static secrets.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.