SlideShare une entreprise Scribd logo
1  sur  62
© 2017, Amazon Web Services, Inc. or its Affiliates, All rights reserved.
Managing Identity and Securing Your Mobile and
Web Applications with Amazon Cognito
Stephen Liedig, Solutions Architect
A/NZ Public Sector, AWS
August 2017
Identity is mission critical for applications
Security
Revenue
Generation
Application
Backbone
 Know your users
 Monitor engagement
with your application
 Store and manage
user data
 Personalize your
users’ experiences
 Protect sensitive data
 Secure business-
critical processes
User Identity
Identity is mission critical for applications
Authentication User ManagementAuthorization
 Manage user lifecycles
 Store and manage
user profile data
 Monitor engagement
 Protect data and
operations
 Provide fine-grained
access control
 Sign in users
 Enable federation with
enterprise identities
 Enable federation with
social identities
User Identity
Developing Auth Infrastructure is Difficult
Source: images.huffingtonpost.com/2015-06-18-1434640796-8854716-frustration.jpg
Developing Auth Infrastructure is Difficult
• Need to develop a reliable user directory to manage identities
• Handling user data and passwords and protecting privacy
• Prioritizing scalability of your infrastructure upfront
• Implementing token-based authentication
• Support for multiple social identity providers
• Federation with corporate directories for B2E applications
1
2
3
5
6
4
Amazon Cognito Identity
Your User Pools
You can easily and securely add sign-up
and sign-in functionality to your mobile and
web apps with a fully-managed service that
scales to support 100s of millions of users.
Federated Identities
Your users can sign in with third-party
identity providers, such as Facebook and
SAML providers, and you can control
access to AWS resources from your app.
Sign in
Username
Password
Submit
Facebook
Corporate
OIDC
Sign in with
SAML
Comprehensive Support for Identity Use Cases
Amazon Cognito: Identity Management Scenarios
Business to Consumer
IoT Scenarios
Business to Employee
SAML
Federation
Enterprise
Directory
Partner A
Partner B
Business to Business
AWS IoT
API Gateway with Lambda
Deny
Allow
Custom
Authorizer
Access control for AWS
Resources
AWS IAM
Lets dive a little
deeper…
Source: https://freerangestock.com/photos/44722/photo-details.html
I want to authenticate
• consumers
• employees
• systems
…on
• Amazon EC2 / Amazon ECS
• AWS Lambda
• Browser
• Mobile
• other
…against
• IAM
• A managed IdP
• SAML
• Google
• Twitter
• Facebook
• OpenID
• Custom
…to access
• AWS APIs and SDKs
• Amazon API Gateway
• custom applications
I want to authenticate
people
…on
browser or mobile
Let’s imagine a user table
Username Email Password
beverly123 beverly123@example.com Password$123
pilotjane pilotjane@example.com a##eroplan3
sudhir1977 sudhir197@example.com mmd414997a
I want to authenticate
people
…on
browser or mobile
Let’s imagine a user table
Username Email Password
beverly123 beverly123@example.com Password$123
pilotjane pilotjane@example.com a##eroplan3
sudhir1977 sudhir197@example.com mmd414997a
• Never store passwords in plaintext!
• Vulnerable to rogue employees
• A hacked DB results in
all passwords being compromised
I want to authenticate
people
…on
browser or mobile
Let’s try again…
Username Email Hashed Password
beverly123 beverly123@example.com 21a730e7d6cc9d715efcc0514ed69a1f
pilotjane pilotjane@example.com fea74fde863cd38f88b3393f590ae883
sudhir1977 sudhir197@example.com 6ce6be14f0c775cc9b3dbe4e18d9fc7d
I want to authenticate
people
…on
browser or mobile
Doh!!!
Username Email Hashed Password
beverly123 beverly123@example.com 21a730e7d6cc9d715efcc0514ed69a1f
pilotjane pilotjane@example.com fea74fde863cd38f88b3393f590ae883
sudhir1977 sudhir197@example.com 6ce6be14f0c775cc9b3dbe4e18d9fc7d
• MD5/SHA1 collisions
• Rainbow Tables
• Dictionary attacks, brute-force (GPUs can compute
billions of hashes/sec)
I want to authenticate
people
…on
browser or mobile
Secure Remote Password Protocol
Username Email SRP Verifier function
beverly123 beverly123@example.com <password-specific verifier>
pilotjane pilotjane@example.com <password-specific verifier>
sudhir1977 sudhir197@example.com <password-specific verifier>
Secure Remote Password (SRP) Protocol
• Verifier-based protocol
• Passwords never travel over the wire
• Resistant to several attack vectors
• Perfect Forward Secrecy
I want to authenticate
people
…on
browser or mobile
But wait…
Best practices
☐ Secure password handling
I want to authenticate
people
…on
browser or mobile
But wait…
Best practices
☐ Secure password handling
☐ Encrypt all data server-side
☐ Enforce password policies (min length, valid characters)
☐ Token-based Authentication
☐ MFA - via SMS for sign-in and forgot password flows
☐ Support CAPTCHAs and other custom authentication flows
☐ Scalable to 100s of millions of users
I want to authenticate
people
…on
browser or mobile
But wait…
User flows
☐ Registration
☐ Verify email/phone
☐ Secure sign-in
Best practices
☐ Secure password handling
☐ Encrypt all data server-side
☐ Enforce password policies (min length, valid characters)
☐ Token-based Authentication
☐ MFA - via SMS for sign-in and forgot password flows
☐ Support CAPTCHAs and other custom authentication flows
☐ Scalable to 100s of millions of users
☐ Forgot password
☐ Change password
☐ Sign-out
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
Amazon Cognito User Pools
Best practices
☐ Secure password handling
☐ Encrypt all data server-side
☐ Enforce password policies (min length, valid characters)
☐ Token-based Authentication
☐ MFA - via SMS for sign-in and forgot password flows
☐ Support CAPTCHAs and other custom authentication flows
☐ Scalable to 100s of millions of users
User flows
☐ Registration
☐ Verify email/phone
☐ Secure sign-in
☐ Forgot password
☐ Change password
☐ Sign-out
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
User APIs
Email or Phone Number
Verification
Require users to verify their email address or phone number prior to
activating their account with a one-time password challenge
Forgot Password
Provide users the ability to change their password when they forget
it with a one-time password challenge
User Sign-Up and Sign-In
Allow users to sign up and sign in using an email, phone number, or
username (and password) for your application.
User Profile Data
Enable users to view and update their profile data – including
custom attributes
SMS Multifactor
Authentication
Require users to complete a second factor of authentication by
inputting a security code received via SMS as part of the sign-in flow
Customize these User Flows Using Lambda
Token Based
Authentication
Use JSON Web Tokens (JWTs) based on OpenID Connect (OIDC)
and OAuth 2.0 standards for user authentication in your backend
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
Administrator APIs
Define Custom Attributes
Set per-App Permissions
Set up Password Policies
Create and manage
User Pools
Define custom attributes for your user profiles
Set read and write permissions for each user attribute on a
per-app basis
Enforce password policies like minimum length and
requirement of certain types of characters
Create, configure, and delete multiple user pools across AWS
regions
Require Submission of
Attribute Data
Select which attributes must be provided by the user prior to
completion of the sign-up process
Search Users Search users based on a full match or a prefix match of their
attributes through the console or Admin API
Manage Users Conduct admin actions, such as reset user password, confirm
user, enable MFA, delete user, and global sign-out
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
Customize with Lambda triggers
Category Lambda Hook Example Scenarios
Custom
Authentication
Flow
Define Auth Challenge Determines the next challenge in a custom auth flow
Create Auth Challenge Creates a challenge in a custom auth flow
Verify Auth Challenge
Response
Determines if a response is correct in a custom auth flow
Authentication
Events
Pre Authentication Custom validation to accept or deny the sign-in request
Post Authentication Event logging for custom analytics
Sign-Up
Pre Sign-up Custom validation to accept or deny the sign-up request
Post Confirmation
Custom welcome messages or event logging for custom
analytics
Messages Custom Message Advanced customization and localization of messages
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
App Integration with User Pools
Use the Amazon Cognito SDK
(JavaScript / Android / iOS), use the
APIs directly.
User Pools now provides a hosted UI
for sign up, sign in, forgot password,
etc.
Developers can customize the UI to
match their style and branding
through custom logo and CSS
NEW!
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
UI Customizations
Customize UI for each application
Customize logo
CSS customizations
How do I use Amazon Cognito
User Pools to authenticate
against Amazon API Gateway?
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito User Pool
Authorizer
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Supports authentication, but not authorization.
API Gateway has an easy integration with Amazon Cognito User
Pools.
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
For fine grained authorization to API Gateway, you’ll need to use
an API Gateway Custom Authorizer.
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
… let’s dive a bit deeper…
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Step 1: User signs up for an
account with our Amazon
Cognito User Pool, providing
their email, telephone number &
password (+ any custom
attributes).
Amazon Cognito can
automatically verify the user’s
email address and/or phone
number if required.
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Step 2: At some point in the
future, the user wants to sign in.
We can now authenticate the
user.
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Optional: If MFA is enabled
(either for this user, or all users),
Amazon Cognito will SMS a one
time authentication code to the
user.
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Step 3: After a successful
authentication, Amazon Cognito
responds with a signed JSON
Web Token (JWT) containing the
user’s details.
JWT Token
Wait… what’s a JWT?
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
https://jwt.io
Cryptographically
verifiableclaims
Restricting JWT claims
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
You can select which Amazon Cognito User Pool attributes are included in
the generated JWT token by using scopes.
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Step 3: After a successful
authentication, Amazon Cognito
responds with a signed JSON
Web Token (JWT) containing the
user’s details.
JWT Token
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Step 4: You are now ready to call
your backend API’s from your
mobile application.
The JWT is passed in via the
Authorization HTTP header.
GET /pets HTTP/1.1
Host: ...
Authorization:eyJraWQi…
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Step 5: API Gateway calls your
custom authorizer function which
validates the JWT token and
creates an IAM policy that
defines which API resources the
user can access (based on their
user attributes in the JWT
claims).
GET /pets HTTP/1.1
Host: ...
Authorization:eyJraWQi…
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Step 6: Additionally, the custom
authorizer function will need to
check that the JWT hasn’t been
tampered with.
To do this, it needs the signing
public key (JWK) from Amazon
Cognito.
GET /pets HTTP/1.1
Host: ...
Authorization:eyJraWQi…
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
var samplePolicy = new AuthPolicy(”userIdentifier", "XXXXXXXXXXXX", apiOptions);
samplePolicy.allowMethod(AuthPolicy.HttpVerb.POST, "/windfarms/");
samplePolicy.allowMethod(AuthPolicy.HttpVerb.GET, "/windfarms/123/*");
samplePolicy.allowMethod(AuthPolicy.HttpVerb.GET, "/windfarms/234/*");
samplePolicy.allowMethod(AuthPolicy.HttpVerb.ALL, "/users/" + user.id);
callback(null, samplePolicy.getPolicy());
A custom authorizer function should return a policy that defines which API
resources the user should get access to.
This is then cached and used for any requests with the same authentication
token (default: 300 seconds).
Make sure your policy includes all actions the user can perform, not just a
single request.
Custom Authorizers
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon Cognito
User Pools
Amazon API Gateway
Custom Authorizer
Lambda Function
/pets
/n…
Amazon
DynamoDB
Throttling
Cache
Logging
Monitoring
Auth
Step 7: If authentication was
successful, the API call will be
passed through to the backend
Lambda functions where your
logic sits.
Authentication is cached for each
token (up to 1 hour).
GET /pets HTTP/1.1
Host: ...
Authorization:eyJraWQi…
API Gateway summary
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
Amazon API Gateway
Amazon
Cognito
User Pool
Authenticate
2
CUP
Token1
Backend
resources
Access backend
resources
CUP
Token
API GW
4
Amazon Cognito User Pools can
be used as standalone IdPs
Amazon Cognito User Pools and
API Gateway integrate really
nicely.
Use the built in User Pool
Authorizer if you don’t need
authorization.
Use Custom Authorizers instead
if you do.
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
AWS APIs and SDKs
How do I use Amazon Cognito
User Pools to authenticate /
authorize access to AWS APIs and
SDKs?
AWS APIs and SDKs
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
AWS APIs and SDKs
Amazon Cognito User Pools cannot generate AWS credentials. You need to use
Amazon Cognito Federated Identity in-front of Amazon Cognito User Pools.
AWS APIs and SDKs
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
AWS APIs and SDKs
You can then configure the AWS SDK to fetch API credentials from Amazon
Cognito like so:
var Amazon CognitoUser = userPool.getCurrentUser();
if (Amazon CognitoUser != null) {
Amazon CognitoUser.getSession(function(err, result) {
if (result) {
console.log('You are now logged in.');
// Add the User's Id Token to the Amazon Cognito credentials login map.
AWS.config.credentials = new AWS.Amazon CognitoIdentityCredentials({
IdentityPoolId: 'YOUR_IDENTITY_POOL_ID',
Logins: {
'Amazon Cognito-idp.{region}.amazonaws.com/{user-pool-id}':
result.getIdToken().getJwtToken()
}
});
}
});
}
RBAC (Role based access control)
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
AWS APIs and SDKs
Amazon Cognito User Pool groups
can be configured with an IAM role
You can then configure Amazon
Cognito Federated Identity to
use the role within the JWT
token when issuing AWS
credentials
RBAC (Role based access control)
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
…to access
AWS APIs and SDKs
Alternatively, you can also map roles based on other attributes in the
JWT token
I want to authenticate
people
…on
browser or mobile
…against
Amazon Cognito User
Pools
What about federation to Active
Directory, SAML and/or social
media accounts?
I want to authenticate
people
…on
browser or mobile
…against
SAML (Active Directory)
and/or social media
accounts
…to access
AWS APIs and SDKs,
Amazon API Gateway or
custom applications
SAML / Active Directory Federation
NEW!
I want to authenticate
people
…on
browser or mobile
…against
SAML (Active Directory)
and/or social media
accounts
…to access
AWS APIs and SDKs,
Amazon API Gateway or
custom applications
Social Media Federation
Mapping Federated Attributes
I want to authenticate
people
…on
browser or mobile
…against
SAML (Active Directory)
and/or social media
accounts
…to access
AWS APIs and SDKs,
Amazon API Gateway or
custom applications
Business to Consumer Use Case
I want to authenticate
people
…on
browser or mobile
…against
SAML (Active Directory)
…to access
AWS APIs and SDKs,
Amazon API Gateway or
custom applications Get AWS credentials
Cognito
Identity Pool
DynamoDB
S3
API GW
Access backend
resources
Cognito
User Pool
Authenticate
3
CUP
Token1
IdP
Token
2
Redirect /
Post back
CUP
Token
4
5
User Pools authenticate users
and returns OpenID Connect and
OAuth2.0 standard tokens
Identity Pools provide AWS
credentials to access backend
resources
Business to Business/Employee
with SAML
I want to authenticate
people
…on
browser or mobile
…against
SAML (Active Directory)
…to access
AWS APIs and SDKs,
Amazon API Gateway or
custom applications
User Pools authenticate users
and returns OpenID Connect and
OAuth2.0 standard tokens
Identity Pools provide AWS
credentials to access backend
resources
Get AWS credentials
Cognito
Identity Pool
DynamoDB
S3
API GW
Access backend
resources
SAML IdP
(e.g., ADFS)
Cognito
User Pool
Authenticate
3
CUP
Token1
SAML
2
Redirect /
Post back
CUP
Token
4
5
Business to Business/Employee
with SAML v2
I want to authenticate
people
…on
browser or mobile
…against
SAML (Active Directory)
…to access
AWS APIs and SDKs,
Amazon API Gateway or
custom applications
Amazon Cognito User Pools
authenticate users and returns
OpenID Connect and OAuth2.0
standard tokens
Amazon Cognito User Pool
tokens can be used for
authorizing access to your APIs /
backend
SAML IdP
(e.g., ADFS)
Cognito
User Pool
Authenticate
3
CUP
Token1
SAML
2
Redirect /
Post back
Backend
resources
Access backend
resources
CUP
Token
API GW
4
I want to authenticate
systems
Ok, we’ve covered
authenticating people, but what
about authenticating systems?
For example, Application A communicating with Application B.
want to authenticate
systems
…on
Amazon EC2
…against
IAM
…to access
AWS APIs and SDKs
Amazon EC2 Instance Roles
Instance roles allow you to grant access from systems on EC2 (AWS
CLI or SDKs) to access AWS Services without needing to bake in
credentials. The CLI and SDKs are preconfigured to detect and use
instance roles if one is attached.
want to authenticate
systems
…on
Amazon EC2
…against
IAM
…to access
Amazon API Gateway
EC2 Instance Roles
EC2 Instance Roles are also a great option for granting access to APIs
hosted with Amazon API Gateway.
API Gateway should be configured for IAM authentication:
want to authenticate
systems
…on
Amazon EC2
…against
IAM
…to access
Amazon API Gateway
EC2 Instance Roles
…and the IAM role should have a policy attached that allows access
to the API required:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "execute-api:Invoke",
"Effect": ”Allow",
"Resource": "arn:aws:execute-api:*:*:ff5h9tpwfh/*"
},
{
"Action": "execute-api:Invoke",
"Effect": "Deny",
"Resource": "arn:aws:execute-api:*:*:ff5h9tpwfh/*/POST/windfarms"
}
]
}
want to authenticate
systems
…on
Amazon EC2 Container
Service (ECS)
…against
IAM
…to access
AWS APIs and SDKs or
Amazon API Gateway
EC2 Container Service (ECS)
ECS supports IAM Roles too. This makes it easy to secure an AWS Service
or API hosted with Amazon API Gateway to a specific container (or group of
containers).
want to authenticate
systems
…on
AWS Lambda
…against
IAM
…to access
AWS APIs and SDKs or
Amazon API Gateway
AWS Lambda
Use AWS Lambda’s execution role to secure an AWS service or API hosted
with Amazon API Gateway to a specific AWS Lambda function.
Summary
It can support a wide range of scenarios including customers, employees,
systems
1
2
3
5
6
4
It includes a fully managed identity provider (Amazon Cognito User Pools), with
a great free tier
Amazon Cognito offers huge flexibility for AuthN / AuthZ
Hosted authentication pages makes integrating really easy
Don’t be scared of Amazon Cognito  Reach out to your local SA if you need
help
New SAML and social federation in Amazon Cognito User Pools!
No more of this…
Source: images.huffingtonpost.com/2015-06-18-1434640796-8854716-frustration.jpg
Source: https://freerangestock.com/photos/39981/victorious--man-standing-on-the-top-of-a-mountain-raising-.html
…and heaps more of this!
© 2017, Amazon Web Services, Inc. or its Affiliates, All rights reserved.
Thank you!

