A
Arun's Blog
All Posts

Putting a Web App Behind AWS Identity Center Without Cognito

|7 min read|
IAM Identity CenterAWSSecurity
TL;DR

If your web app's auth model is "authenticated employees who belong to a specific group", you can skip Cognito entirely. AWS Identity Center supports Custom OIDC Applications directly. Wire your app's OIDC library at IC's endpoints, assign an IC group, and users see the app in the AWS Access Portal alongside their AWS accounts. Cognito only earns its keep when you need to federate multiple IdPs, hand out temp AWS credentials via an Identity Pool, or build custom auth UI. An internal dashboard I built a while ago uses Cognito+SAML for historical reasons. If I built it fresh today I'd skip the Cognito layer.

Where I Went Wrong the First Time

I built an internal engineering dashboard for a client a while back, hosted on S3+CloudFront, and needed to gate it behind IAM Identity Center so only employees on the right IC group could get in. The pattern I reached for looked like this:

  1. Cognito User Pool as the auth layer
  2. Cognito federated to IC via SAML (IC as the IdP, Cognito as the SP)
  3. Custom SAML 2.0 Application in IC pointing at Cognito's ACS URL
  4. IC group assigned to the SAML app

Six moving parts, three services in the auth chain. It works. The dashboard has been live on this setup for months. But when a colleague asked me last week how to put a fresh app behind IC using the same pattern, I re-read the AWS docs and realized I'd built one layer too many.

You Don't Need Cognito

Identity Center supports Custom OIDC Applications in addition to Custom SAML. If your app can speak OIDC (and any app using a modern auth library can), IC can be your app's IdP directly. Cognito was solving a problem I didn't have.

The simpler chain:

  1. Web app uses a standard OIDC library (oauth2-proxy, next-auth, an SDK for your framework)
  2. Custom OIDC Application created in IC console: Applications, then Add application, then Custom OIDC 2.0
  3. IC generates client_id, client_secret, and the OIDC endpoints (issuer URL, authorize URL, token URL, JWKS URL). Plug those into the app's OIDC config.
  4. Assign IC groups to the OIDC app. The app shows up in those users' AWS Access Portal.

Three services collapse into two (IC + your app). No Cognito User Pool to size. No SAML XML metadata to wrangle. No two-hop auth translation.

User Flow

What a user sees when they hit the app URL:

  1. App's OIDC middleware detects no valid session, redirects browser to IC's /authorize endpoint
  2. IC checks if the user has an active IC session. If yes, straight through. If not, IC prompts for the standard IC sign-in (SSO to their IdP, MFA, whatever their IC setup dictates)
  3. IC redirects back to the app's callback URL with an authorization code
  4. App exchanges the code at IC's /token endpoint for an ID token + access token
  5. App validates the ID token's signature against IC's JWKS, checks claims, sets a session cookie, renders

Same shape as any OIDC flow you've done with Okta, Auth0, or Google. IC is just another OIDC provider. The trick is IC is also the identity system your AWS accounts already trust, so you don't have a parallel user directory to maintain.

Group-Based Access

The killer feature is that IC group membership becomes the access gate for the app. Some team member joins the platform team? You add them to their IC group for AWS console access anyway. That same group membership now grants them the app. Someone leaves? Remove them from the group and both AWS accounts and the app drop off in one action.

You don't build a user management layer in the app. You don't sync team rosters. IC is the source of truth, and the app just trusts what IC hands it.

Groups in the Token

If the app needs to know which groups the user is in (for in-app RBAC), configure IC's OIDC app scope to include the groups claim. The app reads it from the ID token and gates features accordingly. No app-side group lookup needed.

Standard OIDC Libraries Work

You don't need an AWS SDK for this. Any OIDC library speaks the standard flow, so pick whatever fits your stack:

Stack Library
Anything behind ALB or nginx oauth2-proxy as a sidecar (handles auth at the proxy layer, app just reads headers)
Next.js / React server components next-auth with a generic OIDC provider config
Python / Flask authlib
Node / Express openid-client
Go coreos/go-oidc

The only IC-specific input is the OIDC discovery URL. Everything else is standard OIDC config the library already knows how to consume.

When Cognito Still Earns Its Keep

Cognito isn't obsolete. It solves problems IC doesn't, and if you have any of these needs, the added complexity is worth it:

  • Federate multiple IdPs. Need to accept both IC-authenticated employees AND external users via Google or email/password? Cognito can federate all of them into a single user pool. IC OIDC alone only accepts IC users.
  • Cognito Identity Pool for temp AWS credentials. If the app needs to hand out short-lived AWS credentials to the browser (for signed S3 uploads, direct DynamoDB reads, etc.), that's what Identity Pools do. IC OIDC alone doesn't hand out AWS credentials to your app's users.
  • Custom sign-in UI or attribute management. Cognito has a hosted UI you can style, plus user attribute schemas, MFA flows, and password reset out of the box. IC's sign-in UI is fixed.
  • Anonymous / guest access. Cognito Identity Pools support unauthenticated identities. IC doesn't.

For "employees on this IC group can use this internal tool", none of those apply. Skip Cognito.

Would I Rebuild the Dashboard Without Cognito?

Probably yes. The internal dashboard I mentioned uses Cognito+SAML because that's the pattern I knew when I built it. It works fine. Users click a tile in the Access Portal, get logged in, see the dashboard. The Cognito layer is invisible to them.

What Cognito is quietly costing me:

  • A User Pool + hosted UI I have to keep in Terraform even though nobody's typing usernames or passwords into it
  • SAML metadata that has to stay in sync between IC's IdP config and Cognito's SP config (breaks silently if either side rotates keys)
  • An extra auth translation hop that adds ~200-500ms to the first-load sign-in
  • An operational surface area I have to remember exists when something's broken

None of these are dealbreakers, and I'm not rushing to migrate. But for the next internal tool I put behind IC, I'll wire it directly to IC OIDC and skip the Cognito layer entirely.

Quick Sanity Check Before You Build

Before you invest in either pattern, run this checklist against your app's actual auth needs:

Question If yes, Cognito might be worth it
Do you need external users (Google, email/password, social)? Yes
Does the browser need to make signed AWS SDK calls? Yes (via Identity Pool)
Do you need to store per-user attributes outside of what IC has? Yes
Do you need a customizable sign-in UI? Yes
Do you need guest / anonymous access? Yes

If all five are no, IC OIDC alone gets you what you need. If any are yes, run through whether Cognito's Cognito+SAML federation model is the right fit or if you should be reaching for a different pattern entirely.

Want Help With This?

If you're standing up an internal app and trying to figure out the auth pattern, or you've got an existing Cognito setup that feels like more machinery than the problem calls for, reach out via the contact form. Happy to help.

Related Articles