Commit 8fb7292
committed
refactor(server): extract the device flow into its own package
Move the OAuth2 device authorization grant (RFC 8628) out of the god Server
into a server/device package, following the router.Handler pattern:
- server/device holds a Handler that mounts /device, /device/code,
/device/auth/verify_code, /device/callback and the deprecated /device/token,
and exposes HandleToken for the device_code grant. It holds only its
dependencies (storage, templates, issuer URL, timing, logger) plus the shared
ExchangeAuthCode and CalculateCodeChallenge callbacks and a RenderError
callback, so it does not depend on the whole Server.
- newServer (the composition root) builds the handler as a local and wires it in
two places: the mount list, and the /token endpoint, which receives the
device_code grant as a parameter instead of the Server building or holding the
handler itself.
- The PKCE code-challenge method names move to the oauth2 package as
PKCEMethodPlain/PKCEMethodS256, next to the rest of the protocol vocabulary.
No behaviour change. The device unit test covers the verification URI; the
end-to-end device tests keep exercising the wired routes through the server.
Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com>1 parent cf4ab8b commit 8fb7292
12 files changed
Lines changed: 560 additions & 537 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | 19 | | |
42 | 20 | | |
43 | 21 | | |
| |||
135 | 113 | | |
136 | 114 | | |
137 | 115 | | |
138 | | - | |
| 116 | + | |
139 | 117 | | |
140 | 118 | | |
141 | 119 | | |
| |||
0 commit comments