Contenu connexe

Tendances

amazon-cognito-auth-in-minutes
amazon-cognito-auth-in-minutesamazon-cognito-auth-in-minutes
amazon-cognito-auth-in-minutes
Vladimir Budilov
 

Tendances (20)

Deep Dive on Amazon Cognito - March 2017 AWS Online Tech Talks
Deep Dive on Amazon Cognito - March 2017 AWS Online Tech TalksDeep Dive on Amazon Cognito - March 2017 AWS Online Tech Talks
Deep Dive on Amazon Cognito - March 2017 AWS Online Tech Talks
 
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...
 
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...
 
Amazon Cognito
Amazon CognitoAmazon Cognito
Amazon Cognito
 
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
 
Scaling your Mobile App Development in the Cloud - DevNexus
Scaling your Mobile App Development in the Cloud - DevNexusScaling your Mobile App Development in the Cloud - DevNexus
Scaling your Mobile App Development in the Cloud - DevNexus
 
Raleigh DevDay 2017: Managing User Onboarding, Sign-up, Sign-in, Identity and...
Raleigh DevDay 2017: Managing User Onboarding, Sign-up, Sign-in, Identity and...Raleigh DevDay 2017: Managing User Onboarding, Sign-up, Sign-in, Identity and...
Raleigh DevDay 2017: Managing User Onboarding, Sign-up, Sign-in, Identity and...
 
