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

OAuth 2 for Me and You - 2022 Edition

OAuth 2 for Me and You - 2022 Edition

This session was given at the Adobe ColdFusion Summit 2022 in Las Vegas, Monday October 3rd, 2022.

It covered the OAuth 2 protocol, what it means to be a consumer or provider, and how to navigate the handshake communications between the service. At the end of this session all attendees walked taller, safe in the fact that they understand OAuth 2, how to use it, and what it all means.

Matt Gifford

October 07, 2022
Tweet

More Decks by Matt Gifford

Other Decks in Technology

Transcript

  1. OAUTH 2 FOR ME AND YOU Matt Gi ff ord

    - Adobe ColdFusion Summit 2022
  2. THE SETLIST ➤ OAuth? ➤ Important De fi nitions ➤

    How to be a consumer ➤ The Authorization Code Flow ➤ Useful Tools
  3. THE SCENARIO I am writing a web-based application for lovers

    of music. I want to access data from third-party services to enhance my application.
  4. THE SCENARIO I am going to use Spotify to build

    a fun project that can generate dynamic playlists for the authenticating user.
  5. THE SCENARIO My application will need to log into Spotify

    on behalf of my users to access their account information and have write access to their playlists.
  6. A delegation framework to allow secure authorization in a simple

    and standard method from web, mobile and desktop applications WHAT IS OAUTH?
  7. A delegation framework to allow secure authorization in a simple

    and standard method from web, mobile and desktop applications WHAT IS OAUTH?
  8. A BRIEF HISTORY 2006 Twitter Chief Architect looked for a

    better authentication method - no passwords 2007 OpenID development group (and contributors) came up with the OAuth 1 first draft 2007 7 updated drafts by the end of the year 2009 OAuth 2.0 spec was started “.. to clear up many of the aspects of OAuth 1 that were difficult or confusing.” 2012 OAuth 2.0 core spec was published There were MANY more revisions to the draft
  9. My Application Spotify Authorization Server Spotify Resource Server THE WORKFLOW

    https://accounts.spotify.com/authorize? client_id=0170ed62bfad4dcc90bd5b057787790e&code_challenge=1assIs_OhqosI koRWb8MopQ9hqHN9gj8HF4HXd06U2U&code_challenge_method=S256&state=A 7CC19EA-D207-414D-9C6C6083A5E1237D&redirect_uri=http:// myapp.local:10539/callback/&scope=playlist-modify-public%20playlist-modify- public%20user-read-email%20user-follow-modify&response_type=code
  10. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request THE WORKFLOW LINK HREF https://accounts.spotify.com/authorize
  11. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request THE WORKFLOW https://accounts.spotify.com/authorize? client_id=0170ed62bfad4dcc90bd5b057787790e LINK HREF
  12. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request https://accounts.spotify.com/authorize? client_id=0170ed62bfad4dcc90bd5b057787790e &response_type=code LINK HREF THE WORKFLOW
  13. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request https://accounts.spotify.com/authorize? client_id=0170ed62bfad4dcc90bd5b057787790e &response_type=code &redirect_uri=https://myapp.local:10538/callback LINK HREF THE WORKFLOW
  14. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request https://accounts.spotify.com/authorize? client_id=0170ed62bfad4dcc90bd5b057787790e &response_type=code &redirect_uri=https://myapp.local:10538/callback &scope=playlist-modify-public user-read-email LINK HREF THE WORKFLOW
  15. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request https://accounts.spotify.com/authorize? client_id=0170ed62bfad4dcc90bd5b057787790e &response_type=code &redirect_uri=https://myapp.local:10538/callback &scope=playlist-modify-public user-read-email &state=9DC18EB2-3B79-4E05-904BD9E6590267C2 LINK HREF THE WORKFLOW
  16. My Application Spotify Do you give permission for My Application

    to access your basic profile information? No Yes Spotify Authorization Server Spotify Resource Server User Authorization Request THE WORKFLOW
  17. User Authorization Request Authorization Code Grant My Application Spotify Authorization

    Server Spotify Resource Server https://myapp.local:10538/callback?code=AUTHORIZATION_CODE https://myapp.local:10538/callback?error=XXX THE WORKFLOW
  18. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request THE WORKFLOW Authorization Code Grant Access Token Request
  19. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request REQUESTING AN ACCESS TOKEN Authorization Code Grant Access Token Request
  20. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request REQUESTING AN ACCESS TOKEN Authorization Code Grant Access Token Request POST https://accounts.spotify.com/token
  21. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request REQUESTING AN ACCESS TOKEN Authorization Code Grant Access Token Request POST grant_type=authorization_code https://accounts.spotify.com/token
  22. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request REQUESTING AN ACCESS TOKEN Authorization Code Grant Access Token Request POST grant_type=authorization_code code=33160 https://accounts.spotify.com/token
  23. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request REQUESTING AN ACCESS TOKEN Authorization Code Grant Access Token Request POST grant_type=authorization_code code=33160 redirect_uri=https://myapp.local:10538/callback https://accounts.spotify.com/token
  24. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request REQUESTING AN ACCESS TOKEN Authorization Code Grant Access Token Request POST grant_type=authorization_code code=33160 redirect_uri=https://myapp.local:10538/callback client_id=a3dd5f928fb04a1f8b5f7bdd3dbd3010 https://accounts.spotify.com/token
  25. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request REQUESTING AN ACCESS TOKEN Authorization Code Grant Access Token Request POST grant_type=authorization_code code=33160 redirect_uri=https://myapp.local:10538/callback client_id=a3dd5f928fb04a1f8b5f7bdd3dbd3010 client_secret=e6b218b3a4cb46d8a11578b8a60f55fb https://accounts.spotify.com/token
  26. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request RECEIVING THE ACCESS TOKEN Authorization Code Grant Access Token Request Access Token Grant
  27. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request RECEIVING THE ACCESS TOKEN Authorization Code Grant Access Token Request Access Token Grant
  28. User Authorization Request Authorization Code Grant Access Token Request Access

    Token Grant Authenticated API Request Protected Resources My Application Spotify Authorization Server Spotify Resource Server ACCESSING RESOURCES
  29. User Authorization Request Authorization Code Grant Access Token Request Access

    Token Grant Authenticated API Request Protected Resources My Application Spotify Authorization Server Spotify Resource Server Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 ACCESSING RESOURCES
  30. User Authorization Request Authorization Code Grant Access Token Request Access

    Token Grant Authenticated API Request Protected Resources My Application Spotify Authorization Server Spotify Resource Server ACCESSING RESOURCES
  31. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request PKCE https://accounts.spotify.com/authorize? client_id=0170ed62bfad4dcc90bd5b057787790e &response_type=code &redirect_uri=https://myapp.local:10538/callback &scope=playlist-modify-public user-read-email &state=9DC18EB2-3B79-4E05-904BD9E6590267C2
  32. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request PKCE https://accounts.spotify.com/authorize? client_id=0170ed62bfad4dcc90bd5b057787790e &response_type=code &redirect_uri=https://myapp.local:10538/callback &scope=playlist-modify-public user-read-email &state=9DC18EB2-3B79-4E05-904BD9E6590267C2 &code_challenge=tZSYs8eBdSGBJpDo3wOPaj729KNWR &code_challenge_method=S256
  33. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request PKCE code_challenge=tZSYs8eBdSGBJpDo3wOPaj729KNWR code_challenge_method=S256
  34. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request PKCE POST grant_type=authorization_code code=10538 redirect_uri=https://myapp.local:10538/callback client_id=a3dd5f928fb04a1f8b5f7bdd3dbd3010 client_secret=e6b218b3a4cb46d8a11578b8a60f55fb https://accounts.spotify.com/token code_verifier=1XxTnj2kNC2Szytqp7WDck3jVUD61nu5KwtQQJBIL_HIH6R3
  35. My Application Spotify Authorization Server Spotify Resource Server User Authorization

    Request PKCE base64url( sha256( code_verifier ) ) = code_challenge ?
  36. HEADER PAYLOAD SIGNATURE JWT { "alg": "HS256", "typ": "JWT" }

    eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp XVCJ9.
  37. HEADER PAYLOAD SIGNATURE JWT { "alg": "HS256", "typ": "JWT" }

    { "iat": 1508158112, "iss": "https://test.monkehserver.com/oauth/token", "sub": 1000, "exp": 1508161712, "scope": "read-private write", "aud": "BF23473E-A6AA-477D-ADDEB3A6DC24D28E" } eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp XVCJ9. eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp XVCJ9.eyJpYXQiOjE1MDgxNTgx MTIsImlzcyI6Imh0dHBzOi8vdGVz dC5tb25rZWhzZXJ2ZXIuY29tL29 hdXRoL3Rva2VuIiwic3ViIjoxMDA wLCJleHAiOjE1MDgxNjE3MTIsIn Njb3BlIjoicmVhZC1wcml2YXRlIH dyaXRlIiwiYXVkIjoiQkYyMzQ3M0 UtQTZBQS00NzdELUFEREVCM0E 2REMyNEQyOEUifQ.
  38. HEADER PAYLOAD SIGNATURE JWT { "alg": "HS256", "typ": "JWT" }

    { "iat": 1508158112, "iss": "https://test.monkehserver.com/oauth/token", "sub": 1000, "exp": 1508161712, "scope": "read-private write", "aud": "BF23473E-A6AA-477D-ADDEB3A6DC24D28E" } HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), secret ) eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp XVCJ9.eyJpYXQiOjE1MDgxNTgx MTIsImlzcyI6Imh0dHBzOi8vdGVz dC5tb25rZWhzZXJ2ZXIuY29tL29 hdXRoL3Rva2VuIiwic3ViIjoxMDA wLCJleHAiOjE1MDgxNjE3MTIsIn Njb3BlIjoicmVhZC1wcml2YXRlIH dyaXRlIiwiYXVkIjoiQkYyMzQ3M0 UtQTZBQS00NzdELUFEREVCM0E 2REMyNEQyOEUifQ. eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp XVCJ9.eyJpYXQiOjE1MDgxNTgx MTIsImlzcyI6Imh0dHBzOi8vdGVz dC5tb25rZWhzZXJ2ZXIuY29tL29 hdXRoL3Rva2VuIiwic3ViIjoxMDA wLCJleHAiOjE1MDgxNjE3MTIsIn Njb3BlIjoicmVhZC1wcml2YXRlIH dyaXRlIiwiYXVkIjoiQkYyMzQ3M0 UtQTZBQS00NzdELUFEREVCM0E 2REMyNEQyOEUifQ.n4b0VpKAgf 0BPVPKxjsep9TtqyoexcnygrSek Wu2KV4
  39. OAUTH 2.1 ➤ PKCE REQUIRED for ALL OAuth clients using

    authorisation code fl ow ➤ Redirect URI values MUST use exact-string matching ➤ Bearer token usage omits the use of bearer tokens in the query string of URIs ➤ Refresh Tokens for public clients must either be sender-constrained or one-time use (mobile apps and JavaScript apps)
  40. OAUTH 2 FOR ME AND YOU Matt Gi ff ord

    - Adobe ColdFusion Summit 2022 THANK YOU!