SEC02-BP04 Rely on a centralized identity provider for users and machines
When each application manages its own identities, users juggle multiple logins and security teams lose a single view of who has access. A centralized identity provider makes one system the source of truth for authentication, authorization, and lifecycle management across your workloads. This applies to machine identities as well as people, so service-to-service calls authenticate through the same governed system.
Desired outcome:
-
Your workloads authenticate users against one identity provider that serves as the source of truth.
-
Your provider supports industry-standard protocols and consistent authorization controls across applications.
-
Your users sign in once and reach the applications they are entitled to, and your security team sees authentication centrally.
-
Your machine identities authenticate and authorize through the same centralized system as your users.
-
Your user lifecycle events, from creation to deactivation, propagate from the provider without manual per-application work.
Common anti-patterns:
-
Teams build a separate authentication system for each application.
-
Teams store credentials directly in application databases.
-
Teams manage users through manual, per-application processes.
-
Teams use different identifiers for the same user across applications.
-
Teams skip token validation and accept tokens without checking signature, expiry, or audience.
-
Teams ignore the full user lifecycle, so accounts remain active after a user's access ends.
-
Teams manage machine identities ad hoc and hard-code service credentials in code or configuration.
Benefits of establishing this best practice:
-
Uniform controls across workloads close the gaps that per-application identity systems create.
-
Automated lifecycle management lowers administrative effort and human error.
-
Single sign-on reduces credential fatigue and improves the user experience.
-
Centralized authentication logging improves threat detection and incident response.
-
One identifier per user keeps records consistent even when personal details change.
Level of risk exposed if this best practice is not established: Medium
Implementation guidance
Document the identity types in your workload, their permission needs, and where each identity originates. That inventory tells you whether you need a customer directory, workforce federation, machine-to-machine authentication, or all three.
Customer identity
Amazon Cognito manages customer identities directly and also federates to external providers. For customer-facing applications, social sign-in through providers such as Amazon, Google, Facebook, or Apple lowers the barrier to registration. For internal applications, SAML or OpenID Connect federation to a corporate directory keeps workforce identity under existing governance.
Prefer managed authentication surfaces such as
user pool managed login over custom flows. Or build on a
library such as
AWS Amplify Auth
Machine identity
Within AWS, services assume an
IAM role to obtain temporary credentials, and systems outside
AWS obtain temporary credentials through
IAM Roles Anywhere. For custom service-to-service
authentication, use
Amazon Cognito machine-to-machine authentication
Workforce identity
When your employees need access to AWS accounts and AWS-managed analytics applications, centralize that access through IAM Identity Center. Connect your existing identity source (such as your corporate IdP) once. Identity Center then becomes the single reference to your workforce that AWS services share. Workforce users receive single sign-on to the accounts and applications they are entitled to. Joiner, mover, and leaver changes continue to flow from your IdP.
Identity Center also supports trusted identity propagation, which attaches the signed-in user's identity to each request as AWS services hand it off. A service then authorizes access based on the user's group associations and records the user's identity in AWS CloudTrail. For analytics access to data lakes, services such as Amazon Redshift, AWS Quick, Amazon Athena, Amazon EMR, and AWS Glue can propagate the end-user identity to AWS Lake Formation and Amazon S3 Access Grants. Lake Formation and S3 Access Grants then grant fine-grained, user-level or group-level access to the data and vend temporary credentials, so permissions no longer live in a broad service role.
Observability
Route authentication events to Amazon CloudWatch to detect suspicious patterns such as repeated failed logins, sign-ins from unusual locations, or unexpected privilege escalation.
Implementation steps
-
Stand up your central user directory for customer identity: Create an Amazon Cognito user pool as the source of truth for users. Configure password policies, MFA, and account recovery, and enable threat protection features that detect exposed credentials and adapt authentication to risk.
-
Federate external identity providers: Connect social identity providers for consumer applications, and configure SAML or OIDC federation for enterprise applications. Apply consistent attribute mapping so profiles stay consistent across providers.
-
Implement secure authentication flows: Use the authorization code flow with Proof Key for Code Exchange (PKCE) for web and single-page applications that cannot store a client secret. Integrate a library such as AWS Amplify Authentication
for token handling, and configure token expiration and refresh to match your security requirements. -
Design authorization: Organize users with groups and custom attributes that reflect roles. For centralized fine-grained authorization, evaluate Amazon Verified Permissions, which uses the Cedar policy language and integrates with Cognito identity data.
-
Automate the user lifecycle: Use Lambda triggers to customize authentication and user management, establish regular access reviews and account deactivation, and turn on account-takeover protection and risk-based adaptive authentication.
-
Authenticate machine identities centrally: For AWS service-to-service calls, use IAM roles with least-privilege permissions. For custom workloads, use Amazon Cognito machine-to-machine authentication
with the OAuth 2.0 client credentials flow, and define rotation and monitoring for service identities. -
Centralize workforce access with IAM Identity Center: For employee access to AWS accounts and AWS-managed applications, enable IAM Identity Center and connect your existing identity source so workforce users sign in once against your corporate IdP. Where workforce users reach data through analytics services such as Amazon Redshift, AWS Quick, Amazon Athena, or Amazon EMR, enable trusted identity propagation and manage fine-grained data permissions in AWS Lake Formation and Amazon S3 Access Grants so access is authorized and audited against the end user's identity rather than a shared service role.
-
Centralize identity monitoring: Send Cognito authentication events to Amazon CloudWatch, set alarms for suspicious activity, and build dashboards to track identity system health and usage.
Resources
Related best practices:
Related documents:
Related examples:
-
How to monitor, optimize, and secure Amazon Cognito machine-to-machine authorization
-
Configuring machine-to-machine authentication with Amazon Cognito and Amazon API Gateway – Part 1
-
Configuring machine-to-machine authentication with Amazon Cognito and Amazon API Gateway – Part 2
-
Simplify fine-grained authorization with Amazon Verified Permissions and Amazon Cognito
-
Access AWS services programmatically using trusted identity propagation
Related workshops: