Asterrr's Handbook

Application identity and authorization

Amazon Cognito user pools and identity pools, guest access and token types, API Gateway authorizers, Amazon Verified Permissions with Cedar, and choosing RBAC or ABAC for application users.

Exam tasks: 4.1 (Skills 4.1.1 identity for application users with Amazon Cognito, 4.1.3 troubleshooting Cognito), 4.2 (Skills 4.2.1 Amazon Verified Permissions, 4.2.2 ABAC and RBAC strategies)

The decision: does your application's user need to sign in (a user pool), call AWS directly with credentials (an identity pool), or be authorized against your own resources with fine-grained rules (Verified Permissions), and where is each check enforced?

The moving parts

User pools vs identity pools

User poolIdentity pool
JobAuthentication: a user directory and OIDC/OAuth 2.0 providerCredential vending: swaps a token for temporary AWS credentials
OutputJWTs: ID, access and refresh tokensAn access key, secret and session token for an IAM role
Federates withSocial IdPs, SAML, OIDCUser pools, social IdPs, SAML, OIDC, your own backend (developer authenticated)
Guest usersNoYes, unauthenticated identities with their own role
Use whenUsers sign in to your app or APIThe app calls S3, DynamoDB, IoT and so on directly
  • Token types: the ID token carries user attributes (who the user is). The access token carries scopes and groups (what the app may call), and is the one to send to APIs. The refresh token gets new ones. You can revoke refresh tokens, and access tokens issued from them stop working at Cognito endpoints.
  • Machine-to-machine: the client credentials grant with resource server scopes issues access tokens to services, no user involved.
  • Feature plans: Lite, Essentials (the default for new pools) and Plus. Threat protection (compromised credential checks, adaptive authentication that scores risky sign-ins and can require MFA or block) is in Plus. Passkeys, email MFA and access token customization need Essentials or Plus.

Legacy: use User pool threat protection (Plus plan) instead

"Advanced security features" in Cognito were folded into the Essentials and Plus feature plans. Compromised credential detection and adaptive authentication now come with the Plus plan.

Identity pools in detail

  • Each identity is authenticated or unauthenticated (guest), and each type maps to an IAM role. Keep the guest role tiny, for example PutObject to one upload prefix.
  • Role selection: a default role, rules that map a token claim to a role, or the cognito:preferred_role claim from user pool groups.
  • Attributes for access control: map token claims to principal tags, then write ABAC policies such as "only objects under users/${aws:PrincipalTag/sub}/".
  • Role trust policies must trust cognito-identity.amazonaws.com and pin cognito-identity.amazonaws.com:aud to your identity pool ID and amr to authenticated or unauthenticated.
  • The enhanced flow is the default. The basic (classic) flow lets the client call AssumeRoleWithWebIdentity itself and bypasses role rules, so leave it off unless you need it.

A guest role with broad access

Unauthenticated identities are available to anyone who has the identity pool ID, which ships in your app. A guest role with s3:* on a bucket is a public bucket. Scope it to the minimum, or turn off guest access.

API Gateway authorizers

AuthorizerChecksGood for
IAM (SigV4)The caller signed with AWS credentials allowed to execute-api:InvokeService-to-service, identity pool users
Cognito user pool (REST)A valid user pool token, optional scopesStraightforward sign-in-then-call
JWT authorizer (HTTP APIs)Any OIDC issuer's JWT, audience and scopesCognito or third-party IdPs on HTTP APIs
Lambda authorizerWhatever your code decides, returning an IAM policyCustom tokens, calls to Verified Permissions, legacy auth
Resource policy (REST)Source account, IP, VPC endpointPrivate APIs, IP allow-lists, cross-account
  • Mutual TLS on a custom domain authenticates clients by certificate, in addition to any authorizer.
  • Cache Lambda authorizer results carefully: a cached allow for one path can be reused for others with the same token if the returned policy is too broad.

Amazon Verified Permissions

  • A managed policy decision point for your own applications. Policies are written in Cedar and stored in a policy store with a schema of principals, actions and resources.
  • Your app, or an API Gateway Lambda authorizer that Verified Permissions can generate, calls IsAuthorized, IsAuthorizedWithToken (passing a Cognito or OIDC token from an identity source) or BatchIsAuthorized.
  • Default deny, and a forbid always beats a permit. The same shape as IAM, applied to your app's objects.
  • Policy templates let you create per-resource grants ("share this document with Priya") without writing a new policy by hand.
  • Every decision can be logged, which answers "who could see patient record 88?" for auditors.
permit (
  principal in Clinic::Role::"nurse",
  action in [Clinic::Action::"viewChart"],
  resource
)
when { resource.ward == principal.ward };

RBAC or ABAC

RBACABAC
Grants based onThe role or group the user is inAttributes (tags, claims) of the user and the resource
New project or teamNew role, new policyTag the resources, nothing else
Policy countGrows with teamsStays small
Audit question"Who is in the admins role?" is easy"Who can reach this resource?" needs attribute analysis
In AWSPermission sets, IAM roles, Cognito groupsaws:PrincipalTag vs aws:ResourceTag, Cedar when clauses on attributes
  • Most real designs mix both: a role decides the kind of access, attributes decide which resources.
  • ABAC depends on tag integrity. Control who can set tags (aws:RequestTag, aws:TagKeys, tag policies) or users can grant themselves access.

Exam signal

"Permissions must scale as new teams and projects are added without policy changes" means ABAC. "Fine-grained, per-record permissions inside a custom application, managed centrally and outside the code" means Verified Permissions.

Scenarios

Scenario
A mobile photo app lets users browse public galleries without signing in, and upload photos to their own folder after signing in. Uploads go straight from the app to S3. Which design follows least privilege?
Scenario
A SaaS company's document service needs rules such as 'editors can change documents in their own tenant, and nobody can change a document on legal hold'. Product managers want to change rules without redeploying code, and auditors want a log of every decision. What should the team use?
Scenario
Users of a web app report that sign-in works but calls to the HTTP API return 401 Unauthorized. The API uses a JWT authorizer configured with the user pool's issuer and the app client ID as audience, and each route requires the orders/read scope. The front end sends the ID token in the Authorization header. Logs show the token is valid. What is the most likely issue?

Further reading

On this page