Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OAuth2 & OpenID Connect - VNINFO talk

OAuth2 & OpenID Connect - VNINFO talk

Avatar for Son Nguyen Kim

Son Nguyen Kim

August 08, 2019

Other Decks in Programming

Transcript

  1. OUTLINE ▸ OAuth 2.0 ▸ Context ▸ Code flow ▸

    Implicit flow ▸ Future ▸ OpenID Connect (OIDC) ▸ A bit of history ▸ OpenID Connect vs OAuth
  2. ▸ Complex terminology, WTF is resource owner, authorization grant? ▸

    Too much incorrect resources ▸ Too many versions
  3. FLOW (USE CASE) ▸ Backend: code flow ▸ Front-end only,

    Native app: implicit flow ▸ User password: support old app ▸ Client credential: backend to backend call
  4. FLOW (USE CASE) ▸ Backend: code flow ▸ Front-end only,

    Native app: implicit flow ▸ User password: support old app ▸ Client credential: backend to backend call
  5. User App: Contact Manager Identity Provider: Facebook 1) User goes

    to an app, clicks on 2) User redirected to Facebook, accept sharing data with app 3) App receives "Grant", exchange for having user contacts 4) Contact import successful! FLOW
  6. 1) User goes to an app, clicks on 2) User

    redirected to Facebook, accept sharing data with app 3) App receives "Grant", exchange for having user contacts 4) Contact import successful! CODE FLOW facebook.com/oauth?response_type=code& client_id=1234& redirect_uri=http://app/callback scope=email& state=random_string http://app/callback?code=secret_code facebook.com/token?code=secret_code access_token facebook.com/contacts?access_token=access_token [ { name: "first last", email: "[email protected]" }, { name: "John Wick", email: "[email protected]" } ] BACKEND TO BACKEND INSIDE BROWSER User App: Contact Manager Identity Provider: Facebook
  7. User App Identity Provider 1) User goes to an app,

    clicks on 2) User redirected to Facebook, accept sharing data with app 3) App receives "Access Token", exchange for having user contacts 4) Contact import successful! IMPLICIT FLOW facebook.com/oauth?response_type=token& client_id=1234& redirect_uri=http://app/callback scope=email& state=random_string http://app/callback?access_token=secret facebook.com/contacts?access_token=access_token [ { name: "first last", email: "[email protected]" }, { name: "John Wick", email: "[email protected]" } ] INSIDE BROWSER
  8. FUTURE ▸ Backend: code flow ▸ Front-end only, Native app:

    implicit flow ▸ User password: support old app ▸ Client credential: backend to backend call PKCE CODE FLOW
  9. TEXT USING OAUTH FOR AUTHENTICATION IS A HACK ▸ No

    standard to get user info ▸ Different implementation
  10. User App Identity Provider 1) User goes to an app,

    clicks on 2) User redirected to Facebook, accept sharing data with app 3) App receives "Code", exchange for having user information: email, name, ... 4) User is logged in OPENID CONNECT CODE FLOW facebook.com/oauth?response_type=code& client_id=1234& redirect_uri=http://app/callback scope=email& state=random_string http://app/callback?code=secret_code facebook.co/token?code=secret_code ID_TOKEN BACKEND TO BACKEND INSIDE BROWSER
  11. User App Identity Provider 1) User goes to an app,

    clicks on 2) User redirected to Facebook, accept sharing data with app 3) App receives "Access Token" and "ID Token", exchange for having user information: email, name, ... 4) User is logged in OPENID CONNECT IMPLICIT FLOW facebook.com/oauth?response_type=code& client_id=1234& redirect_uri=http://app/callback scope=email& state=random_string http://app/callback?access_token=secret&id_token=jwt INSIDE BROWSER
  12. OPENID IS FOR HUMANS LOGGING INTO MACHINES, OAUTH IS FOR

    MACHINES LOGGING INTO MACHINES ON BEHALF OF HUMANS. whoami