SlideShare a Scribd company logo
1 of 41
Download to read offline
Securing Serverless Applications
Part 1
Karthi Thyagarajan
Enterprise Solutions Architect
Using Amazon API Gateway, AWS Lambda and Amazon Cognito
Imagine for a minute…
Being able to develop a mobile backend API that:
• Requires no infrastructure
• Scales automatically to meet demand
• Has granular costs that grow with usage
The services we are going to use
Amazon API GatewayAWS Lambda Amazon Cognito Amazon DynamoDB
Host the API and
route API calls
Execute our app’s
business logic
Generate temporary
AWS credentials
Data store
What to Expect from the Session
1. Start with a basic 3-tier web app
• Pure serverless
2. Add authentication with Amazon Cognito
• Integrate with Cognito
• Login by leveraging BYOI (bring your own identity)
3. Authorization with AWS IAM
4. Segue to part 2
Key takeaways
AWS Lambda + Amazon API Gateway means no
infrastructure to manage – we scale for you
Security is important, and complex – make the most of
AWS Identity and Access Management by leveraging
Cognito
Flexibility – API Gateway, Lambda and Cognito give
you choices for authentication and authorization
First building block:
AWS Lambda
High performance at any scale;
Cost-effective and efficient
No Infrastructure to manage
Pay only for what you use: Lambda
automatically matches capacity to
your request rate. Purchase
compute in 100ms increments.
Bring Your Own Code
Lambda functions: Stateless, trigger-based code execution
Run code in a choice of standard
languages. Use threads, processes,
files, and shell scripts normally.
Focus on business logic, not
infrastructure. You upload code; AWS
Lambda handles everything else.
AWS Lambda Overview
AWS Lambda Console
Develop, test and
publish your Lambda
functions either by the
AWS Management
Console, AWS CLI or
our SDKs.
Or use community
frameworks such as
serverless.com,
gosparta.io and
more…
Second building block:
Amazon API Gateway
Amazon API Gateway overview
Manage deployments to
multiple versions and
environments
Define and host APIs
Leverage Identity and
Access Management to
authorize access to your
cloud resources
Leverage AWS Auth
DDoS protection and
request throttling to
safeguard your back end
Manage network traffic
Your Feedback
Managing multiple versions and stages of an API is difficult
Monitoring 3rd party developers’ access is time consuming
Access authorization is a challenge
Traffic spikes create operational burden
What if I don’t want servers at all?
Host multiple versions and stages of your APIs
Create and distribute API Keys to developers
Authenticate and authorise API consumers
Throttle and monitor requests to protect your backend
Utilizes AWS Lambda
Introducing Amazon API Gateway
Introducing Amazon API Gateway
Managed cache to store API responses
Reduced latency and DDoS protection through CloudFront
SDK Generation for iOS, Android and JavaScript
Swagger import and export support
Request / Response data transformation and API mocking
Serverless 3-tier Web Architecture
Amazon API
Gateway
AWS
Lambda
Amazon
DynamoDB
Data tier App tier Presentation
tier
Amazon
S3
Amazon
CloudFront
Demo – notes app
Third building block:
Amazon Cognito
Amazon Cognito overview
Manage authenticated and
guest users across identity
providers
Identity management
Synchronize users’ data
across devices and
platforms via the cloud
Data synchronization
Securely access AWS
services from mobile
devices and platforms
Secure AWS access
The notes API
Unauthenticated
API call flows
Clients AWS Lambda lambdaHandler
Register
Login
API Gateway
Authenticated
Clients AWS Lambda lambdaHandler
ListNotes
CreateNote
API Gateway
Assume Role
Etc..
Sigv4 Invoke with
caller credentials
Authorized by IAM
Retrieving AWS credentials
The API definition
• POST
• Receives a user name and password
• Encrypts the password and creates the user
account in DynamoDB
• Calls Amazon Cognito to generate
credentials
• Returns the user + its credentials
/users
• POST
• Receives a user name and password
• Authenticates the user against the
DynamoDB database
• Calls Amazon Cognito to generate
credentials
• Returns a set of temporary credentials
/login
Retrieving temporary AWS credentials
Call Login API,
no auth required
Client API Gateway Backend
/login
Login
action
User
accounts
database
Credentials
verified
Get OpenID token
for developer
identity
Receives
credentials to
sign API calls
Identity ID +
token
Get credentials for
identity
Access key +
secret key +
session token
/login
1.
2.
3.
Demo – login with Cognito
Authorizing API calls
The Pets resources require authorization
• POST
• Receives a Pet model
• Saves it in DynamoDB
• Returns the new Pet ID
• GET
• Returns the list of Pets stored in
DynamoDB
/pets
• GET
• Receives a Pet ID from the path
• Uses mapping templates to pass the path
parameter to the Lambda function
• Loads the Pet from DynamoDB
• Returns a Pet model
/pets/{petId}
Using the caller credentials
credentials:
arn:aws:iam::*:user/*
Using the console Using Swagger
The IAM role defines access permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Scan",
"lambda:InvokeFunction",
"execute-api:invoke"
],
"Resource": [
"arn:aws:dynamodb:us-east-1:xxxxxx:table/notes",
"arn:aws:lambda:us-east-1:xxxxx:function:NotesGet”,
"arn:aws:execute-api:us-east-1:xxxx:API_ID/*/POST/notes"
]
}
]
}
The role allows calls to:
• DynamoDB
• API Gateway
• Lambda
The role can access specific
resources in these services
One step further: Fine-grained access permissions
Internet
Client
API
Gateway
AWS Lambda
functions
Amazon
CloudFront
DynamoDB
CognitoId2
…
"Condition": {
"ForAllValues:StringEquals": {
"dynamodb:LeadingKeys": [”${cognito-
identity.amazonaws.com:sub}"],
"dynamodb:Attributes": [
"UserId","GameTitle","Wins","Losses",
"TopScore","TopScoreDateTime”
]
},
"StringEqualsIfExists": {
"dynamodb:Select": "SPECIFIC_ATTRIBUTES”
}
}
…
Executes with
this role
UserID Wins Losses
cognitoId1 3 2
cognitoId2 5 8
cognitoId3 2 3
The credentials and context (Cognito ID) are passed along
Both AWS Lambda & DynamoDB will follow the access policy
Authenticated flow in depth
Clients AWS Lambda lambdaHandler
API Gateway
Sigv4
Invoke with
caller credentials
Service calls are
authorized using
the IAM role
Learn more about fine-grained access permissions
http://amzn.to/1YkxcjR
DynamoDB
Demo – Authorization
Benefits of using AWS auth & IAM
• Separation of concerns – our authorization strategy is
delegated to a dedicated service
• We have centralized access management to a single
set of policies
• Roles and credentials can be disabled with a single
API call
AWS credentials on the client
1-click SDK generation from the console
The client SDK declares all methods
The AWSCredentialsProvider
We implement the AWSCredentialsProvider interface
The refresh() method is called whenever the SDK needs new credentials
Generated SDK benefits
The generated client SDK knows how to:
• Sign API calls using AWS signature version 4
• Handle-throttled responses with exponential back-off
• Marshal and unmarshal requests and responses to
model objects
Options for authentication and
authorization
Options
• Cognito facilitates BYOI
• Google, FB, etc…
• Roll your own
• Cognito User Pools
• Authorization options – facilitated by API Gateway
• AWS IAM
• Custom Authorizer
Manage authenticated
and guest users’
access to your AWS
resources
Federated Identities
Add sign-up and sign-
in with a fully
managed user
directory
Your User Pool
GuestYour own auth
Amazon Cognito Identity
Amazon Cognito Identity
What have we learned?
AWS Lambda + Amazon API Gateway means no
infrastructure to manage – we scale for you
Security is important, and complex – make the most of
AWS Identity and Access Management by leveraging
Cognito
Flexibility – API Gateway, Lambda and Cognito give
you choices for authentication and authorization
Questions?

More Related Content

What's hot

Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Amazon Web Services
 

What's hot (20)

Getting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and ServerlessGetting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and Serverless
 
Accelerating App Development with AWS Amplify
Accelerating App Development with AWS AmplifyAccelerating App Development with AWS Amplify
Accelerating App Development with AWS Amplify
 
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...
 
IaC on AWS Cloud
IaC on AWS CloudIaC on AWS Cloud
IaC on AWS Cloud
 
AWS API Gateway
AWS API GatewayAWS API Gateway
AWS API Gateway
 
K8s on AWS: Introducing Amazon EKS
K8s on AWS: Introducing Amazon EKSK8s on AWS: Introducing Amazon EKS
K8s on AWS: Introducing Amazon EKS
 
AWS Amplify
AWS AmplifyAWS Amplify
AWS Amplify
 
Introduction to Serverless
Introduction to ServerlessIntroduction to Serverless
Introduction to Serverless
 
Amazon Cognito
Amazon CognitoAmazon Cognito
Amazon Cognito
 
Auto Scaling on AWS
Auto Scaling on AWSAuto Scaling on AWS
Auto Scaling on AWS
 
Intro to AWS Lambda
Intro to AWS Lambda Intro to AWS Lambda
Intro to AWS Lambda
 
Introduction to AWS IAM
Introduction to AWS IAMIntroduction to AWS IAM
Introduction to AWS IAM
 
AWS Cloud Watch
AWS Cloud WatchAWS Cloud Watch
AWS Cloud Watch
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
 
Introduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless ApplicationsIntroduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless Applications
 
Lambdaless and AWS CDK
Lambdaless and AWS CDKLambdaless and AWS CDK
Lambdaless and AWS CDK
 
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
 
Serverless Microservices Communication with Amazon EventBridge
Serverless Microservices Communication with Amazon EventBridgeServerless Microservices Communication with Amazon EventBridge
Serverless Microservices Communication with Amazon EventBridge
 
Introduction to Amazon EC2
Introduction to Amazon EC2Introduction to Amazon EC2
Introduction to Amazon EC2
 
Serverless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about serversServerless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about servers
 

Similar to Securing Serverless Workloads with Cognito and API Gateway Part I - AWS Security Day

amazon-cognito-auth-in-minutes
amazon-cognito-auth-in-minutesamazon-cognito-auth-in-minutes
amazon-cognito-auth-in-minutes
Vladimir Budilov
 
Deep Dive on Amazon Cognito - DevDay Austin 2017
Deep Dive on Amazon Cognito - DevDay Austin 2017Deep Dive on Amazon Cognito - DevDay Austin 2017
Deep Dive on Amazon Cognito - DevDay Austin 2017
Amazon Web Services
 

Similar to Securing Serverless Workloads with Cognito and API Gateway Part I - AWS Security Day (20)

Building Secure Mobile APIs
Building Secure Mobile APIsBuilding Secure Mobile APIs
Building Secure Mobile APIs
 
Workshop: We love APIs
Workshop: We love APIsWorkshop: We love APIs
Workshop: We love APIs
 
amazon-cognito-auth-in-minutes
amazon-cognito-auth-in-minutesamazon-cognito-auth-in-minutes
amazon-cognito-auth-in-minutes
 
Security Best Practices for Serverless Applications - July 2017 AWS Online T...
Security Best Practices for Serverless Applications  - July 2017 AWS Online T...Security Best Practices for Serverless Applications  - July 2017 AWS Online T...
Security Best Practices for Serverless Applications - July 2017 AWS Online T...
 
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API GatewayBuilding Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API Gateway
 
Cloud Security-how to create serverless applications
Cloud Security-how to create serverless applicationsCloud Security-how to create serverless applications
Cloud Security-how to create serverless applications
 
Building Scalable Services with Amazon API Gateway - Technical 201
Building Scalable Services with Amazon API Gateway - Technical 201Building Scalable Services with Amazon API Gateway - Technical 201
Building Scalable Services with Amazon API Gateway - Technical 201
 
Rapid Application Development on AWS
Rapid Application Development on AWSRapid Application Development on AWS
Rapid Application Development on AWS
 
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
 
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
 
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
 
Federation
FederationFederation
Federation
 
AWS Identity, Directory, and Access Services: An Overview
AWS Identity, Directory, and Access Services: An Overview AWS Identity, Directory, and Access Services: An Overview
AWS Identity, Directory, and Access Services: An Overview
 
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
 
Federation
FederationFederation
Federation
 
AWS Identity, Directory, and Access Services: An Overview - SID201 - Chicago ...
AWS Identity, Directory, and Access Services: An Overview - SID201 - Chicago ...AWS Identity, Directory, and Access Services: An Overview - SID201 - Chicago ...
AWS Identity, Directory, and Access Services: An Overview - SID201 - Chicago ...
 
SID201 Overview of AWS Identity, Directory, and Access Services
 SID201 Overview of AWS Identity, Directory, and Access Services SID201 Overview of AWS Identity, Directory, and Access Services
SID201 Overview of AWS Identity, Directory, and Access Services
 
Ovations AWS pop-up loft 2019 Technical presentation
Ovations AWS pop-up loft 2019 Technical presentationOvations AWS pop-up loft 2019 Technical presentation
Ovations AWS pop-up loft 2019 Technical presentation
 
Deep Dive on Amazon Cognito - DevDay Austin 2017
Deep Dive on Amazon Cognito - DevDay Austin 2017Deep Dive on Amazon Cognito - DevDay Austin 2017
Deep Dive on Amazon Cognito - DevDay Austin 2017
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 

More from 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
 

More from 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
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Securing Serverless Workloads with Cognito and API Gateway Part I - AWS Security Day

  • 1. Securing Serverless Applications Part 1 Karthi Thyagarajan Enterprise Solutions Architect Using Amazon API Gateway, AWS Lambda and Amazon Cognito
  • 2. Imagine for a minute… Being able to develop a mobile backend API that: • Requires no infrastructure • Scales automatically to meet demand • Has granular costs that grow with usage
  • 3. The services we are going to use Amazon API GatewayAWS Lambda Amazon Cognito Amazon DynamoDB Host the API and route API calls Execute our app’s business logic Generate temporary AWS credentials Data store
  • 4. What to Expect from the Session 1. Start with a basic 3-tier web app • Pure serverless 2. Add authentication with Amazon Cognito • Integrate with Cognito • Login by leveraging BYOI (bring your own identity) 3. Authorization with AWS IAM 4. Segue to part 2
  • 5. Key takeaways AWS Lambda + Amazon API Gateway means no infrastructure to manage – we scale for you Security is important, and complex – make the most of AWS Identity and Access Management by leveraging Cognito Flexibility – API Gateway, Lambda and Cognito give you choices for authentication and authorization
  • 7. High performance at any scale; Cost-effective and efficient No Infrastructure to manage Pay only for what you use: Lambda automatically matches capacity to your request rate. Purchase compute in 100ms increments. Bring Your Own Code Lambda functions: Stateless, trigger-based code execution Run code in a choice of standard languages. Use threads, processes, files, and shell scripts normally. Focus on business logic, not infrastructure. You upload code; AWS Lambda handles everything else. AWS Lambda Overview
  • 8. AWS Lambda Console Develop, test and publish your Lambda functions either by the AWS Management Console, AWS CLI or our SDKs. Or use community frameworks such as serverless.com, gosparta.io and more…
  • 10. Amazon API Gateway overview Manage deployments to multiple versions and environments Define and host APIs Leverage Identity and Access Management to authorize access to your cloud resources Leverage AWS Auth DDoS protection and request throttling to safeguard your back end Manage network traffic
  • 11. Your Feedback Managing multiple versions and stages of an API is difficult Monitoring 3rd party developers’ access is time consuming Access authorization is a challenge Traffic spikes create operational burden What if I don’t want servers at all?
  • 12. Host multiple versions and stages of your APIs Create and distribute API Keys to developers Authenticate and authorise API consumers Throttle and monitor requests to protect your backend Utilizes AWS Lambda Introducing Amazon API Gateway
  • 13. Introducing Amazon API Gateway Managed cache to store API responses Reduced latency and DDoS protection through CloudFront SDK Generation for iOS, Android and JavaScript Swagger import and export support Request / Response data transformation and API mocking
  • 14. Serverless 3-tier Web Architecture Amazon API Gateway AWS Lambda Amazon DynamoDB Data tier App tier Presentation tier Amazon S3 Amazon CloudFront
  • 17. Amazon Cognito overview Manage authenticated and guest users across identity providers Identity management Synchronize users’ data across devices and platforms via the cloud Data synchronization Securely access AWS services from mobile devices and platforms Secure AWS access
  • 19. Unauthenticated API call flows Clients AWS Lambda lambdaHandler Register Login API Gateway Authenticated Clients AWS Lambda lambdaHandler ListNotes CreateNote API Gateway Assume Role Etc.. Sigv4 Invoke with caller credentials Authorized by IAM
  • 21. The API definition • POST • Receives a user name and password • Encrypts the password and creates the user account in DynamoDB • Calls Amazon Cognito to generate credentials • Returns the user + its credentials /users • POST • Receives a user name and password • Authenticates the user against the DynamoDB database • Calls Amazon Cognito to generate credentials • Returns a set of temporary credentials /login
  • 22. Retrieving temporary AWS credentials Call Login API, no auth required Client API Gateway Backend /login Login action User accounts database Credentials verified Get OpenID token for developer identity Receives credentials to sign API calls Identity ID + token Get credentials for identity Access key + secret key + session token /login 1. 2. 3.
  • 23. Demo – login with Cognito
  • 25. The Pets resources require authorization • POST • Receives a Pet model • Saves it in DynamoDB • Returns the new Pet ID • GET • Returns the list of Pets stored in DynamoDB /pets • GET • Receives a Pet ID from the path • Uses mapping templates to pass the path parameter to the Lambda function • Loads the Pet from DynamoDB • Returns a Pet model /pets/{petId}
  • 26. Using the caller credentials credentials: arn:aws:iam::*:user/* Using the console Using Swagger
  • 27. The IAM role defines access permissions { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:Scan", "lambda:InvokeFunction", "execute-api:invoke" ], "Resource": [ "arn:aws:dynamodb:us-east-1:xxxxxx:table/notes", "arn:aws:lambda:us-east-1:xxxxx:function:NotesGet”, "arn:aws:execute-api:us-east-1:xxxx:API_ID/*/POST/notes" ] } ] } The role allows calls to: • DynamoDB • API Gateway • Lambda The role can access specific resources in these services
  • 28. One step further: Fine-grained access permissions Internet Client API Gateway AWS Lambda functions Amazon CloudFront DynamoDB CognitoId2 … "Condition": { "ForAllValues:StringEquals": { "dynamodb:LeadingKeys": [”${cognito- identity.amazonaws.com:sub}"], "dynamodb:Attributes": [ "UserId","GameTitle","Wins","Losses", "TopScore","TopScoreDateTime” ] }, "StringEqualsIfExists": { "dynamodb:Select": "SPECIFIC_ATTRIBUTES” } } … Executes with this role UserID Wins Losses cognitoId1 3 2 cognitoId2 5 8 cognitoId3 2 3 The credentials and context (Cognito ID) are passed along Both AWS Lambda & DynamoDB will follow the access policy
  • 29. Authenticated flow in depth Clients AWS Lambda lambdaHandler API Gateway Sigv4 Invoke with caller credentials Service calls are authorized using the IAM role Learn more about fine-grained access permissions http://amzn.to/1YkxcjR DynamoDB
  • 31. Benefits of using AWS auth & IAM • Separation of concerns – our authorization strategy is delegated to a dedicated service • We have centralized access management to a single set of policies • Roles and credentials can be disabled with a single API call
  • 32. AWS credentials on the client
  • 33. 1-click SDK generation from the console
  • 34. The client SDK declares all methods
  • 35. The AWSCredentialsProvider We implement the AWSCredentialsProvider interface The refresh() method is called whenever the SDK needs new credentials
  • 36. Generated SDK benefits The generated client SDK knows how to: • Sign API calls using AWS signature version 4 • Handle-throttled responses with exponential back-off • Marshal and unmarshal requests and responses to model objects
  • 37. Options for authentication and authorization
  • 38. Options • Cognito facilitates BYOI • Google, FB, etc… • Roll your own • Cognito User Pools • Authorization options – facilitated by API Gateway • AWS IAM • Custom Authorizer
  • 39. Manage authenticated and guest users’ access to your AWS resources Federated Identities Add sign-up and sign- in with a fully managed user directory Your User Pool GuestYour own auth Amazon Cognito Identity Amazon Cognito Identity
  • 40. What have we learned? AWS Lambda + Amazon API Gateway means no infrastructure to manage – we scale for you Security is important, and complex – make the most of AWS Identity and Access Management by leveraging Cognito Flexibility – API Gateway, Lambda and Cognito give you choices for authentication and authorization