Build Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile ServicesBuild Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile Services
 
AWS re:Invent 2016: Serverless Authentication and Authorization: Identity Man...
AWS re:Invent 2016: Serverless Authentication and Authorization: Identity Man...AWS re:Invent 2016: Serverless Authentication and Authorization: Identity Man...
AWS re:Invent 2016: Serverless Authentication and Authorization: Identity Man...
 
Raleigh DevDay 2017: Driving User Engagement and App Success with AWS Pinpoin...
Raleigh DevDay 2017: Driving User Engagement and App Success with AWS Pinpoin...Raleigh DevDay 2017: Driving User Engagement and App Success with AWS Pinpoin...
Raleigh DevDay 2017: Driving User Engagement and App Success with AWS Pinpoin...
 
Authentication & Authorization for Connected Mobile & Web Applications using ...
Authentication & Authorization for Connected Mobile & Web Applications using ...Authentication & Authorization for Connected Mobile & Web Applications using ...
Authentication & Authorization for Connected Mobile & Web Applications using ...
 
amazon-cognito-auth-in-minutes
amazon-cognito-auth-in-minutesamazon-cognito-auth-in-minutes
amazon-cognito-auth-in-minutes
 
(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...
(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...
(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...
 
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of ChoicesIntegrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
 
Build Your Mobile App Faster with AWS Mobile Services (Cognito, Lambda, SNS, ...
Build Your Mobile App Faster with AWS Mobile Services (Cognito, Lambda, SNS, ...Build Your Mobile App Faster with AWS Mobile Services (Cognito, Lambda, SNS, ...
Build Your Mobile App Faster with AWS Mobile Services (Cognito, Lambda, SNS, ...
 
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014
 
Getting Started with Cognito User Pools - September Webinar Series
Getting Started with Cognito User Pools - September Webinar SeriesGetting Started with Cognito User Pools - September Webinar Series
Getting Started with Cognito User Pools - September Webinar Series
 
Cloud-powered Cross-platform Mobile Apps on AWS
Cloud-powered Cross-platform Mobile Apps on AWSCloud-powered Cross-platform Mobile Apps on AWS
Cloud-powered Cross-platform Mobile Apps on AWS
 
ACDKOCHI19 - Enterprise grade security for web and mobile applications on AWS
ACDKOCHI19 - Enterprise grade security for web and mobile applications on AWSACDKOCHI19 - Enterprise grade security for web and mobile applications on AWS
ACDKOCHI19 - Enterprise grade security for web and mobile applications on AWS
 
Delivering Mobile Apps Using AWS Mobile Services
Delivering Mobile Apps Using AWS Mobile ServicesDelivering Mobile Apps Using AWS Mobile Services
Delivering Mobile Apps Using AWS Mobile Services
 

Similaire à Managing Identity and Securing Your Mobile and Web Applications with Amazon Cognito - AWS PS Summit Canberra 2017

Similaire à Managing Identity and Securing Your Mobile and Web Applications with Amazon Cognito - AWS PS Summit Canberra 2017 (20)

AWS re:Invent 2016: Add User Sign-In, User Management, and Security to your M...
AWS re:Invent 2016: Add User Sign-In, User Management, and Security to your M...AWS re:Invent 2016: Add User Sign-In, User Management, and Security to your M...
AWS re:Invent 2016: Add User Sign-In, User Management, and Security to your M...
 
User Authentication and Identity with Amazon Cognito
User Authentication and Identity with Amazon CognitoUser Authentication and Identity with Amazon Cognito
User Authentication and Identity with Amazon Cognito
 
User Identity and Authentication
User Identity and AuthenticationUser Identity and Authentication
User Identity and Authentication
 
Deep Dive on Amazon Cognito - DevDay Los Angeles 2017
Deep Dive on Amazon Cognito - DevDay Los Angeles 2017Deep Dive on Amazon Cognito - DevDay Los Angeles 2017
Deep Dive on Amazon Cognito - DevDay Los Angeles 2017
 
Cognito Customer Deep Dive
Cognito Customer Deep DiveCognito Customer Deep Dive
Cognito Customer Deep Dive
 
Implement User Onboarding, Sign-Up, and Sign-In for Mobile and Web Applicatio...
Implement User Onboarding, Sign-Up, and Sign-In for Mobile and Web Applicatio...Implement User Onboarding, Sign-Up, and Sign-In for Mobile and Web Applicatio...
Implement User Onboarding, Sign-Up, and Sign-In for Mobile and Web Applicatio...
 
Add User Sign in and Management to your Apps with Amazon Cognito
Add User Sign in and Management to your Apps with Amazon CognitoAdd User Sign in and Management to your Apps with Amazon Cognito
Add User Sign in and Management to your Apps with Amazon Cognito
 
Amazon Cognito Public Beta of Built-in UI for User Sign-up/in and SAML Federa...
Amazon Cognito Public Beta of Built-in UI for User Sign-up/in and SAML Federa...Amazon Cognito Public Beta of Built-in UI for User Sign-up/in and SAML Federa...
Amazon Cognito Public Beta of Built-in UI for User Sign-up/in and SAML Federa...
 
Identity Management for Your Users and Apps: A Deep Dive on Amazon Cognito - ...
Identity Management for Your Users and Apps: A Deep Dive on Amazon Cognito - ...Identity Management for Your Users and Apps: A Deep Dive on Amazon Cognito - ...
Identity Management for Your Users and Apps: A Deep Dive on Amazon Cognito - ...
 
Authentication & Authorization for Connected Mobile & Web Applications using ...
Authentication & Authorization for Connected Mobile & Web Applications using ...Authentication & Authorization for Connected Mobile & Web Applications using ...
Authentication & Authorization for Connected Mobile & Web Applications using ...
 
Announcements for Mobile Developers
Announcements for Mobile DevelopersAnnouncements for Mobile Developers
Announcements for Mobile Developers
 
Building mobile apps on AWS
Building mobile apps on AWSBuilding mobile apps on AWS
Building mobile apps on AWS
 
Building mobile apps on aws
Building mobile apps on awsBuilding mobile apps on aws
Building mobile apps on aws
 
AWS Mobile Services & SDK Introduction & Demo
AWS Mobile Services & SDK Introduction & DemoAWS Mobile Services & SDK Introduction & Demo
AWS Mobile Services & SDK Introduction & Demo
 
Serverless Authentication and Authorisation
Serverless Authentication and AuthorisationServerless Authentication and Authorisation
Serverless Authentication and Authorisation
 
AWS Webinar Series - Build web-based and native mobile applications on AWS
AWS Webinar Series - Build web-based and native mobile applications on AWS AWS Webinar Series - Build web-based and native mobile applications on AWS
AWS Webinar Series - Build web-based and native mobile applications on AWS
 
Build Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile ServicesBuild Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile Services
 
The bits and pieces of Azure AD B2C
The bits and pieces of Azure AD B2CThe bits and pieces of Azure AD B2C
The bits and pieces of Azure AD B2C
 
Building Cloud-powered Mobile Apps
Building Cloud-powered Mobile AppsBuilding Cloud-powered Mobile Apps
Building Cloud-powered Mobile Apps
 
AWS Webinar - 201 Developing mobile apps with AWS
AWS Webinar - 201 Developing mobile apps with AWSAWS Webinar - 201 Developing mobile apps with AWS
AWS Webinar - 201 Developing mobile apps with AWS
 

Plus de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Plus de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Managing Identity and Securing Your Mobile and Web Applications with Amazon Cognito - AWS PS Summit Canberra 2017

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates, All rights reserved. Managing Identity and Securing Your Mobile and Web Applications with Amazon Cognito Stephen Liedig, Solutions Architect A/NZ Public Sector, AWS August 2017
  • 2. Identity is mission critical for applications Security Revenue Generation Application Backbone  Know your users  Monitor engagement with your application  Store and manage user data  Personalize your users’ experiences  Protect sensitive data  Secure business- critical processes User Identity
  • 3. Identity is mission critical for applications Authentication User ManagementAuthorization  Manage user lifecycles  Store and manage user profile data  Monitor engagement  Protect data and operations  Provide fine-grained access control  Sign in users  Enable federation with enterprise identities  Enable federation with social identities User Identity
  • 4. Developing Auth Infrastructure is Difficult Source: images.huffingtonpost.com/2015-06-18-1434640796-8854716-frustration.jpg
  • 5. Developing Auth Infrastructure is Difficult • Need to develop a reliable user directory to manage identities • Handling user data and passwords and protecting privacy • Prioritizing scalability of your infrastructure upfront • Implementing token-based authentication • Support for multiple social identity providers • Federation with corporate directories for B2E applications 1 2 3 5 6 4
  • 6. Amazon Cognito Identity Your User Pools You can easily and securely add sign-up and sign-in functionality to your mobile and web apps with a fully-managed service that scales to support 100s of millions of users. Federated Identities Your users can sign in with third-party identity providers, such as Facebook and SAML providers, and you can control access to AWS resources from your app. Sign in Username Password Submit Facebook Corporate OIDC Sign in with SAML
  • 7. Comprehensive Support for Identity Use Cases
  • 8. Amazon Cognito: Identity Management Scenarios Business to Consumer IoT Scenarios Business to Employee SAML Federation Enterprise Directory Partner A Partner B Business to Business AWS IoT API Gateway with Lambda Deny Allow Custom Authorizer Access control for AWS Resources AWS IAM
  • 9. Lets dive a little deeper… Source: https://freerangestock.com/photos/44722/photo-details.html
  • 10. I want to authenticate • consumers • employees • systems …on • Amazon EC2 / Amazon ECS • AWS Lambda • Browser • Mobile • other …against • IAM • A managed IdP • SAML • Google • Twitter • Facebook • OpenID • Custom …to access • AWS APIs and SDKs • Amazon API Gateway • custom applications
  • 11. I want to authenticate people …on browser or mobile Let’s imagine a user table Username Email Password beverly123 beverly123@example.com Password$123 pilotjane pilotjane@example.com a##eroplan3 sudhir1977 sudhir197@example.com mmd414997a
  • 12. I want to authenticate people …on browser or mobile Let’s imagine a user table Username Email Password beverly123 beverly123@example.com Password$123 pilotjane pilotjane@example.com a##eroplan3 sudhir1977 sudhir197@example.com mmd414997a • Never store passwords in plaintext! • Vulnerable to rogue employees • A hacked DB results in all passwords being compromised
  • 13. I want to authenticate people …on browser or mobile Let’s try again… Username Email Hashed Password beverly123 beverly123@example.com 21a730e7d6cc9d715efcc0514ed69a1f pilotjane pilotjane@example.com fea74fde863cd38f88b3393f590ae883 sudhir1977 sudhir197@example.com 6ce6be14f0c775cc9b3dbe4e18d9fc7d
  • 14. I want to authenticate people …on browser or mobile Doh!!! Username Email Hashed Password beverly123 beverly123@example.com 21a730e7d6cc9d715efcc0514ed69a1f pilotjane pilotjane@example.com fea74fde863cd38f88b3393f590ae883 sudhir1977 sudhir197@example.com 6ce6be14f0c775cc9b3dbe4e18d9fc7d • MD5/SHA1 collisions • Rainbow Tables • Dictionary attacks, brute-force (GPUs can compute billions of hashes/sec)
  • 15. I want to authenticate people …on browser or mobile Secure Remote Password Protocol Username Email SRP Verifier function beverly123 beverly123@example.com <password-specific verifier> pilotjane pilotjane@example.com <password-specific verifier> sudhir1977 sudhir197@example.com <password-specific verifier> Secure Remote Password (SRP) Protocol • Verifier-based protocol • Passwords never travel over the wire • Resistant to several attack vectors • Perfect Forward Secrecy
  • 16. I want to authenticate people …on browser or mobile But wait… Best practices ☐ Secure password handling
  • 17. I want to authenticate people …on browser or mobile But wait… Best practices ☐ Secure password handling ☐ Encrypt all data server-side ☐ Enforce password policies (min length, valid characters) ☐ Token-based Authentication ☐ MFA - via SMS for sign-in and forgot password flows ☐ Support CAPTCHAs and other custom authentication flows ☐ Scalable to 100s of millions of users
  • 18. I want to authenticate people …on browser or mobile But wait… User flows ☐ Registration ☐ Verify email/phone ☐ Secure sign-in Best practices ☐ Secure password handling ☐ Encrypt all data server-side ☐ Enforce password policies (min length, valid characters) ☐ Token-based Authentication ☐ MFA - via SMS for sign-in and forgot password flows ☐ Support CAPTCHAs and other custom authentication flows ☐ Scalable to 100s of millions of users ☐ Forgot password ☐ Change password ☐ Sign-out
  • 19. I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools Amazon Cognito User Pools Best practices ☐ Secure password handling ☐ Encrypt all data server-side ☐ Enforce password policies (min length, valid characters) ☐ Token-based Authentication ☐ MFA - via SMS for sign-in and forgot password flows ☐ Support CAPTCHAs and other custom authentication flows ☐ Scalable to 100s of millions of users User flows ☐ Registration ☐ Verify email/phone ☐ Secure sign-in ☐ Forgot password ☐ Change password ☐ Sign-out
  • 20. I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools User APIs Email or Phone Number Verification Require users to verify their email address or phone number prior to activating their account with a one-time password challenge Forgot Password Provide users the ability to change their password when they forget it with a one-time password challenge User Sign-Up and Sign-In Allow users to sign up and sign in using an email, phone number, or username (and password) for your application. User Profile Data Enable users to view and update their profile data – including custom attributes SMS Multifactor Authentication Require users to complete a second factor of authentication by inputting a security code received via SMS as part of the sign-in flow Customize these User Flows Using Lambda Token Based Authentication Use JSON Web Tokens (JWTs) based on OpenID Connect (OIDC) and OAuth 2.0 standards for user authentication in your backend
  • 21. I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools Administrator APIs Define Custom Attributes Set per-App Permissions Set up Password Policies Create and manage User Pools Define custom attributes for your user profiles Set read and write permissions for each user attribute on a per-app basis Enforce password policies like minimum length and requirement of certain types of characters Create, configure, and delete multiple user pools across AWS regions Require Submission of Attribute Data Select which attributes must be provided by the user prior to completion of the sign-up process Search Users Search users based on a full match or a prefix match of their attributes through the console or Admin API Manage Users Conduct admin actions, such as reset user password, confirm user, enable MFA, delete user, and global sign-out
  • 22. I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools Customize with Lambda triggers Category Lambda Hook Example Scenarios Custom Authentication Flow Define Auth Challenge Determines the next challenge in a custom auth flow Create Auth Challenge Creates a challenge in a custom auth flow Verify Auth Challenge Response Determines if a response is correct in a custom auth flow Authentication Events Pre Authentication Custom validation to accept or deny the sign-in request Post Authentication Event logging for custom analytics Sign-Up Pre Sign-up Custom validation to accept or deny the sign-up request Post Confirmation Custom welcome messages or event logging for custom analytics Messages Custom Message Advanced customization and localization of messages
  • 23. I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools App Integration with User Pools Use the Amazon Cognito SDK (JavaScript / Android / iOS), use the APIs directly. User Pools now provides a hosted UI for sign up, sign in, forgot password, etc. Developers can customize the UI to match their style and branding through custom logo and CSS NEW!
  • 24. I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools UI Customizations Customize UI for each application Customize logo CSS customizations
  • 25. How do I use Amazon Cognito User Pools to authenticate against Amazon API Gateway? I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway
  • 26. Amazon Cognito User Pool Authorizer I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Supports authentication, but not authorization. API Gateway has an easy integration with Amazon Cognito User Pools.
  • 27. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway For fine grained authorization to API Gateway, you’ll need to use an API Gateway Custom Authorizer. Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth … let’s dive a bit deeper…
  • 28. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Step 1: User signs up for an account with our Amazon Cognito User Pool, providing their email, telephone number & password (+ any custom attributes). Amazon Cognito can automatically verify the user’s email address and/or phone number if required.
  • 29. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Step 2: At some point in the future, the user wants to sign in. We can now authenticate the user.
  • 30. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Optional: If MFA is enabled (either for this user, or all users), Amazon Cognito will SMS a one time authentication code to the user.
  • 31. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Step 3: After a successful authentication, Amazon Cognito responds with a signed JSON Web Token (JWT) containing the user’s details. JWT Token
  • 32. Wait… what’s a JWT? I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway https://jwt.io Cryptographically verifiableclaims
  • 33. Restricting JWT claims I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway You can select which Amazon Cognito User Pool attributes are included in the generated JWT token by using scopes.
  • 34. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Step 3: After a successful authentication, Amazon Cognito responds with a signed JSON Web Token (JWT) containing the user’s details. JWT Token
  • 35. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Step 4: You are now ready to call your backend API’s from your mobile application. The JWT is passed in via the Authorization HTTP header. GET /pets HTTP/1.1 Host: ... Authorization:eyJraWQi…
  • 36. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Step 5: API Gateway calls your custom authorizer function which validates the JWT token and creates an IAM policy that defines which API resources the user can access (based on their user attributes in the JWT claims). GET /pets HTTP/1.1 Host: ... Authorization:eyJraWQi…
  • 37. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Step 6: Additionally, the custom authorizer function will need to check that the JWT hasn’t been tampered with. To do this, it needs the signing public key (JWK) from Amazon Cognito. GET /pets HTTP/1.1 Host: ... Authorization:eyJraWQi…
  • 38. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway var samplePolicy = new AuthPolicy(”userIdentifier", "XXXXXXXXXXXX", apiOptions); samplePolicy.allowMethod(AuthPolicy.HttpVerb.POST, "/windfarms/"); samplePolicy.allowMethod(AuthPolicy.HttpVerb.GET, "/windfarms/123/*"); samplePolicy.allowMethod(AuthPolicy.HttpVerb.GET, "/windfarms/234/*"); samplePolicy.allowMethod(AuthPolicy.HttpVerb.ALL, "/users/" + user.id); callback(null, samplePolicy.getPolicy()); A custom authorizer function should return a policy that defines which API resources the user should get access to. This is then cached and used for any requests with the same authentication token (default: 300 seconds). Make sure your policy includes all actions the user can perform, not just a single request.
  • 39. Custom Authorizers I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pools Amazon API Gateway Custom Authorizer Lambda Function /pets /n… Amazon DynamoDB Throttling Cache Logging Monitoring Auth Step 7: If authentication was successful, the API call will be passed through to the backend Lambda functions where your logic sits. Authentication is cached for each token (up to 1 hour). GET /pets HTTP/1.1 Host: ... Authorization:eyJraWQi…
  • 40. API Gateway summary I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access Amazon API Gateway Amazon Cognito User Pool Authenticate 2 CUP Token1 Backend resources Access backend resources CUP Token API GW 4 Amazon Cognito User Pools can be used as standalone IdPs Amazon Cognito User Pools and API Gateway integrate really nicely. Use the built in User Pool Authorizer if you don’t need authorization. Use Custom Authorizers instead if you do.
  • 41. I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access AWS APIs and SDKs How do I use Amazon Cognito User Pools to authenticate / authorize access to AWS APIs and SDKs?
  • 42. AWS APIs and SDKs I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access AWS APIs and SDKs Amazon Cognito User Pools cannot generate AWS credentials. You need to use Amazon Cognito Federated Identity in-front of Amazon Cognito User Pools.
  • 43. AWS APIs and SDKs I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access AWS APIs and SDKs You can then configure the AWS SDK to fetch API credentials from Amazon Cognito like so: var Amazon CognitoUser = userPool.getCurrentUser(); if (Amazon CognitoUser != null) { Amazon CognitoUser.getSession(function(err, result) { if (result) { console.log('You are now logged in.'); // Add the User's Id Token to the Amazon Cognito credentials login map. AWS.config.credentials = new AWS.Amazon CognitoIdentityCredentials({ IdentityPoolId: 'YOUR_IDENTITY_POOL_ID', Logins: { 'Amazon Cognito-idp.{region}.amazonaws.com/{user-pool-id}': result.getIdToken().getJwtToken() } }); } }); }
  • 44. RBAC (Role based access control) I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access AWS APIs and SDKs Amazon Cognito User Pool groups can be configured with an IAM role You can then configure Amazon Cognito Federated Identity to use the role within the JWT token when issuing AWS credentials
  • 45. RBAC (Role based access control) I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools …to access AWS APIs and SDKs Alternatively, you can also map roles based on other attributes in the JWT token
  • 46. I want to authenticate people …on browser or mobile …against Amazon Cognito User Pools What about federation to Active Directory, SAML and/or social media accounts?
  • 47. I want to authenticate people …on browser or mobile …against SAML (Active Directory) and/or social media accounts …to access AWS APIs and SDKs, Amazon API Gateway or custom applications SAML / Active Directory Federation NEW!
  • 48. I want to authenticate people …on browser or mobile …against SAML (Active Directory) and/or social media accounts …to access AWS APIs and SDKs, Amazon API Gateway or custom applications Social Media Federation
  • 49. Mapping Federated Attributes I want to authenticate people …on browser or mobile …against SAML (Active Directory) and/or social media accounts …to access AWS APIs and SDKs, Amazon API Gateway or custom applications
  • 50. Business to Consumer Use Case I want to authenticate people …on browser or mobile …against SAML (Active Directory) …to access AWS APIs and SDKs, Amazon API Gateway or custom applications Get AWS credentials Cognito Identity Pool DynamoDB S3 API GW Access backend resources Cognito User Pool Authenticate 3 CUP Token1 IdP Token 2 Redirect / Post back CUP Token 4 5 User Pools authenticate users and returns OpenID Connect and OAuth2.0 standard tokens Identity Pools provide AWS credentials to access backend resources
  • 51. Business to Business/Employee with SAML I want to authenticate people …on browser or mobile …against SAML (Active Directory) …to access AWS APIs and SDKs, Amazon API Gateway or custom applications User Pools authenticate users and returns OpenID Connect and OAuth2.0 standard tokens Identity Pools provide AWS credentials to access backend resources Get AWS credentials Cognito Identity Pool DynamoDB S3 API GW Access backend resources SAML IdP (e.g., ADFS) Cognito User Pool Authenticate 3 CUP Token1 SAML 2 Redirect / Post back CUP Token 4 5
  • 52. Business to Business/Employee with SAML v2 I want to authenticate people …on browser or mobile …against SAML (Active Directory) …to access AWS APIs and SDKs, Amazon API Gateway or custom applications Amazon Cognito User Pools authenticate users and returns OpenID Connect and OAuth2.0 standard tokens Amazon Cognito User Pool tokens can be used for authorizing access to your APIs / backend SAML IdP (e.g., ADFS) Cognito User Pool Authenticate 3 CUP Token1 SAML 2 Redirect / Post back Backend resources Access backend resources CUP Token API GW 4
  • 53. I want to authenticate systems Ok, we’ve covered authenticating people, but what about authenticating systems? For example, Application A communicating with Application B.
  • 54. want to authenticate systems …on Amazon EC2 …against IAM …to access AWS APIs and SDKs Amazon EC2 Instance Roles Instance roles allow you to grant access from systems on EC2 (AWS CLI or SDKs) to access AWS Services without needing to bake in credentials. The CLI and SDKs are preconfigured to detect and use instance roles if one is attached.
  • 55. want to authenticate systems …on Amazon EC2 …against IAM …to access Amazon API Gateway EC2 Instance Roles EC2 Instance Roles are also a great option for granting access to APIs hosted with Amazon API Gateway. API Gateway should be configured for IAM authentication:
  • 56. want to authenticate systems …on Amazon EC2 …against IAM …to access Amazon API Gateway EC2 Instance Roles …and the IAM role should have a policy attached that allows access to the API required: { "Version": "2012-10-17", "Statement": [ { "Action": "execute-api:Invoke", "Effect": ”Allow", "Resource": "arn:aws:execute-api:*:*:ff5h9tpwfh/*" }, { "Action": "execute-api:Invoke", "Effect": "Deny", "Resource": "arn:aws:execute-api:*:*:ff5h9tpwfh/*/POST/windfarms" } ] }
  • 57. want to authenticate systems …on Amazon EC2 Container Service (ECS) …against IAM …to access AWS APIs and SDKs or Amazon API Gateway EC2 Container Service (ECS) ECS supports IAM Roles too. This makes it easy to secure an AWS Service or API hosted with Amazon API Gateway to a specific container (or group of containers).
  • 58. want to authenticate systems …on AWS Lambda …against IAM …to access AWS APIs and SDKs or Amazon API Gateway AWS Lambda Use AWS Lambda’s execution role to secure an AWS service or API hosted with Amazon API Gateway to a specific AWS Lambda function.
  • 59. Summary It can support a wide range of scenarios including customers, employees, systems 1 2 3 5 6 4 It includes a fully managed identity provider (Amazon Cognito User Pools), with a great free tier Amazon Cognito offers huge flexibility for AuthN / AuthZ Hosted authentication pages makes integrating really easy Don’t be scared of Amazon Cognito  Reach out to your local SA if you need help New SAML and social federation in Amazon Cognito User Pools!
  • 60. No more of this… Source: images.huffingtonpost.com/2015-06-18-1434640796-8854716-frustration.jpg
  • 62. © 2017, Amazon Web Services, Inc. or its Affiliates, All rights reserved. Thank you!