mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-03 21:02:15 +00:00
## Todos for release - [x] Configure Env in docs project on vercel - [x] Configure Root Path in the docs project on vercel - [ ] Remove old CSP https://github.com/zitadel/website/pull/1592 ## What we did This pull request migrates the project documentation from the old `docs/` directory to the new `apps/docs/` directory, introduces a new documentation system built with Next.js and Fumadocs, and updates all relevant references, configuration files, and documentation to reflect this change. It also adds new configuration and ignore files for the new documentation app, updates CI and linting to exclude the new docs from certain checks, and revises the contributing guidelines accordingly. **Documentation System Migration and New Docs App** * Migrated all documentation from `docs/` to `apps/docs/`, and updated all references in `README.md`, `CONTRIBUTING.md`, and other files to point to the new location. [[1]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L585-L640) [[2]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L660-R607) [[3]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L740-R687) [[4]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L2-R3) [[5]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L30-R30) * Added a new Next.js/Fumadocs-based documentation app under `apps/docs/`, including core app files, layouts, routing, search API, and a comprehensive `README.md` with development and contribution instructions. [[1]](diffhunk://#diff-5a1b07344a2c1b4d3f37b23ff1388b62cd9f57dea3c1cd23d8a0412b7602b132R1-R74) [[2]](diffhunk://#diff-462b9ad1eabbb7d1c29bb9c36e4931eb180fd7190900e6d2babf8f4d66ad1c28R1-R39) [[3]](diffhunk://#diff-e16ae25660ded787b10ac35dea96d5ecaacf895dae0afc8a9bd4382dc79a8c87R1-R7) [apps/docs/app/[[...slug]]/layout.tsxR1-R81](diffhunk://#diff-59e08acde4e805b7aeccef1dcf98f1d71dfc550777e6b9402085cee0e9fa4e0aR1-R81), [apps/docs/app/[[...slug]]/page.tsxR1-R79](diffhunk://#diff-e5df3f80d0fa01e12d63d81f29c57a9d14e846c78fd3beabb2ef768e38fd9580R1-R79), [[4]](diffhunk://#diff-389b34918e040cacaa87cd7201ffa462cc2b0b716736f537e3d3c660ac69353bR1-R7) [[5]](diffhunk://#diff-d3b03416d1c457b19f1c27b26f2db741412df841b875c26ccadc36e4522247f4R1-R29) [[6]](diffhunk://#diff-c8fb8339570a5305809be7c618e14705fd86390dc278e6ce8ba224a7bc8b0c3cR1-R25) **Configuration and Tooling Updates** * Updated `.github/workflows/codeql.yml`, `.golangci.yaml`, and `.github/dependabot.yml` to properly handle the new docs app: excluded `apps/docs` from certain checks, added npm dependency updates for the docs app, and excluded generated content. [[1]](diffhunk://#diff-12783128521e452af0cfac94b99b8d250413c516ec71fe6d97dbea666ff7ba27L8-R14) [[2]](diffhunk://#diff-9917ddc9f1c3304218f7269265b746d997c5c0615478177b5fceecd33ef47cb5R5-R6) [[3]](diffhunk://#diff-9917ddc9f1c3304218f7269265b746d997c5c0615478177b5fceecd33ef47cb5R126-R129) [[4]](diffhunk://#diff-dd4fbda47e51f1e35defb9275a9cd9c212ecde0b870cba89ddaaae65c5f3cd28R89-R106) * Updated `.devcontainer/devcontainer.json` to use the latest Go 1.25.3 version for consistency. **Licensing and Miscellaneous** * Added `apps/docs/` to the list of licensed directories in `LICENSING.md`. These changes ensure the documentation is now maintained in a modern, scalable system and all project tooling is updated to support the new structure. --------- Co-authored-by: Federico Coppede <[email protected]>
166 lines
7.1 KiB
Plaintext
166 lines
7.1 KiB
Plaintext
---
|
|
title: Support for the Device Authorization Grant in a Custom Login UI
|
|
sidebar_label: Device Authorization
|
|
---
|
|
|
|
In case one of your applications requires the [OAuth2 Device Authorization Grant](/guides/integrate/login/oidc/device-authorization) this guide will show you how to implement
|
|
this in your application as well as the custom login UI.
|
|
|
|
The following flow shows you the different components you need to enable OAuth2 Device Authorization Grant for your login.
|
|

