feat: device authorization by QR or short code
PHP's device flow on golem15_user_device_auth_sessions (PHP's columns,
the token stored as its SHA-256, plus jwt_jti): POST /devices/initiate
answers a 64-character token, an XXXX-XXXX short code, the configurable
auth_url (golem15.user.device_auth.auth_url) and the expiry; a signed-in
user authorizes it with POST /devices/authorize (short_code or token,
one guarded pending-to-confirmed UPDATE); the device's first poll of
GET /devices/status/{token} after that receives a session JWT through one
guarded confirmed-to-used UPDATE, so exactly one poll gets it. Used and
revoked sessions never turn into expired; each initiate deletes a bounded
batch of stale sessions.
This commit is contained in:
@@ -97,9 +97,11 @@ func TestPasswordPublicRoutes(t *testing.T) {
|
||||
}
|
||||
// 18 routes up to v0.1.9, plus GET /backend-link/{code}, POST
|
||||
// /backend-link/show and POST /backend-link/confirm (the account link),
|
||||
// GET /token/me and GET /tokens/scopes.
|
||||
if len(base) != 23 {
|
||||
t.Fatalf("unset: %d routes, want 23", len(base))
|
||||
// GET /token/me and GET /tokens/scopes, plus POST /devices/initiate,
|
||||
// GET /devices/status/{token} and POST /devices/authorize (device
|
||||
// authorization).
|
||||
if len(base) != 26 {
|
||||
t.Fatalf("unset: %d routes, want 26", len(base))
|
||||
}
|
||||
seen := 0
|
||||
for _, route := range base {
|
||||
@@ -111,8 +113,8 @@ func TestPasswordPublicRoutes(t *testing.T) {
|
||||
t.Fatalf("unset: found %d of the password routes, want %d", seen, len(passwordRouteKeys))
|
||||
}
|
||||
off := withoutPasswordRoutes(base)
|
||||
if len(off) != 20 {
|
||||
t.Fatalf("base without the password routes has %d routes, want 20", len(off))
|
||||
if len(off) != 23 {
|
||||
t.Fatalf("base without the password routes has %d routes, want 23", len(off))
|
||||
}
|
||||
|
||||
for _, c := range []struct {
|
||||
|
||||
Reference in New Issue
Block a user