oauth

25
OAuth introduce by 木木

Upload: -

Post on 25-Jun-2015

38 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Oauth

OAuthintroduce by 木酱

Page 2: Oauth

Why OAuth ?

Page 3: Oauth

If without OAuth?

Page 4: Oauth

“We want something like Flickr Auth / Google AuthSub / Yahoo! BBAuth, but published as an open standard, with

common server and client libraries”

– Blaine Cook, April 5th, 2007

Page 5: Oauth

April 2010

The OAuth 1.0 Protocol http://tools.ietf.org/html/rfc5849

Page 6: Oauth

client

server

protected

resource

client credentialstemporary credentials

verifier

temporary credentials serv

erownerclient

temporary credentials & verifiertoken

credentials

client

resource

client & token credentials

server

the resource

Page 7: Oauth

Problems

Page 8: Oauth

Sign Very Time

Server App Only

Permanent Access

Page 9: Oauth

Temporary Credential Request: consumer

key、 signature_method、 timestamp、 nonce、 signature

Resource Owner Authorization: temporary token

Token Request: consumer key、 signature method、 timestamp、 nonce、 signature、 temporary

token、 verifier

Resource Request: consumer key、 access token、 signature

method、 timestamp、 nonce、 signature

Page 10: Oauth

Temporary Credential Request: consumer

key、 signature_method、 timestamp、 nonce、 signature

Resource Owner Authorization: temporary token

Token Request: consumer key、 signature method、 timestamp、 nonce、 signature、 temporary

token、 verifier

Resource Request: consumer key、 access token、 signature

method、 timestamp、 nonce、 signature

Page 11: Oauth

Sign Very Time

Server App Only

Permanent Access

Page 12: Oauth

October 2012

The OAuth 2.0 Authorization Framework

http://tools.ietf.org/html/rfc6749

Page 13: Oauth

protected

resource verifi

er

client

server

client credentialstemporary credentialstemporary credentials serv

erownerclient

temporary credentials & verifiertoken

credentials

client

resource

client & token credentials

server

client_id

auth codeauth code

token & expires time & refresh token

Refresh Access Token If Expired

the resource

token

Page 14: Oauth

Web Server APPBrowser Based APPUsername/Password AccessApplication AccessMobile APP

authorization_codeimplicitpasswordclient_credentialsimplicit

Page 15: Oauth

+----------+ | resource | | owner | | | +----------+ ^ | (B) +----|-----+ Client Identifier +---------------+ | -+----(A)-- & Redirection URI ---->| | | User- | | Authorization | | Agent -+----(B)-- User authenticates --->| Server | | | | | | -+----(C)-- Authorization Code ---<| | +-|----|---+ +---------------+ | | ^ v (A) (C) | | | | | | ^ v | | +---------+ | | | |>---(D)-- Authorization Code ---------' | | Client | & Redirection URI | | | | | |<---(E)----- Access Token -------------------' +---------+ (w/ Optional Refresh Token)

+----------+ | resource | | owner | | | +----------+ ^ | (B) +----|-----+ Client Identifier +---------------+ | -+----(A)-- & Redirection URI ---->| | | User- | | Authorization | | Agent -+----(B)-- User authenticates --->| Server | | | | | | -+----(C)-- Authorization Code ---<| | +-|----|---+ +---------------+ | | ^ v (A) (C) | | | | | | ^ v | | +---------+ | | | |>---(D)-- Authorization Code ---------' | | Client | & Redirection URI | | | | | |<---(E)----- Access Token -------------------' +---------+ (w/ Optional Refresh Token)

Page 16: Oauth

+----------+ | Resource | | Owner | | | +----------+ ^ | (B) +----|-----+ Client Identifier +---------------+ | -+----(A)-- & Redirection URI --->| | | User- | | Authorization | | Agent -|----(B)-- User authenticates -->| Server | | | | | | |<---(C)--- Redirection URI ----<| | | | with Access Token +---------------+ | | in Fragment | | +---------------+ | |----(D)--- Redirection URI ---->| Web-Hosted | | | without Fragment | Client | | | | Resource | | (F) |<---(E)------- Script ---------<| | | | +---------------+ +-|--------+ | | (A) (G) Access Token | | ^ v +---------+ | | | Client | | | +---------+

+----------+ | Resource | | Owner | | | +----------+ ^ | (B) +----|-----+ Client Identifier +---------------+ | -+----(A)-- & Redirection URI --->| | | User- | | Authorization | | Agent -|----(B)-- User authenticates -->| Server | | | | | | |<---(C)--- Redirection URI ----<| | | | with Access Token +---------------+ | | in Fragment | | +---------------+ | |----(D)--- Redirection URI ---->| Web-Hosted | | | without Fragment | Client | | | | Resource | | (F) |<---(E)------- Script ---------<| | | | +---------------+ +-|--------+ | | (A) (G) Access Token | | ^ v +---------+ | | | Client | | | +---------+

Page 17: Oauth

+----------+ | Resource | | Owner | | | +----------+ v | Resource Owner (A) Password Credentials | v +---------+ +---------------+ | |>--(B)---- Resource Owner ------->| | | | Password Credentials | Authorization | | Client | | Server | | |<--(C)---- Access Token ---------<| | | | (w/ Optional Refresh Token) | | +---------+ +---------------+

+----------+ | Resource | | Owner | | | +----------+ v | Resource Owner (A) Password Credentials | v +---------+ +---------------+ | |>--(B)---- Resource Owner ------->| | | | Password Credentials | Authorization | | Client | | Server | | |<--(C)---- Access Token ---------<| | | | (w/ Optional Refresh Token) | | +---------+ +---------------+

Page 18: Oauth

+---------+ +---------------+ | | | | | |>--(A)- Client Authentication --->| Authorization | | Client | | Server | | |<--(B)---- Access Token ---------<| | | | | | +---------+ +---------------+

+---------+ +---------------+ | | | | | |>--(A)- Client Authentication --->| Authorization | | Client | | Server | | |<--(B)---- Access Token ---------<| | | | | | +---------+ +---------------+

Page 19: Oauth

风险

Page 20: Oauth

Unbounded tokens无绑定 token

Page 21: Oauth

Bearer tokens无记名 token

Page 22: Oauth

Expiring tokenstoken失效

Page 23: Oauth

CSRF with attacker code

Page 24: Oauth

Q&A

Page 25: Oauth

You Are Welcome!