Resource Owner: 일반적인 사용자 (리소스 소유자)
client: 서비스 제공자
Authorization Server: 인증을 담당하는 서버 (ex: 깃헙 인증 서버)
Resource Server: 리소스를 가지고 있고 클라이언트에게 제공해주는 서버 (ex. 깃헙 데이터 서버)
유저(Resource Owner) <-> 서버(Client) <-> Third Party (1. Authorization server 2. Resource server)
+--------+ +---------------+
| |--(A)- Authorization Request ->| Resource |
| | | Owner |
| |<-(B)-- Authorization Grant ---| |
| | +---------------+
| |
| | +---------------+
| |--(C)-- Authorization Grant -->| Authorization |
| Client | | Server |
| |<-(D)----- Access Token -------| |
| | +---------------+
| |
| | +---------------+
| |--(E)----- Access Token ------>| Resource |
| | | Server |
| |<-(F)--- Protected Resource ---| |
+--------+ +---------------+
Figure 1: Abstract Protocol Flow
+----------+
| 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)
Build the Authorization URL (Client -> Resource Owner -> Authorization Server) GET
Verify the state parameter (Authorization Server -> Resource Owner -> Client)
리다이렉션은 브라우저에 먼저 전달되고, 브라우저가 client에게 전달되는 flow
Exchange the Authorization Code (Client -> Authorization Server) POST
Get Access Token (Authorization Server -> Client)
client가 header에 access token을 넣고 리소스 요청을 보내면 Resource server는 토큰이 올바르고, 만료기한 이내일 때 리소스를 응답한다.
code
: 유저에게 받은 허가증! 액토 주세요!
access token
: Authorization 서버에게 받은 허가증! 리소스 주세요!
+--------+ +---------------+
| |--(A)------- Authorization Grant --------->| |
| | | |
| |<-(B)----------- Access Token -------------| |
| | & Refresh Token | |
| | | |
| | +----------+ | |
| |--(C)---- Access Token ---->| | | |
| | | | | |
| |<-(D)- Protected Resource --| Resource | | Authorization |
| Client | | Server | | Server |
| |--(E)---- Access Token ---->| | | |
| | | | | |
| |<-(F)- Invalid Token Error -| | | |
| | +----------+ | |
| | | |
| |--(G)----------- Refresh Token ----------->| |
| | | |
| |<-(H)----------- Access Token -------------| |
+--------+ & Optional Refresh Token +---------------+