Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
cognito-userpools-in-production
Search
tannai
August 02, 2016
Technology
8.9k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
cognito-userpools-in-production
http://classmethod.connpass.com/event/35523/
#cmdevio
tannai
August 02, 2016
More Decks by tannai
See All by tannai
redash patche at dmm
yuukigoodman
0
770
akibago-2018-10-30
yuukigoodman
0
91
serverless-design-and-streaming-date-processing-service
yuukigoodman
0
1.1k
alexa-changes-development-process
yuukigoodman
0
1.7k
VUIとAlexaによるちょっと未来の体験の話2
yuukigoodman
0
940
regrowth2016alexa
yuukigoodman
0
1.4k
Rails App Deployment with CodeDeploy
yuukigoodman
0
1.6k
aws-lambda-in-practice
yuukigoodman
2
2.1k
serverless-from-today
yuukigoodman
2
2.3k
Other Decks in Technology
See All in Technology
range over func 2年間の軌跡 Issue #56413 はGoのエコシステムをどう変えたか
ryujicre8ive
0
190
synctest時代のhttptest Go 1.27で変わるHTTPサーバテストの裏側 / go conference2026 synctest and httptest
budougumi0617
1
3k
事業課題から技術的負債に向き合う
sansantech
PRO
2
1.8k
OpenTelemetryのメトリクスをCloudWatchに送ってPromQLで見てみた
ota1022
0
150
Claude in Chrome 入門 / Introduction to Claude in Chrome
cielo1985
0
820
Spring BootからQuarkusへの移行
tatsuya1bm
2
120
AIネイティブプロダクトで顧客価値を最大化するプロダクトエンジニアとFDEの協働
righttouch
PRO
0
310
20260912_スクラムにジェネラリストは必要か
ryugen04
0
420
安心して変更できるWebフロントエンドの作り方
pirosikick
4
2.5k
Screen Lens - 今見てる画面を翻訳する
komagata
0
310
Deployment の 先にある AI Agent 基盤 - kagent vNext、Agent Substrate、Hermes から読み解く Agent Runtime の現在地 / k8s-matsuri-2-ai-agent-platform-amsy810
masayaaoyama
3
570
AI時代の「技術的負債」の変質ー概念の終焉と再解釈、エージェントと共に向かう先
nwiizo
0
2.6k
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
77
5.5k
Code Review Best Practice
trishagee
74
20k
sira's awesome portfolio website redesign presentation
elsirapls
0
410
Building an army of robots
kneath
307
46k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
350
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
520
WCS-LA-2024
lcolladotor
0
830
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
A designer walks into a library…
pauljervisheath
211
25k
Transcript
࣮ࡍʹ͏ Cognito UserPools Classmethod, Inc. Yuki Tannai ࣮ફSERVERLESS #cmdevio ࣮ફserverless
#cmdevio 1
ࣗݾհ • ୮༏ل • @yuukigoodman • αʔόͰಈ͘ϓϩάϥϜͱ͔AWS ࣮ફserverless #cmdevio 2
Agenda • ServerlessͱCognito • Cognito User Pools • CognitoΛ࣮ࡍʹ͏ͨΊʹ ࣮ફserverless
#cmdevio 3
Serverlessͱ Cognito ࣮ફserverless #cmdevio 4
ServerlessΞʔΩςΫνϟ ͱ ࣮ફserverless #cmdevio 5
ඇৗறܕϓϩηε ΛΠϕϯτʹΑͬͯ τϦΨʔ͢ΔΠϯϑ ϥετϥΫνϟ1 — @zerobase 1 http://qiita.com/zerobase/items/3bc0d15980b472af841d ࣮ફserverless #cmdevio
6
ServerlessΞʔΩςΫνϟͱ • ΠϯϑϥΞϓϦͷΠϕϯτΛτϦΨʔʹ࣮ߦ ͞ΕΔඇৗறϓϩηε • ίʔυͷ࣮ߦڥ͕ϑϧϚωʔδυαʔϏεͱ ͯ͠ఏڙ͞ΕΔ • AWS Lambda͕࣮ݱํ๏ͷද֨ͱͯ͠༗໊
࣮ફserverless #cmdevio 7
serverlessͰղܾ͍ͨ͠ • EC2ແ͠Ͱ؆୯ͳϓϩάϥϜΛӡ༻͍ͨ͠ • ӡ༻ͷखؒ • ͓ۚͷઅ • ΞϓϦέʔγϣϯ͔Βຊ࣭Ͱͳ͍ίʔυΛগͳ ͍ͨ͘͠
LambdaҎ֎ͷΞϓϩʔν͋Δ ࣮ફserverless #cmdevio 8
Amazon Cognito ࣮ફserverless #cmdevio 9
Cognitoͱ • ΞϓϦέʔγϣϯͷೝূɾೝՄΛαϙʔτ͢Δ ϑϧϚωʔδυαʔϏε ࣮ફserverless #cmdevio 10
• Cognito Identity • Federated Identity • User Pools •
Cognito Sync • Sync Store • Cognito Events • Cognito Streams ࣮ફserverless #cmdevio 11
Cognito Identity • ֎෦Ͱೝূ͞ΕͨϢʔβʹରͯ͠ػೳΛఏڙ͢ Δ • Federated Identity • ֎෦ͷೝূαʔϏε͔Βͷ໊دͤ
• ಗ໊Ϣʔβͱͯ͠ͷೝূՄೳ • ෳͷIdentity ProviderΛͻͱͭͷIdentity ͱͯ͠ϚʔδͰ͖Δ ࣮ફserverless #cmdevio 12
• STS • AWSͷΞΫηεΩʔΛ҆શʹൃߦ͢Δ • AssumeRoleConditionઅͳͲIAMͱͷ࿈ ܞ ࣮ફserverless #cmdevio 13
࣮ફserverless #cmdevio 14
࣮ફserverless #cmdevio 15
Cognito Sync • ϢʔβσʔλͷಉظػೳΛఏڙ • Sync Store • KVSͷΑ͏ʹ͑ΔσʔλετΞ •
SDKܦ༝ͳΒϩʔΧϧετϨʔδͱͷ࿈ܞ ؆୯ ࣮ફserverless #cmdevio 16
• Cognito Streams • SyncΠϕϯτΛड৴ͯ͠Kinesis Streamsʹ ૹ৴͢Δ • Cognito Events
• SyncΠϕϯτΛड৴ͯ͠Lambda Function Λಉظ࣮ߦ͢Δ ࣮ફserverless #cmdevio 17
Cognito User Pools ࣮ફserverless #cmdevio 18
Cognito User Poolsͱ • AWS͕ఏڙ͢ΔIdentity Provider • ϢʔβͷొཧɺೝূΛߦͳ͏͜ͱ͕Ͱ͖ Δ •
Federated Identityͱ࿈ܞͰ͖Δ • ύεϫʔυMFAɺ֬ೝϝʔϧͷૹ৴ͳͲҰൠ తͳWebαʔϏεʹඞཁͳೝূػೳΛҰ௨Γ ͍࣋ͬͯΔ ࣮ફserverless #cmdevio 19
͍ͭʹGA! ࣮ફserverless #cmdevio 20
σϞ awslabs/aws-cognito-angular2-quickstart2 2 https://github.com/awslabs/aws-cognito-angular2-quickstart ࣮ફserverless #cmdevio 21
User Poolsͷػೳ ࣮ફserverless #cmdevio 22
Ϣʔβొ • ϢχʔΫͳϢʔβ໊Λઃఆ • ύεϫʔυೝূͱɺΦϓγϣϯͰMFAΛར༻ Մೳ • ύεϫʔυϙϦγʔΛઃఆՄೳ ࣮ફserverless #cmdevio
23
ΞτϦϏϡʔτ • ΘΕΔػձ͕ଟ͍ϢʔβଐੑΛઃఆՄೳ • ΤΠϦΞεʹΑͬͯɺϩάΠϯͰ༻͢Δଐੑ ΛࢦఆͰ͖Δ • ಠࣗͷΞτϦϏϡʔτΛઃఆͰ͖Δ ࣮ફserverless #cmdevio
24
ϝʔϧɾSMSͷ֬ೝͱMFA • Ϣʔβొ࣌ɺҰ࣌తͳೝূίʔυΛൃߦ͢Δ ͜ͱͰ༗ޮͳѼઌͰ͋Δ͜ͱΛ֬ೝ • ϝοηʔδͷςϯϓϨʔτฤूՄೳ • MFAͷઃఆ͕Մೳ ࣮ફserverless #cmdevio
25
σόΠετϥοΩϯά • ಉҰϢʔβ͕ϩάΠϯঢ়ଶΛҡ࣋Ͱ͖Δ ͷઃఆ • ༗ޮʹ͢ΔͱɺॳճϩάΠϯ࣌ʹೝূͱผʹ τϥοΩϯά༻్ͷτʔΫϯ͕σόΠε͝ͱʹ ൃߦ͞ΕΔ • τϥοΩϯά͕༗ޮͳMFAΛεΩοϓ͢
Δ͜ͱͰ͖Δ ࣮ફserverless #cmdevio 26
σόΠετϥοΩϯά • ཧऀɺSDKඇެ։ͷREST API͔ΒσόΠε ϦετΛऔಘͰ͖Δ • Global Sign-out(ಉҰϢʔβͷશαΠϯΞ τ)ཧऀݖݶͰͷαΠϯΞτՄೳ ࣮ફserverless
#cmdevio 27
App • ඇೝূϢʔβ͕ϩάΠϯύεϫʔυ࠶ൃߦͳ ͲͷAPIΛ࣮ߦ͢ΔͨΊͷΤϯςΟςΟ • TokenͱSecretɻϒϥβΞϓϦSecretΛ Θͳ͍͜ͱͰ͖Δ ࣮ફserverless #cmdevio 28
App • ྫ͑ϓϥοτϑΥʔϜ͝ͱͳͲɺෳ࡞Մ ೳ • Relying PartyͷΑ͏ͳෆಛఆͷୈࡾऀʹఏڙ͢ Δ༻్ͰΘͳ͍ ࣮ફserverless #cmdevio
29
Trigger • ॴఆͷΠϕϯτΛτϦΨʔʹͯ͠Lambda Functionͷ࣮ߦ͕Մೳ • ηΩϡϦςΟػೳͷΧελϚΠζɺΠϕϯτ τϥοΩϯάͳͲ༷ʑͳ֦ு͕Մೳ ࣮ફserverless #cmdevio 30
Cognito Identity࿈ܞ • Federated IdentityͷϓϩόΠμͱͯ͠ར༻Մ ೳ • User PoolsೝূϢʔβʹରͯ͠AWSϦιʔε ͷΞΫηεݖݶΛ҆શʹൃߦͰ͖Δ
࣮ફserverless #cmdevio 31
࣮ફserverless #cmdevio 32
API Gateway࿈ܞ • API GatewayͰͷೝՄͰɺUser Poolsͷೝূ ใΛར༻Ͱ͖Δ • API GatewayͷϚωδϝϯτίϯιʔϧ͔Β
User PoolΛઃఆ͢Δ ࣮ફserverless #cmdevio 33
࣮ફserverless #cmdevio 34
CognitoΛ ࣮ࡍʹ͏ͨΊʹ ࣮ફserverless #cmdevio 35
ϙϦγʔม • CognitoʹׂΓͯΒΕΔIDʹҰக͢ΔϦιʔ εͷΈͷݖݶൃߦ • αʔόΛհ͞ͳ͍ॲཧΛ҆શʹߦ͑Δ • IAMͷConditionઅʹมΛهࡌ ࣮ફserverless #cmdevio
36
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [
"dynamodb:Query" ], "Resource": [ "arn:aws:dynamodb:ap-northeast-1:<Account ID>:table/projects", "arn:aws:dynamodb:ap-northeast-1:<Account ID>:table/projects/index/*" ], "Condition": { "ForAllValues:StringEquals": { "dynamodb:LeadingKeys": [ "${cognito-identity.amazonaws.com:sub}" ] } } } ] } ࣮ફserverless #cmdevio 37
S3ͷ߹5 { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action":
["s3:ListBucket"], "Resource": ["arn:aws:s3:::EXAMPLE-BUCKET-NAME"], "Condition": {"StringLike": {"s3:prefix": ["cognito/mynumbersgame/"]}} }, { "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject" ], "Resource": [ "arn:aws:s3:::EXAMPLE-BUCKET-NAME/cognito/mynumbersgame/${cognito-identity.amazonaws.com:sub}", "arn:aws:s3:::EXAMPLE-BUCKET-NAME/cognito/mynumbersgame/${cognito-identity.amazonaws.com:sub}/*" ] } ] } 5 http://docs.aws.amazon.com/jajp/IAM/latest/UserGuide/accesspolicies_examples.html#iam- policy-example-cognito ࣮ફserverless #cmdevio 38
͜ͷΑ͏ͳม͕ར༻Մೳ3 • ${cognito-identity.amazonaws.com:sub} • ${www.amazon.com:user_id} • ${accounts.google.com:sub} • ${graph.facebook.com:id} 3
http://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/specifying- conditions.html http://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/ WIF.RunningYourApp.html ࣮ફserverless #cmdevio 39
OIDC Provider • Web/UserPoolsͷଞʹFederated Identityʹઃ ఆՄೳͳIdentity Provider • GoogleSalseforceͳͲ •
IAMʹOIDC ProviderΛՃ͠ɺFederated Identityʹઃఆ͢Δ • SAML͑ΔΑ͏ʹͳΓ·ͨ͠ ࣮ફserverless #cmdevio 40
࣮ફserverless #cmdevio 41
େྔϦΫΤετ࣌ͷ੍ݶ • ʮ1 ͭͷϦετ/API ࢀরݺͼग़͠ͷ࠷େ 60ʯ4 • ΞϓϦ͔Βͷݺͼग़͠ͷ੍ݶແ͍ʁ • ؒҧ͑ͯผϦʔδϣϯΛݺͼ·ͬͯͨ࣌͘
ʹʮ੍ݶ͠ͱ͍ͨΑʯͱݴΘΕͨ 4 http://docs.aws.amazon.com/ja_jp/cognito/latest/developerguide/limits.html ࣮ફserverless #cmdevio 42
Trust Relationship • ͲͷTokenൃߦऀʹରͯ͠Assume RoleΛڐՄ ͢Δ͔ͷϙϦγʔ • cognitoͷΟβʔυ͔ΒRoleΛ࡞ΔͱͪΌΜ ͱઃఆ͞Ε͍ͯΔ •
ࣗͰฤू͢ΔͱϋϚΔͷͰҙ AccessDenied -- Not authorized to perform sts:AssumeRoleWithWebIdentity ࣮ફserverless #cmdevio 43
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": {
"Federated": "cognito-identity.amazonaws.com" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "cognito-identity.amazonaws.com:aud": "us-east-1:aaaa-bbbb-cccc-dddd-1111-2222" }, "ForAnyValue:StringLike": { "cognito-identity.amazonaws.com:amr": "authenticated" } } } ] } ࣮ફserverless #cmdevio 44
• audͰCognito Identity Pool IDΛࢦఆ • amrͰϓϩόΠμΛࢦఆ • ྫ͑facebookͷ߹ "ForAnyValue:StringLike":
{ "cognito-identity.amazonaws.com:amr": "graph.facebook.com" } ࣮ફserverless #cmdevio 45
·ͱΊ ࣮ફserverless #cmdevio 46
• User PoolsͰೝূػೳΛAWSʹҠͤΔ • Cognito Identityͱ࿈ܞͯ͠ߋʹػೳΛAWSʹ ҠͤΔ • ࣗͷϏδωεʹԊ͏ΓํͰαʔόϨεʹ ͔͍ͬͯ͜͏
࣮ફserverless #cmdevio 47
End ࣮ફserverless #cmdevio 48