|
|
|
|
1. Your application makes a device authorization request to your login UI
|
|
2. The login UI proxies the request to ZITADEL.
|
|
3. ZITADEL parses the request and does what it needs to interpret certain parameters (e.g., organization scope, etc.)
|
|
4. ZITADEL returns the device authorization response
|
|
5. Your application presents the `user_code` and `verification_uri` or maybe even renders a QR code with the `verification_uri_complete` for the user to scan
|
|
6. Your application starts a polling mechanism to check if the user has approved the device authorization request on the token endpoint
|
|
7. When the user opens the browser at the verification_uri, he can enter the user_code, or it's automatically filled in, if they scan the QR code
|
|
8. Request the device authorization request from the ZITADEL API using the user_code
|
|
9. Your login UI allows to approve or deny the device request
|
|
10. In case they approved, authenticate the user in your login UI by creating and updating a session with all the checks you need.
|
|
11. Inform ZITADEL about the decision:
|
|
1. Authorize the device authorization request by sending the session and the previously retrieved id of the device authorization request to the ZITADEL API
|
|
2. In case they denied, deny the device authorization from the ZITADEL API using the previously retrieved id of the device authorization request
|
|
12. Notify the user that they can close the window now and return to the application.
|
|
13. Your applications request to the token endpoint now receives the tokens or an error if the user denied the request.
|
|
|
|
## Example
|
|
|
|
Let's assume you host your login UI on the following URL:
|
|
```
|
|
https://login.example.com
|
|
```
|
|
|
|
## Device Authorization Request
|
|
|
|
A user opens your application and is unauthenticated, the application will create the following request:
|
|
```http
|
|
POST /oauth/v2/device_authorization HTTP/1.1
|
|
Host: login.example.com
|
|
Content-type: application/x-www-form-urlencoded
|
|
|
|
client_id=170086824411201793&
|
|
scope=openid%20email%20profile
|
|
```
|
|
|
|
The request includes all the relevant information for the OAuth2 Device Authorization Grant and in this example we also have some scopes for the user.
|
|
|
|
You now have to proxy the auth request from your own UI to the device authorization Endpoint of ZITADEL.
|
|
For more information, see [OIDC Proxy](./login-app#oidc-proxy) for the necessary headers.
|
|
|
|
<Callout>
|
|
The version and the optional custom URI for the available login UI is configurable under the application settings.
|
|
</Callout>
|
|
|
|
The endpoint will return the device authorization response:
|
|
```json
|
|
{
|
|
"device_code": "0jbAZbU3ClK-Mkt0li4U1A",
|
|
"user_code": "FWRK-JGWK",
|
|
"verification_uri": "https://login.example.com/device",
|
|
"verification_uri_complete": "https://login.example.com/device?user_code=FWRK-JGWK",
|
|
"expires_in": 300,
|
|
"interval": 5
|
|
}
|
|
```
|
|
|
|
The device presents the `user_code` and `verification_uri` or maybe even render a QR code with the `verification_uri_complete` for the user to scan.
|
|
|
|
Your login will have to provide a page on the `verification_uri` where the user can enter the `user_code`, or it's automatically filled in, if they scan the QR code.
|
|
|
|
### Get the Device Authorization Request by User Code
|
|
|
|
With the user_code entered by the user you will now be able to get the information of the device authorization request.
|
|
[Get Device Authorization Request Documentation](/reference/api/oidc/zitadel.oidc.v2.OIDCService.GetDeviceAuthorizationRequest)
|
|
|
|
```bash
|
|
curl --request GET \
|
|
--url https://${CUSTOM_DOMAIN}/v2/oidc/device_authorization/FWRK-JGWK \
|
|
--header 'Authorization: Bearer '"$TOKEN"''
|
|
```
|
|
|
|
Response Example:
|
|
|
|
```json
|
|
{
|
|
"deviceAuthorizationRequest": {
|
|
"id": "XzNejv6NxqVU8Qur5uxEh7f_Wi1p0qUu4PJTJ6JUIx0xtJ2uqmU",
|
|
"clientId": "170086824411201793",
|
|
"scope": [
|
|
"openid",
|
|
"profile"
|
|
],
|
|
"appName": "TV App",
|
|
"projectName": "My Project"
|
|
}
|
|
}
|
|
```
|
|
|
|
Present the user with the information of the device authorization request and allow them to approve or deny the request.
|
|
|
|
### Perform Login
|
|
|
|
After you have initialized the OIDC flow you can implement the login.
|
|
Implement all the steps you like the user the go trough by [creating](/reference/api/session/zitadel.session.v2.SessionService.CreateSession) and [updating](/reference/api/session/zitadel.session.v2.SessionService.SetSession) the user-session.
|
|
|
|
Read the following resources for more information about the different checks:
|
|
- [Username and Password](./username-password)
|
|
- [External Identity Provider](./external-login)
|
|
- [Passkeys](./passkey)
|
|
- [Multi-Factor](./mfa)
|
|
|
|
### Authorize the Device Authorization Request
|
|
|
|
To finalize the auth request and connect an existing user session with it, you have to update the auth request with the session token.
|
|
On the create and update user session request you will always get a session token in the response.
|
|
|
|
The latest session token has to be sent to the following request:
|
|
|
|
Read more about the [Authorize or Deny Device Authorization Request Documentation](/reference/api/oidc/zitadel.oidc.v2.OIDCService.AuthorizeOrDenyDeviceAuthorization)
|
|
|
|
Make sure that the authorization header is from an account which is permitted to finalize the Auth Request through the `IAM_LOGIN_CLIENT` role.
|
|
```bash
|
|
curl --request POST \
|
|
--url ${CUSTOM_DOMAIN}/v2/oidc/device_authorization/XzNejv6NxqVU8Qur5uxEh7f_Wi1p0qUu4PJTJ6JUIx0xtJ2uqmU \
|
|
--header 'Accept: application/json' \
|
|
--header 'Authorization: Bearer '"$TOKEN"''\
|
|
--header 'Content-Type: application/json' \
|
|
--data '{
|
|
"session": {
|
|
"sessionId": "225307381909694508",
|
|
"sessionToken": "7N5kQCvC4jIf2OuBjwfyWSX2FUKbQqg4iG3uWT-TBngMhlS9miGUwpyUaN0HJ8OcbSzk4QHZy_Bvvv"
|
|
}
|
|
}'
|
|
```
|
|
|
|
If you don't get any error back, the request succeeded, and you can notify the user that they can close the window now and return to the application.
|
|
|
|
### Deny the Device Authorization Request
|
|
|
|
If the user denies the device authorization request, you can deny the request by sending the following request:
|
|
|
|
```bash
|
|
curl --request POST \
|
|
--url ${CUSTOM_DOMAIN}/v2/oidc/device_authorization/ \
|
|
--header 'Accept: application/json' \
|
|
--header 'Authorization: Bearer '"$TOKEN"''\
|
|
--header 'Content-Type: application/json' \
|
|
--data '{
|
|
"deny": {}
|
|
}'
|
|
```
|
|
|
|
If you don't get any error back, the request succeeded, and you can notify the user that they can close the window now and return to the application.
|
|
|
|
### Device Authorization Endpoints
|
|
|
|
All OAuth2 Device Authorization Grant endpoints are provided by ZITADEL. In your login UI you just have to proxy them through and send them directly to the backend.
|
|
|
|
These endpoints are:
|
|
- Well-known
|
|
- Device Authorization Endpoint
|
|
- Token
|
|
|
|
Additionally, we recommend you to proxy all the other [OIDC relevant endpoints](./oidc-standard#oidc-endpoints).
|