🏠 | 💻 IT | Cybersecurity |

OAuth

Terminology

In this example user hase images on Google Drive and wants to print them at some external Printing Service

Protected Resource - images on Google Drive

Resource Owner - user who owns images, he has access to Protected Resource and he can grant access rights

Resource Server - service where Protected Resource is stored. In this example it is Google Drive

Client - application that needs to access Protected Resource on behalf of the Resource owner and with its authorization. In this example it is Printing Service

Authorization Server - service responsible for authorized acces to Protected Resource. It is issuing Access Tokens to the Client

Workflow

Authorization Code Flow

Brief Description

Source Destination Message / Action
Resource Owner Client Do something with my Protected Resource
Client Authorization Server Need access to Protected Resource
Authorization Server Resource Owner Should I give access to your Protected Resource?
Resource Owner Authorization Server Yes
Authorization Server Client Authorization Token
Client Authorization Server Authorization Token
+ Give me
Access Token
Authorization Server Client Access Token
Client Resource Server Access Token + Give me access to Protected Resource
Resource Server Client Access to Protected Resource

1) Пользователь (Resource Owner) обращается к клиенту (Client) с запросом о печате своих фото (Protected Resource) с Google Drive (Resource Server)

User: …«Напечатай фотографии»… → Client

2) Printing Service (Client) обращается к Authorization Server с сообщением о том, что ему нужно распечатать фотоки пользователя (Resource Owner) и передаёт данные о пользователе и о фотографиях, доступ к которым ему нужен.

Client: … «Нужен доступ к таким-то фотографиям этого пользователя»… → Authorization Server

3) Authorization Server обращается к Resource Owner и сообщает, что Client запросил доступ к Protected Resourse и хочет выполнить определённые действия. Вопрос - согласен ли на это Resource Owner

Authorization Server: …«Согласен ли ты разрешить определённые действия с Protected Resource?»… → Resource Owner

4) Resource Owner отвечает, что всё ОК

Resource Owner: …« Да, я согласен предоставить определённый доступ к определённым Protected Resource»… → Authorization Server

5) Authorizaion Server отправляет клиенту (Client) Authorization Token . Обычно это короткоживущий токен.

Authorization Server: …Authorization Token… → Client

6) Client запрашивает у Autorization Server Access Token . К этому запросу он присоединяет полученный ранее Authorization Token .

Client: …« Дай мне Access Token у меня есть Authorization Token, вот он: » + Authorization Token… → Authorization Server

7) Authorizaion Server проверяет Authorization Token и отправляет на Client Access Token

Authorization Server: …Access Token… → Client

8) Client и отправляет на Resource Server Access Token и запрашивает доступ к Protected Resource

Client: …«Дай мне доступ к Protected Resource, у меня есть Access Token вот он:» + Access Token … → Resource Server

9) Resource Server проверяет Access Token и выдает Client доступ к Protected Resource

Resource Server: … Доступ к Protected Resource … → Client

Share in social media: