Skip to content

Commit d3d0128

Browse files
zepatrikvinckr
authored andcommitted
chore: address review comments and format
1 parent 0279663 commit d3d0128

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

docs/oauth2-oidc/device-authorization.mdx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,26 @@ title: Device Authorization
44
sidebar_label: Device authorization flow
55
---
66

7-
The OAuth 2.0 Device Authorization Grant (RFC 8628) brings OAuth to devices with internet connectivity but limited input
8-
capabilities. This flow is designed for smart TVs, streaming devices, IoT hardware, printers, remote terminal sessions, AI agents, and other connected devices
9-
where typing credentials or opening a browser isn't practical or possible. Here's how it works: the device to be authenticated displays a URL and a short code, prompting
10-
you to open that URL on your phone or computer to authorize access. After successful authorization, the device will get an access and (optionally) a refresh token. The two devices don't need to communicate directly—the authorization
11-
happens through the OAuth provider.
7+
The OAuth 2.0 Device Authorization Grant (RFC 8628) brings OAuth to devices with internet connectivity but limited input
8+
capabilities. This flow is designed for smart TVs, streaming devices, IoT hardware, printers, remote terminal sessions, AI agents,
9+
and other connected devices where typing credentials or opening a browser isn't practical or possible. Here's how it works: the
10+
device to be authenticated displays a URL and a short code, prompting you to open that URL on your phone or computer to authorize
11+
access. After successful authorization, the device will get an access and (optionally) a refresh token. The two devices don't need
12+
to communicate directly—the authorization happens through the OAuth provider.
1213

13-
This document provides an overview of the Ory's device authorization grant flow, with a step-by-step example of its implementation, configuration
14-
options, and guidance on creating custom user interfaces for the verification screen.
14+
This document provides an overview of the Ory's device authorization grant flow, with a step-by-step example of its
15+
implementation, configuration options, and guidance on creating custom user interfaces for the verification screen.
1516

1617
## Overview of the flow
1718

1819
Here is the high-level overview for the device authorization grant flow:
1920

2021
1. The user attempts to log in to the device. This initiates the device to request authorization from the authorization server.
21-
1. When the authorization server responds, the user is instructed to visit a URL and enter the provided user code, which they do
22+
1. When the authorization server responds, the user is instructed to visit a URL and enter the provided user code, which they do
2223
on a different device.
2324
1. On the different device the user visits the URL, enters the user code, (logs in, if needed) and grants access to the device.
24-
1. In the meantime, the device polls the authorization server. Once the user authenticates and grants access, the authenicaton server
25-
sends an access token to the device, which is used to access the protected resource.
25+
1. In the meantime, the device polls the authorization server. Once the user authenticates and grants access, the authenicaton
26+
server sends an access token to the device, which is used to access the protected resource.
2627

2728
```mdx-code-block
2829
import Mermaid from "@site/src/theme/Mermaid";
@@ -59,8 +60,8 @@ import Mermaid from "@site/src/theme/Mermaid";
5960

6061
### Step 1: Device requests authorization
6162

62-
The user attempts to log in through the limited input device. The device sends a POST request to the authorization server to initiate
63-
the flow with the following parameters:
63+
The user attempts to log in through the limited input device. The device sends a POST request to the authorization server to
64+
initiate the flow with the following parameters:
6465

6566
- `client_id`: The ID of the client (device) that's making the request
6667
- `scope` (optional): The scope of the access request, which specifies which resources the requesting device can access
@@ -76,12 +77,13 @@ The authorization server responds with the following information:
7677

7778
### Step 2: Display user code and verification URI
7879

79-
The device shows the user the `user_code` and `verification_uri` it received from the authorization server. Depending on the device, this can be in the form of a URL, QR-code, acoustically, or any other form that the device can communicate with the user.
80+
The device shows the user the `user_code` and `verification_uri` it received from the authorization server. Depending on the
81+
device, this can be in the form of a URL, QR-code, acoustically, or any other form that the device can communicate with the user.
8082

8183
### Step 3: User grants permission
8284

83-
The user visits the provided URI on a separate device, such as a phone, and enters the code. Once the user enters the code,
84-
the user is prompted to log in, if not already authenticated, and grants or denies permission to the client (device). After granting
85+
The user visits the provided URI on a separate device, such as a phone, and enters the code. Once the user enters the code, the
86+
user is prompted to log in, if not already authenticated, and grants or denies permission to the client (device). After granting
8587
permission, the user is redirected to a page confirming they are successfully logged in.
8688

8789
### Step 4: Device polls for the access token
@@ -93,7 +95,8 @@ user has completed the authorization process, by making a POST request with the
9395
- `device_code`: The device code returned from the authorization request
9496
- `grant_type`: This must always be `urn:ietf:params:oauth:grant-type:device_code`
9597

96-
After the user grants their consent, the authentication server sends an access token to the device, which is used to access the protected resource.
98+
After the user grants their consent, the authentication server sends an access token to the device, which is used to access the
99+
protected resource.
97100

98101
## Configuration options
99102

@@ -112,14 +115,29 @@ urls:
112115
113116
### Configuring user code entropy
114117
115-
Depending on your security needs and your traffic load, you should choose the appropriate `user_code` entropy. The
118+
Depending on your security needs and your traffic load, you should choose the appropriate `user_code` entropy. The
116119
`oauth2.device_authorization.user_code.entropy_preset` configuration supports 3 values:
117120

118121
- `high`: `user_code` is 8 characters long and consists of alphanumeric characters, excluding some ambiguous symbols
119122
- `medium`: `user_code` is 8 characters long and consists of only upper case alphabetic characters
120-
- `low`: `user_code` is 9 characters long and consists of only numberic characters
123+
- `low`: `user_code` is 9 characters long and consists of only numeric characters
121124

122-
As users will need to manually enter the user code, the higher the entropy, the more difficult it will be for the user to enter the user code.
125+
It is also possible to configure the length and character set directly:
126+
127+
```yaml
128+
oauth2:
129+
device_authorization:
130+
user_code:
131+
length: 8
132+
character_set: abcdefghijklmnopqrstuvwxyz0123456789
133+
```
134+
135+
It is important to strike the right balance between security and user-experience here. Higher entropy enhances security and
136+
protects against an attacker randomly guessing valid user-codes. This is especially important the more concurrent device flows are
137+
being performed. As users will need to manually enter the user code, the higher the entropy, the more difficult it will be for the
138+
user to enter the user code. For better user-experience ambiguous characters should be avoided (e.g. `O` and `0` on any display,
139+
or `1` and `7` on a 7-segment display). This is not of any concern when the user doesn't need to input the user-code manually,
140+
e.g. by scanning a QR-code.
123141

124142
## Device verification UI implementation
125143

0 commit comments

Comments
 (0)