cis14: working with oauth and openid connect

54
OAuth 2.0 and OpenID Connect Basics From OAuth2 to OpenID Connect by Roland Hedberg

Upload: cloudidsummit

Post on 18-May-2015

1.279 views

Category:

Technology


4 download

DESCRIPTION

Roland Hedberg, Umeå University All you need to know about OpenID Connect, with concrete examples and hands-on demos that illustrate how OpenID Connect can be used in web and mobile scenarios.

TRANSCRIPT

Page 1: CIS14: Working with OAuth and OpenID Connect

OAuth 2.0 and OpenID Connect Basics

From OAuth2 to OpenID Connect by Roland Hedberg

Page 2: CIS14: Working with OAuth and OpenID Connect

Let’s start with OAuth2

Page 3: CIS14: Working with OAuth and OpenID Connect

❖ The OAuth 2.0 authorization framework enables a third-party application to obtain limited access to an HTTP service, !

❖ either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service, !

❖ or by allowing the third-party application to obtain access on its own behalf.

Page 4: CIS14: Working with OAuth and OpenID Connect

The players

Authorization Server

Resource ServerClient

Page 5: CIS14: Working with OAuth and OpenID Connect

Authorization Request

Authorization Server

Resource ServerClient

Authorization request

Page 6: CIS14: Working with OAuth and OpenID Connect

Authorization Request - detailsParameters!

client_id!

redirect_uri!

response_type!

scope!

state

Authorization Server

Resource ServerClient

Authorization request

GET!http://example.com/authorization?state=1521671980316802035&!! redirect_uri=https://example.org/authz_cb&!! response_type=code&!! client_id=SFEBuhC7sp3a

Page 7: CIS14: Working with OAuth and OpenID Connect

Authorization Server

Resource ServerClient

AUTHENTICATION HAPPENS&

End-user consent/authorization

Page 8: CIS14: Working with OAuth and OpenID Connect

Authorization Response

Authorization Server

Resource ServerClient

Authorization response

Page 9: CIS14: Working with OAuth and OpenID Connect

Authorization Response - detailsAuthorization Server

Resource ServerClient

Authorization response

GET!https://example.org/authz_cb?state=1521671980316802035&!! code=s87BT60pp2UbNX2HnkWpZ9YhPVHRZaoTuU9XJul6JMuQaKUidUM6y1Boab6

Parameters

code!state

access_token!token_type!expires_in!

scope!state

Page 10: CIS14: Working with OAuth and OpenID Connect

Access Token Request

Authorization Server

Resource ServerClient

Access token request

Page 11: CIS14: Working with OAuth and OpenID Connect

Access Token Request - details

POST!http://example.com/token!!code=s87BT60pp2UbNX2HnkWpZ9YhPVHRZaoTuU9XJul6JMuQaKUidUM6y1Boab6&!! grant_type=authorization_code&!! redirect_uri=https://example.org/authz_cb

Authorization Server

Resource ServerClient

Access token request

Parameters!

client_id!

code!

grant_type!

redirect_uri

Page 12: CIS14: Working with OAuth and OpenID Connect

Access Token Response

Authorization Server

Resource ServerClient

Access token response

Page 13: CIS14: Working with OAuth and OpenID Connect

Access Token Response - details

{!! 'access_token': ’s87BT60pp2UbNX2HnkWpfPfWNo9Gi7chACuWoa2IDND', !! 'expires_in': 3600, !! 'refresh_token': ’s87BT60pp2U+bNX2HnkWpVCnDYPsy8EOpI’!! 'state': ’STATE0’,!! 'token_type': 'Bearer', !}

Authorization Server

Resource ServerClient

Access token response

Parameters!access_token!

expires_in!refresh_token

scope!token_type

Page 14: CIS14: Working with OAuth and OpenID Connect

Resource Access

Authorization Server

Resource ServerClient

Resource request/response

Page 15: CIS14: Working with OAuth and OpenID Connect

Resource Access - detailsAuthorization Server

Resource ServerClient

Resource request/response

GET!https://example.com/resource!!Header:!! Authorization: ’Bearer s87BT60pp2UbNX2HnkWpfPfWNo9Gi7chACuWoa2IDND’!

Page 16: CIS14: Working with OAuth and OpenID Connect

The wholeAuthorization Server

Resource ServerClient

Authorization request

Authorization Server

Resource ServerClient

Authorization response

Authorization Server

Resource ServerClient

Access token request

Authorization Server

Resource ServerClient

Access token responseAuthorization Server

Resource ServerClient

Resource request/response

Authorization Server

Resource ServerClient

AUTHENTICATION HAPPENS&

End-user consent/authorization

Page 17: CIS14: Working with OAuth and OpenID Connect

Flows

❖ Authorization Code Grant!

❖ Implicit Grant!

❖ Resource Owner Password Credentials Grant!

❖ Client Credentials Grant

Page 18: CIS14: Working with OAuth and OpenID Connect

Implicit grantAuthorization Server

Resource ServerClient

Authorization request

Authorization Server

Resource ServerClient

Resource request/response

Authorization Server

Resource ServerClient

Authorization response

Authorization Server

Resource ServerClient

AUTHENTICATION HAPPENS&

End-user consent/authorization

Page 19: CIS14: Working with OAuth and OpenID Connect

Resource Owner Password Credentials Grant &

Client Credentials Grant

Authorization Server

Resource ServerClient

Access token request

Authorization Server

Resource ServerClient

Access token response

Authorization Server

Resource ServerClient

Resource request/response

Page 20: CIS14: Working with OAuth and OpenID Connect

From OAuth2 to OpenID Connect

Page 21: CIS14: Working with OAuth and OpenID Connect

❖ OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0 protocol. !

❖ It enables Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server, as well as to obtain basic profile information about the End-User in an interoperable and REST-like manner.

Page 22: CIS14: Working with OAuth and OpenID Connect

The differences

❖ Only authorization grant and implicit grant flows!

❖ Dynamic provider discovery and client registration!

❖ ID Token!

❖ Additions/Clarifications/Constrictions!

❖ UserInfo endpoint

Page 23: CIS14: Working with OAuth and OpenID Connect

Flows

❖ Authorization code!

❖ Implicit!

❖ Hybrid (authorization code with a twist)!❖ code id_token!❖ code token!❖ code id_token token

Page 24: CIS14: Working with OAuth and OpenID Connect

Dynamic provider discovery and client registration

Page 25: CIS14: Working with OAuth and OpenID Connect

Dynamic discovery and registration

1. Find the provider!

2. Discover provider info!

3. Register client

Page 26: CIS14: Working with OAuth and OpenID Connect

1.Find the provider ❖ Webfinger (RFC 7033)!

❖ User identifier -> URL!

[email protected] ->!

!

GET /.well-known/webfinger?!

resource=acct:[email protected]&!

rel=http://openid.net/specs/connect/1.0/issuer!

HTTP/1.1!

Host: example.com

Page 27: CIS14: Working with OAuth and OpenID Connect

Webfinger responseHTTP/1.1 200 OK! Access-Control-Allow-Origin: *! Content-Type: application/jrd+json!! {! "subject" : "acct:[email protected]",! "links" :! [ {! "rel" : "http://openid.net/specs/connect/1.0/issuer",! "href" : "https://openid.example.com"! } ]! }

Page 28: CIS14: Working with OAuth and OpenID Connect

2.Discover provider info - query

GET /.well-known/openid-configuration HTTP/1.1!Host: openid.example.com

Page 29: CIS14: Working with OAuth and OpenID Connect

2. Discover provider info - response

❖ issuer!

❖ jwks_uri!

❖ endpoints!

❖ functions supported!

❖ support for signing/encrypting algorithms!

❖ policy/tos

Page 30: CIS14: Working with OAuth and OpenID Connect

Required information❖ issuer!

❖ jwks_uri!

❖ authorization_endpoint!

❖ token_endpoint (*)!

❖ response_types_supported!

❖ subject_types_supported!

❖ id_token_signing_alg_supported

Page 31: CIS14: Working with OAuth and OpenID Connect

3. Client registration

❖ uris!

❖ application information!

❖ support for signing/encrypting algorithms!

❖ key material!

❖ server behavior!

❖ client behavior

Page 32: CIS14: Working with OAuth and OpenID Connect

required information

❖ redirect_uris

Page 33: CIS14: Working with OAuth and OpenID Connect

Client registration response

❖ client_id!

❖ possibly client_secret and if so client_secret_experies_at!

❖ and the Authorization servers view of things

Page 34: CIS14: Working with OAuth and OpenID Connect

An Authorization Server

❖ MAY add fields the client didn’t include.!

❖ MAY reject or replace any of the Client's requested field values and substitute them with suitable values.!

❖ MAY ignore values provided by the client, and MUST ignore any fields sent by the Client that it does not understand.

Page 35: CIS14: Working with OAuth and OpenID Connect

A Client can not

❖ modify a registration!

❖ delete a registration

Page 36: CIS14: Working with OAuth and OpenID Connect

ID Token

Page 37: CIS14: Working with OAuth and OpenID Connect

ID Token

❖ Have to make a detour into JWT/K/A/S/E land

Page 38: CIS14: Working with OAuth and OpenID Connect

JWT

❖ Jason Web Token!

❖ a compact URL-safe means of representing claims to be transferred between two parties!

❖ Suggested pronunciation: ’jot’

Page 39: CIS14: Working with OAuth and OpenID Connect

JWS

represents content secured with digital signatures or Message Authentication Codes (MACs) using JavaScript Object Notation (JSON) based data structures.

JWErepresents encrypted content using JavaScript Object Notation (JSON) based data structures.

Page 40: CIS14: Working with OAuth and OpenID Connect

JWK

a JavaScript Object Notation (JSON) data structure that represents a cryptographic key

JWAregisters cryptographic algorithms and identifiers to be used with the JSON Web Signature(JWS), JSON Web Encryption (JWE), and JSON Web Key (JWK) specifications

Page 41: CIS14: Working with OAuth and OpenID Connect

ID Token

❖a security token that contains Claims about the Authentication of an End-User by an Authorization Server when using a Client, and potentially other requested Claims. !

❖is represented as a JSON Web Token (JWT)

Page 42: CIS14: Working with OAuth and OpenID Connect

ID Token claims -required❖ iss - Issuer Identifier for the Issuer of the response!

❖ sub - Subject Identifier!

❖ aud - Intended audience!

❖ exp - Expiration time!

❖ iat - Issued at!

❖ auth_time - Authentication time!

❖ nonce

Page 43: CIS14: Working with OAuth and OpenID Connect

ID Token claims - optional

❖ acr - Authentication Context Class Reference!

❖ amr - Authentication Method References!

❖ azp - Authorized party

Page 44: CIS14: Working with OAuth and OpenID Connect

Additions/Clarifications/Constrictions

Page 45: CIS14: Working with OAuth and OpenID Connect

OAuth2 Authorization Request - detailsParameters!

client_id!

redirect_uri!

response_type!

scope!

state

Authorization Server

Resource ServerClient

Authorization request

GET!http://example.com/authorization?state=1521671980316802035&!! redirect_uri=https://example.org/authz_cb&!! response_type=code&!! client_id=SFEBuhC7sp3a

Page 46: CIS14: Working with OAuth and OpenID Connect

Authentication Request - OpenID Connect extensions

❖ response_mode - The mechanism to use for returning parameters!

❖ nonce - Associates client session with ID Token!

❖ Signed/encrypted Authentication Request!

❖ End-user interactions!

❖ Response details

Page 47: CIS14: Working with OAuth and OpenID Connect

Signed/encrypted Authentication Request

❖ request - by value!

❖ request_uri - by reference!

!

❖ Single self-contained parameter!

❖ Signed and/or encrypted (JWT)

Page 48: CIS14: Working with OAuth and OpenID Connect

End-user interactions❖ display - How to display pages to End-User!

❖ prompt - If the End-User should be prompted for re-authentication/consent!

❖ max_age - allowed max time since last authentication!

❖ ui_locales - End-User’s preferred languages and scripts!

❖ id_token_hint - ID Token previously issued !

❖ login_hint - login identifier the End-User might want to use!

❖ acr_values - requested Authentication Context Class Reference values

Page 49: CIS14: Working with OAuth and OpenID Connect

Response details❖ claims!

❖ user_info!

❖ id_token!

!

❖ claims specification!

❖ null!

❖ essential!

❖ value!

❖ values

Page 50: CIS14: Working with OAuth and OpenID Connect

UserInfo endpoint

Page 51: CIS14: Working with OAuth and OpenID Connect

User info

❖ sub!

❖ name!

❖ given_name!

❖ family_name!

❖ middle_name!

❖ nickname!

❖ preferred_username

Set of standard claims

❖ profile!

❖ picture!

❖ website!

❖ email!

❖ email_verified!

❖ gender!

❖ birthdate

❖ zoneinfo!

❖ locale!

❖ phone_number!

❖ phone_number_verfied!

❖ address!

❖ updated_at!

Page 52: CIS14: Working with OAuth and OpenID Connect

claims types

❖ Normal!

❖ Aggregated!

❖ Distributed

Page 53: CIS14: Working with OAuth and OpenID Connect

Summary

❖ OAuth2 is about authorization!

❖ OpenID Connect adds authentication and identity information

Page 54: CIS14: Working with OAuth and OpenID Connect

Questions ?