Slide 1

Slide 1 text

How to use Amazon Cognito user pools with custom UI and also OIDC Kenichiro Kimura [AWS Community Builders] [JAWS-UG Fukuoka]

Slide 2

Slide 2 text

Who am I Name: Kenichiro Kimura Country: Japan / Fukuoka Occupation: Technical Architect Company: Alterbooth,INC Award: - AWS APJ Community Leaders Award 2023 - AWS Samurai 2019 Community: - JAWS-UG Fukuoka(organizer) - AWS Community Builders @show_m001 kenichirou.kimura 2

Slide 3

Slide 3 text

Conclusion -You can use OIDC endpoint for Amazon Cognito user pools with custom UI, by using AWS Amplify Identity broker -There are some limitations: - Missing functions need to be developed by yourself - Cannot use fully OIDC functions -If you want to use custom UI and OIDC at the same time in Cognito user pools, please try it. 3

Slide 4

Slide 4 text

What is Cognito user pools? An Amazon Cognito user pool is a user directory for web and mobile app authentication and authorization. From the perspective of your app, an Amazon Cognito user pool is an OpenID Connect (OIDC) identity provider (IdP). (https://docs.aws.amazon.com/en_us/cognito/latest/developerguide/cognito-user-identity-pools.html) 4

Slide 5

Slide 5 text

OIDC Authorization flow with Cognito user pools 5 GET /oauth2/authorize?redirect_uri={redirect_uri}.. Location: /login?redirect_uri={redirect_uri}… GET /login?redirect_uri={redirect_uri}… (hosted UI Page) (Sign in) Location: {redirect_uri}?id_token=eyXXXXX

Slide 6

Slide 6 text

About hosted UI What is hosted UI? -UI prepared in Cognito User pools for flows such as sign- in and sign-up. -You can customize hosted UI, but limited looks only - Upload logo image - Use custom css 6

Slide 7

Slide 7 text

Customize login flow(sign-up/sign-in...) To customize your login flow(sign-up/sign-in/forgot password/reset-password…), - Develop UI using Cognito SDK - Cognito user pools’ OIDC endpoints are not available What should we do to use OIDC endpoints with custom UI ? - Develop your own OIDC endpoints? 7

Slide 8

Slide 8 text

AWS Amplify Identity Broker A code sample provided as an illustration of how to achieve and identity broker and SSO on top of Amazon Cognito by awslabs. https://github.com/awslabs/aws-amplify-identity-broker/ 8

Slide 9

Slide 9 text

Features -Login flows: sign-in, sign-up, forgot password, reset- password -Is a standard OIDC Identity Provider -PKCE and Implicit Oauth2 flows -100% UI customizable(React + Amplify JS) -I18n -Federations: Social login, SAML, OIDC 9

Slide 10

Slide 10 text

Architecture 10

Slide 11

Slide 11 text

OIDC Authorization flow with Identity Broker(1) 11 GET /oauth2/authorize?redirect_uri={redirect_uri}.. Location: /?redirect_uri={redirect_uri}… GET /?redirect_uri={redirect_uri}… (React UI Page) (Sign in) Tokens or code Check session API Call POST /storage Location: {redirect_uri}?id_token=eyXXXXX

Slide 12

Slide 12 text

OIDC Authorization flow with Identity Broker(2) 12 GET /oauth2/authorize?redirect_uri={redirect_uri}.. Location: https://server/?redirect_uri={redirect_uri}… GET /some-uri?redirect_uri={redirect_uri}… (Original UI Page) (Sign in) Tokens or code Check session API Call Redirect with Tokens or code Location: {redirect_uri}?id_token=eyXXXXX POST /storage

Slide 13

Slide 13 text

Features which not implemented -Authorization endpoint - HTTP POST - scope parameter - response_type(only id_token and code, currently) - Other OPITONAL features - display, prompt, id_token_hint,… -Token endpoint - http response header(Cache-control: no-store) 13

Slide 14

Slide 14 text

Limitation You can’t use nonce parameter -Nonce is OPTIONAL function in oidc documents - But it is REQUIRED if you use implicit flow -Nonce must be in id token signed by idp - Only idp can manipulates id token -Cognito API does not allow the providing of a nonce - Hosted UI can provide a nonce - Use PKCE flow instead of implicit flow 14

Slide 15

Slide 15 text

Conclusion -You can use OIDC endpoint for Amazon Cognito user pools with custom UI, by using AWS Amplify Identity broker. -There are some limitations: - Missing functions need to be developed by yourself - Cannot use fully OIDC functions, such as nonce parameter -Limited Support by AWS -If you want to use custom UI and OIDC at the same time in Cognito user pools, please try it out. 15

Slide 16

Slide 16 text

Thank you! Thank you for your attention 16