You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/internals.md
+72Lines changed: 72 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,3 +104,75 @@ stateDiagram-v2
104
104
```
105
105
106
106
> **Note** This file is automatically generated by the `bin/structure.jl` script.
107
+
108
+
## Device flow authentication
109
+
110
+
Device flow authentication enables an application to authenticate a user by providing a link that can be opened on another device where the user can proceed with authentication. The application will be able to check whether the user has completed authentication on the other device by calling certain APIs. Finally, the application can retrieve the users OAuth token via the same API call. Device flow authentication becomes necessary on devices that do not have a browser based interface for regular login or applications that are not browser based such as command line applications. More details [here](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow).
111
+
112
+
### Working of device flow in PkgAuthentication.jl
113
+
114
+
We first call the dex [openid-configuration](https://dexidp.io/docs/openid-connect/) endpoint to determine whether the Pkg server supports device authentication. When device authentication is supported by the Pkg server we call the `/dex/device/code` endpoint. When the Pkg server does not support device authentication we fall back to the legacy browser authentication flow. The state machine for both flows are exactly the same (see diagram above). Only the http requests are different. The request and response for device code endpoint looks like:
The `verfication_uri_complete` value is opened in the browser for the user so that they can continue logging in. As in the legacy browser flow which calls `/claimtoken` to poll for completion of authentication, we call `/dex/token` when device authentication is available.
We generate content for the `auth.toml` file with these values. We add some extra key/values to auth.toml when device authentication is enabled:
174
+
-`client: "device"` This will help us distinguish between device authenticated auth.toml's and legacy auth.toml's.
175
+
-`expires_at: <expires_in> + <time()>` This value is required to determine whether the token is expired and needs refresh. This is missing in the token response so we add it by summing the `expires_in` in value with the current timestamp.
176
+
-`refresh_url` This value is also missing in the device token response but is necessary for refreshing expired tokens. We create this field with value `<server>/auth/renew/token.toml/device/`.
177
+
178
+
The mechanism to refresh the token is the same as in the legacy browser authentication flow.
0 commit comments