@fabrika/iam 0.9.0-dev.32 → 0.9.0-dev.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fabrika.config.ts +47 -7
- package/migrations/0032_second_factor.sql +29 -0
- package/migrations/0033_oauth_grant_resources.sql +6 -0
- package/migrations/0034_oauth_device_authorizations.sql +24 -0
- package/migrations-postgres/0032_second_factor.sql +29 -0
- package/migrations-postgres/0033_oauth_grant_resources.sql +6 -0
- package/migrations-postgres/0034_oauth_device_authorizations.sql +24 -0
- package/package.json +12 -10
- package/src/admin/api-keys.ts +15 -5
- package/src/admin/grant-support.ts +10 -0
- package/src/admin/grants.ts +5 -2
- package/src/admin/handlers.ts +3 -0
- package/src/admin/principals.ts +2 -5
- package/src/admin/rpc.ts +8 -0
- package/src/admin/second-factor.ts +39 -0
- package/src/admin/sessions.ts +4 -4
- package/src/app.ts +1 -1
- package/src/auth/failure.ts +5 -0
- package/src/auth/http.ts +1 -1
- package/src/auth/invitations.ts +11 -3
- package/src/auth/login.ts +3 -2
- package/src/auth/oidc.ts +1 -1
- package/src/auth/password.ts +6 -6
- package/src/auth/routes.ts +11 -3
- package/src/auth/second-factor-challenge.ts +114 -0
- package/src/auth/second-factor.ts +276 -0
- package/src/auth/sessions.ts +72 -21
- package/src/auth.ts +19 -4
- package/src/catalog/cs.ts +32 -0
- package/src/catalog/en.ts +33 -0
- package/src/catalog/index.ts +28 -0
- package/src/catalog/uk.ts +33 -0
- package/src/data-key.ts +92 -0
- package/src/db.ts +12 -1
- package/src/env.ts +15 -2
- package/src/node/runtime.ts +7 -0
- package/src/oauth-client-auth.ts +6 -2
- package/src/oauth-config.ts +5 -5
- package/src/oauth-device-page.ts +173 -0
- package/src/oauth-device.ts +265 -0
- package/src/oauth-http.ts +53 -7
- package/src/oauth.ts +105 -37
- package/src/oidc-session.ts +25 -0
- package/src/repositories/audit.ts +4 -2
- package/src/repositories/oauth.ts +171 -4
- package/src/repositories/second-factors.ts +165 -0
- package/src/repositories/sessions.ts +17 -9
- package/src/second-factor-pages.ts +129 -0
- package/src/services.ts +11 -2
- package/src/tokens.ts +3 -3
- package/src/totp.ts +132 -0
- package/types/src/admin/api-keys.d.ts +3 -3
- package/types/src/admin/grant-support.d.ts +2 -0
- package/types/src/admin/handlers.d.ts +3 -0
- package/types/src/admin/second-factor.d.ts +5 -0
- package/types/src/auth/failure.d.ts +10 -0
- package/types/src/auth/http.d.ts +1 -1
- package/types/src/auth/invitations.d.ts +2 -1
- package/types/src/auth/password.d.ts +1 -1
- package/types/src/auth/second-factor-challenge.d.ts +34 -0
- package/types/src/auth/second-factor.d.ts +19 -0
- package/types/src/auth/sessions.d.ts +22 -9
- package/types/src/auth.d.ts +9 -3
- package/types/src/catalog/index.d.ts +28 -0
- package/types/src/data-key.d.ts +19 -0
- package/types/src/db.d.ts +4 -1
- package/types/src/env.d.ts +15 -2
- package/types/src/oauth-config.d.ts +3 -3
- package/types/src/oauth-device-page.d.ts +7 -0
- package/types/src/oauth-device.d.ts +51 -0
- package/types/src/oauth-http.d.ts +5 -2
- package/types/src/oauth.d.ts +34 -8
- package/types/src/oidc-session.d.ts +12 -0
- package/types/src/repositories/audit.d.ts +2 -1
- package/types/src/repositories/oauth.d.ts +48 -1
- package/types/src/repositories/second-factors.d.ts +68 -0
- package/types/src/repositories/sessions.d.ts +7 -3
- package/types/src/rpc-inputs.d.ts +23 -23
- package/types/src/second-factor-pages.d.ts +42 -0
- package/types/src/services.d.ts +4 -0
- package/types/src/totp.d.ts +32 -0
package/types/src/auth/http.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare function stringValue(value: string | null): string | null;
|
|
|
21
21
|
export declare function methodNotAllowed(): Response;
|
|
22
22
|
/**
|
|
23
23
|
* Headers for a 302 out of this surface. `no-store` belongs on every one of them, not just the
|
|
24
|
-
* password pages: these are the responses that carry the
|
|
24
|
+
* password pages: these are the responses that carry the session cookie and, on the handoff
|
|
25
25
|
* path, the single-use code in the `Location` itself.
|
|
26
26
|
*/
|
|
27
27
|
export declare function redirectHeaders(location: string): Headers;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RequestContext } from '../env';
|
|
2
2
|
import type { Services } from '../services';
|
|
3
|
+
import type { AuthEnv } from './oidc-flight';
|
|
3
4
|
/**
|
|
4
5
|
* `GET|POST /auth/invitations/accept`. The emailed link opens the GET page; its fragment carries the
|
|
5
6
|
* one-time token, which never reaches a server log. Accepting is a POST from that page, same-origin
|
|
@@ -15,4 +16,4 @@ import type { Services } from '../services';
|
|
|
15
16
|
* The link's `?app=` picks the page's language; an accepted invitation lands on its own application's
|
|
16
17
|
* registered origin, where the application's proxy signs the browser in through the normal handoff.
|
|
17
18
|
*/
|
|
18
|
-
export declare function handleInvitation(request: Request, services: Services, ctx: RequestContext, requestId: string): Promise<Response>;
|
|
19
|
+
export declare function handleInvitation(request: Request, services: Services, env: AuthEnv, ctx: RequestContext, requestId: string): Promise<Response>;
|
|
@@ -4,4 +4,4 @@ import { type Services } from '../services';
|
|
|
4
4
|
import type { AuthEnv } from './oidc-flight';
|
|
5
5
|
export declare function handlePasswordLogin(request: Request, services: Services, env: AuthEnv, ctx: RequestContext, clientAddress: string | null, requestId: string): Promise<Response>;
|
|
6
6
|
export declare function handleForgotPassword(request: Request, services: Services, ctx: RequestContext, clientAddress: string | null, requestId: string): Promise<Response>;
|
|
7
|
-
export declare function handlePasswordAction(request: Request, services: Services, ctx: RequestContext, purpose: PasswordActionPurpose, requestId: string): Promise<Response>;
|
|
7
|
+
export declare function handlePasswordAction(request: Request, services: Services, env: AuthEnv, ctx: RequestContext, purpose: PasswordActionPurpose, requestId: string): Promise<Response>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ChallengeProblem } from '../second-factor-pages';
|
|
2
|
+
import type { Services } from '../services';
|
|
3
|
+
import type { Handoff } from './handoff';
|
|
4
|
+
import type { AuthEnv } from './oidc-flight';
|
|
5
|
+
/** Host-only on IAM's host, outside the `__Host-px_` prefix the proxy strips upstream, so no application receives it. */
|
|
6
|
+
export declare const SECOND_FACTOR_COOKIE = "__Host-fabrika_second_factor";
|
|
7
|
+
/** Long enough to open an authenticator app and type a code; a sign-in that takes longer proves its first factor again. */
|
|
8
|
+
export declare const SECOND_FACTOR_CHALLENGE_TTL_SECONDS: number;
|
|
9
|
+
/** The login a verified code opens: what `issueSession` was given, less the request's own id. */
|
|
10
|
+
export interface PendingLogin {
|
|
11
|
+
readonly principalId: string;
|
|
12
|
+
readonly idpSub: string | null;
|
|
13
|
+
readonly email: string | null;
|
|
14
|
+
readonly authenticationMethod: 'oidc' | 'password';
|
|
15
|
+
readonly redirect: string | null;
|
|
16
|
+
readonly reason: string;
|
|
17
|
+
readonly handoff: Handoff | null;
|
|
18
|
+
/** A password login earns the known-device cookie once it is recorded. */
|
|
19
|
+
readonly rememberDevice: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** The pending login the request's challenge cookie proves, or null when it is absent, forged, expired or malformed. */
|
|
22
|
+
export declare function readPendingLogin(env: AuthEnv, request: Request): Promise<PendingLogin | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Answer a first factor with the code form and the cookie that holds the pending login. An OIDC flight is spent here,
|
|
25
|
+
* as on every other end of its callback.
|
|
26
|
+
*/
|
|
27
|
+
export declare function challengeSecondFactor(services: Services, env: AuthEnv, request: Request, pending: PendingLogin): Promise<Response>;
|
|
28
|
+
/**
|
|
29
|
+
* The code form for `pending`, again with `problem`. Its `form-action` admits the one origin the verified login lands
|
|
30
|
+
* on: the handoff's registered origin, the IAM-chosen landing, or the console for a login with no destination.
|
|
31
|
+
*/
|
|
32
|
+
export declare function challengePage(services: Services, request: Request, pending: PendingLogin, problem?: ChallengeProblem): Promise<Response>;
|
|
33
|
+
/** The `Set-Cookie` that spends the challenge. */
|
|
34
|
+
export declare function endingChallengeCookie(): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RequestContext } from '../env';
|
|
2
|
+
import type { Services } from '../services';
|
|
3
|
+
import type { AuthEnv } from './oidc-flight';
|
|
4
|
+
/** Codes one account may try in a window before the next waits out the block: a burst, not a person mistyping. */
|
|
5
|
+
export declare const SECOND_FACTOR_MAX_ATTEMPTS = 5;
|
|
6
|
+
/**
|
|
7
|
+
* The code form's POST. The pending login comes from the challenge cookie only. Each attempt is counted per account
|
|
8
|
+
* before the code is checked, from the row the counting statement returns, so a parallel burst gets no more than
|
|
9
|
+
* `SECOND_FACTOR_MAX_ATTEMPTS` checks; the attempt that starts a block writes `iam.second_factor.throttle` to the
|
|
10
|
+
* audit log. Every refusal writes its `auth_log` row; an accepted code opens the login through `issueSession`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleSecondFactor(request: Request, services: Services, env: AuthEnv, ctx: RequestContext, requestId: string): Promise<Response>;
|
|
13
|
+
/**
|
|
14
|
+
* Enrolment, on IAM's host, for a signed-in principal that administers (`administersIam`). `GET` shows the state;
|
|
15
|
+
* `POST step=start` seals a new secret that waits for its first code and shows it; `POST step=confirm` checks that
|
|
16
|
+
* code, confirms the factor, replaces the recovery codes and records `iam.second_factor.enrol` in one transaction, and
|
|
17
|
+
* shows the codes once. A confirmed factor is never replaced here: only an administrator's reset removes it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleSecondFactorEnrolment(request: Request, services: Services, requestId: string): Promise<Response>;
|
|
@@ -2,8 +2,9 @@ import { type AuthenticationMethod, type PrincipalRow, type SessionRow } from '.
|
|
|
2
2
|
import { type RequestContext } from '../env';
|
|
3
3
|
import { type Services } from '../services';
|
|
4
4
|
import { type Handoff } from './handoff';
|
|
5
|
+
import { type AuthEnv } from './oidc-flight';
|
|
5
6
|
/** The caller's IAM session, if the browser already holds a valid one on this host. */
|
|
6
|
-
export declare function currentSession(request: Request, services: Services): Promise<
|
|
7
|
+
export declare function currentSession(request: Request, services: Services): Promise<import("../db").SignedInSessionRow | null>;
|
|
7
8
|
/** A login a handoff may continue: the browser's IAM session and its principal, an active user. */
|
|
8
9
|
export interface CurrentLogin {
|
|
9
10
|
readonly session: SessionRow;
|
|
@@ -11,12 +12,8 @@ export interface CurrentLogin {
|
|
|
11
12
|
}
|
|
12
13
|
/** The caller's IAM login when its principal is an active user, else null — which signs in afresh. */
|
|
13
14
|
export declare function currentLogin(request: Request, services: Services): Promise<CurrentLogin | null>;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* be logged opens no session and answers 503. A principal that administers at IAM, the installation or the people of
|
|
17
|
-
* an application (ADR-0058), is logged `privileged`.
|
|
18
|
-
*/
|
|
19
|
-
export declare function issueSession(request: Request, services: Services, ctx: RequestContext, input: {
|
|
15
|
+
/** A login a proven first factor opens. */
|
|
16
|
+
export interface LoginInput {
|
|
20
17
|
principalId: string;
|
|
21
18
|
idpSub?: string | null;
|
|
22
19
|
email?: string | null;
|
|
@@ -29,13 +26,29 @@ export declare function issueSession(request: Request, services: Services, ctx:
|
|
|
29
26
|
clearOidc?: boolean;
|
|
30
27
|
/** When set, land on the app's callback with a code instead of on `redirect` (ADR-0022). */
|
|
31
28
|
handoff?: Handoff | null;
|
|
32
|
-
|
|
29
|
+
/** Set the known-device cookie once the login is recorded: a password login's (`auth/known-device.ts`). */
|
|
30
|
+
rememberDevice?: boolean;
|
|
31
|
+
/** Set only by the second-factor form, after the principal's code or recovery code was accepted. */
|
|
32
|
+
secondFactor?: 'verified';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Open a login: the session and its `auth_log` row are written in one batch, before the answer. A login that cannot
|
|
36
|
+
* be logged opens no session and answers 503. A principal that administers at IAM, the installation or the people of
|
|
37
|
+
* an application (ADR-0058), is logged `privileged`.
|
|
38
|
+
*
|
|
39
|
+
* A principal with a confirmed second factor gets no session here until its code is verified: the answer is the code
|
|
40
|
+
* form and a challenge cookie holding this login (`second-factor-challenge.ts`). Every password, OIDC, password-action
|
|
41
|
+
* and invitation login passes through here, so none skips the factor; only the local-dev bypass does, which no
|
|
42
|
+
* installation outside `ENVIRONMENT=local` serves. A terminal's assertion (`identification.ts`) opens no session here
|
|
43
|
+
* and asks no factor: it reaches only the asserting application, never IAM's administration.
|
|
44
|
+
*/
|
|
45
|
+
export declare function issueSession(request: Request, services: Services, env: AuthEnv, ctx: RequestContext, input: LoginInput): Promise<Response>;
|
|
33
46
|
/**
|
|
34
47
|
* Answer a refused login after its `deny` row is in `auth_log`. A refusal that cannot be logged answers 503 instead,
|
|
35
48
|
* so no login attempt goes unrecorded.
|
|
36
49
|
*/
|
|
37
50
|
/** The fixed `auth_log.reason` of a refused login. A reason never carries what the caller submitted. */
|
|
38
|
-
export type LoginRefusal = 'password_invalid' | 'password_throttled' | 'password_malformed' | 'handoff_refused' | 'login_cross_origin' | 'oidc_invalid_state' | 'oidc_code_exchange_failed' | 'oidc_invalid_id_token' | 'oidc_not_admitted' | 'oidc_disabled' | 'oidc_unknown_principal' | 'oidc_external_principal' | 'local_login_refused';
|
|
51
|
+
export type LoginRefusal = 'password_invalid' | 'password_throttled' | 'password_malformed' | 'handoff_refused' | 'login_cross_origin' | 'oidc_invalid_state' | 'oidc_code_exchange_failed' | 'oidc_invalid_id_token' | 'oidc_not_admitted' | 'oidc_disabled' | 'oidc_unknown_principal' | 'oidc_external_principal' | 'local_login_refused' | 'second_factor_invalid' | 'second_factor_throttled' | 'second_factor_expired';
|
|
39
52
|
export declare function refuseLogin(services: Services, request: Request, entry: {
|
|
40
53
|
requestId: string;
|
|
41
54
|
principalId: string | null;
|
package/types/src/auth.d.ts
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { type PermissionEntry, type PrincipalType, type TokenPrincipalType } from '@fabrika/auth-core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SignedInSessionRow } from './db';
|
|
3
3
|
import type { Env } from './env';
|
|
4
4
|
import type { Config, Services } from './services';
|
|
5
5
|
/** Fixed identity of the local-dev login (`LOCAL_DEV_LOGIN`, `auth/login.ts`). */
|
|
6
6
|
export declare const LOCAL_DEV_ADMIN_ID = "local-dev-admin";
|
|
7
7
|
export declare const LOCAL_DEV_ADMIN_EMAIL = "admin@local.test";
|
|
8
8
|
/**
|
|
9
|
-
* May this session still be used, given what the installation enables NOW?
|
|
9
|
+
* May this session still be used at `now` (unix seconds), given what the installation enables NOW?
|
|
10
10
|
*
|
|
11
11
|
* **Checked at USE, not at creation, and that is the point.** Turning a method off changes what the
|
|
12
12
|
* next login may do and nothing about what was already issued. Sessions live 30 days, so an
|
|
13
13
|
* installation that moved to password-only kept honouring every OIDC login for a month — and, for the
|
|
14
14
|
* bypass, every one of those is a global admin.
|
|
15
15
|
*
|
|
16
|
+
* An OIDC login is usable for `sessionCapSeconds` after it signed in; then the provider is asked again, so a person
|
|
17
|
+
* blocked there loses access within the cap. Measured here, from the login's sign-in, so it also ends logins issued
|
|
18
|
+
* before the cap was lowered, and the app sessions derived from them.
|
|
19
|
+
*
|
|
16
20
|
* The bypass carries `local_dev` as its own method rather than an exemption
|
|
17
21
|
* here, so this stays a total function over the enum: a method added later has to answer the question.
|
|
18
22
|
*/
|
|
19
|
-
export declare function sessionUsable(session: Pick<
|
|
23
|
+
export declare function sessionUsable(session: Pick<SignedInSessionRow, 'authentication_method' | 'expires_at' | 'signed_in_at'>, config: Pick<Config, 'authentication' | 'localDevLogin'>, now: number): boolean;
|
|
24
|
+
/** When a session ends by its own clock: its expiry, or earlier for an OIDC login, its sign-in plus the installation's cap. */
|
|
25
|
+
export declare function sessionEndsAt(session: Pick<SignedInSessionRow, 'authentication_method' | 'expires_at' | 'signed_in_at'>, config: Pick<Config, 'authentication'>): number;
|
|
20
26
|
/**
|
|
21
27
|
* Fixed identity for the SEEDED PROVISIONING KEY below. A stable `service` principal with this id is
|
|
22
28
|
* seeded into `principals` (migration `0001_init.sql`) so the audit the provisioning
|
|
@@ -67,6 +67,34 @@ export interface PageText {
|
|
|
67
67
|
readonly enrolledTitle: string;
|
|
68
68
|
readonly enrolledText: (label: string) => string;
|
|
69
69
|
};
|
|
70
|
+
/** The second factor (TOTP): the code a sign-in asks for, and enrolling an authenticator app. */
|
|
71
|
+
readonly secondFactor: {
|
|
72
|
+
readonly challengeTitle: string;
|
|
73
|
+
readonly challengeText: string;
|
|
74
|
+
readonly codeLabel: string;
|
|
75
|
+
readonly submit: string;
|
|
76
|
+
readonly invalidCode: string;
|
|
77
|
+
/** Too many wrong codes for this account; the next attempt waits. */
|
|
78
|
+
readonly throttled: string;
|
|
79
|
+
/** The data key is unset or does not open the secret: only a recovery code signs in. */
|
|
80
|
+
readonly appCodesUnavailable: string;
|
|
81
|
+
readonly startOver: string;
|
|
82
|
+
readonly enrolTitle: string;
|
|
83
|
+
readonly enrolText: string;
|
|
84
|
+
readonly start: string;
|
|
85
|
+
readonly scanText: string;
|
|
86
|
+
readonly secretLabel: string;
|
|
87
|
+
readonly confirmLabel: string;
|
|
88
|
+
readonly confirm: string;
|
|
89
|
+
readonly enrolledTitle: string;
|
|
90
|
+
/** `enrolledOn` is an ISO date; `left` the recovery codes not used yet. */
|
|
91
|
+
readonly enrolledText: (enrolledOn: string, left: number) => string;
|
|
92
|
+
readonly recoveryTitle: string;
|
|
93
|
+
readonly recoveryText: string;
|
|
94
|
+
readonly continue: string;
|
|
95
|
+
readonly unavailableTitle: string;
|
|
96
|
+
readonly unavailableText: string;
|
|
97
|
+
};
|
|
70
98
|
readonly invitation: {
|
|
71
99
|
readonly title: string;
|
|
72
100
|
readonly text: string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** AES-256: the installation's key and each data key. */
|
|
2
|
+
export declare const DATA_KEY_BYTES = 32;
|
|
3
|
+
/** The sealed pieces as stored: all base64, never a plaintext value or data key. */
|
|
4
|
+
export interface SealedValue {
|
|
5
|
+
readonly ciphertext: string;
|
|
6
|
+
readonly valueIv: string;
|
|
7
|
+
readonly wrappedDek: string;
|
|
8
|
+
readonly dekIv: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse `FABRIKA_IAM_DATA_KEY` (base64 of 32 random bytes) once at boot. Unset or empty is null: nothing can be sealed,
|
|
12
|
+
* so TOTP enrolment is unavailable. Anything else that is not 32 bytes fails the boot; a short key would be a weak key
|
|
13
|
+
* nobody notices.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseDataKey(raw: string | undefined): Uint8Array<ArrayBuffer> | null;
|
|
16
|
+
/** Seal `value` for `owner` (the associated data of both layers). */
|
|
17
|
+
export declare function sealValue(dataKey: Uint8Array<ArrayBuffer>, owner: string, value: Uint8Array<ArrayBuffer>): Promise<SealedValue>;
|
|
18
|
+
/** Open a value `sealValue` sealed for `owner`. A wrong key, another owner or any tampered piece throws. */
|
|
19
|
+
export declare function openValue(dataKey: Uint8Array<ArrayBuffer>, owner: string, sealed: SealedValue): Promise<Uint8Array<ArrayBuffer>>;
|
package/types/src/db.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { MembershipTransportKeyRepository } from './repositories/membership-tran
|
|
|
12
12
|
import { OAuthRepository } from './repositories/oauth';
|
|
13
13
|
import { PasswordPolicyRepository } from './repositories/password-policy';
|
|
14
14
|
import { PrincipalRepository } from './repositories/principals';
|
|
15
|
+
import { SecondFactorRepository } from './repositories/second-factors';
|
|
15
16
|
import { SessionRepository } from './repositories/sessions';
|
|
16
17
|
import { TerminalRepository } from './repositories/terminals';
|
|
17
18
|
import { WorkloadRepository } from './repositories/workloads';
|
|
@@ -27,7 +28,8 @@ export { MembershipTransportKeyRepository, type MembershipTransportKeyRow } from
|
|
|
27
28
|
export { type OAuthCodeRow, type OAuthGrantRow, type OAuthRefreshTokenRow, OAuthRepository } from './repositories/oauth';
|
|
28
29
|
export { PasswordPolicyRepository, type PasswordPolicyRow } from './repositories/password-policy';
|
|
29
30
|
export { PrincipalRepository, type PrincipalRow, type PrincipalStatus, principalStatus } from './repositories/principals';
|
|
30
|
-
export {
|
|
31
|
+
export { SecondFactorRepository, type SecondFactorRow, type SecondFactorStatus } from './repositories/second-factors';
|
|
32
|
+
export { type AuthenticationMethod, SessionRepository, type SessionRow, type SessionTerminal, sessionTerminal, type SignedInSessionRow, } from './repositories/sessions';
|
|
31
33
|
export { DEFAULT_TERMINAL_SESSION_TTL_SECONDS, MAX_TERMINAL_SESSION_TTL_SECONDS, type TerminalAsserter, type TerminalIdentificationRow, type TerminalProfile, TerminalRepository, type TerminalRow, } from './repositories/terminals';
|
|
32
34
|
export { type AppWorkloadRow, type WorkloadPrincipalRow, WorkloadRepository } from './repositories/workloads';
|
|
33
35
|
/** IAM persistence capabilities selected together by a runtime composition root. */
|
|
@@ -48,6 +50,7 @@ export interface IamRepositories {
|
|
|
48
50
|
membershipTransport: MembershipTransportKeyRepository;
|
|
49
51
|
brand: InstallationBrandRepository;
|
|
50
52
|
passwordPolicy: PasswordPolicyRepository;
|
|
53
|
+
secondFactors: SecondFactorRepository;
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
53
56
|
* The portable repository bundle. A composition root may replace one complete capability. `dialect` picks how a
|
package/types/src/env.d.ts
CHANGED
|
@@ -37,8 +37,9 @@ export interface Env {
|
|
|
37
37
|
*/
|
|
38
38
|
ADMIN_AUDIENCES?: string;
|
|
39
39
|
/**
|
|
40
|
-
* JSON: the OAuth 2.1 authorization server
|
|
41
|
-
*
|
|
40
|
+
* JSON: the OAuth 2.1 authorization server's clients and resources (`src/oauth-config.ts`). Absent or empty means
|
|
41
|
+
* OAuth is off and its routes 404. On Bun, `FABRIKA_IAM_OAUTH_CONFIG`; a Cloudflare deploy computes it in
|
|
42
|
+
* `fabrika.config.ts`. Malformed fails the boot.
|
|
42
43
|
*/
|
|
43
44
|
OAUTH_CONFIG?: string;
|
|
44
45
|
/**
|
|
@@ -51,6 +52,11 @@ export interface Env {
|
|
|
51
52
|
* `FABRIKA_IAM_AUDIT_RETENTION_DAYS`. A value that is not a whole number of days fails the boot.
|
|
52
53
|
*/
|
|
53
54
|
AUDIT_RETENTION_DAYS?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Hours an OIDC login stays usable after its sign-in; unset means 12. Deploy var `FABRIKA_IAM_OIDC_SESSION_HOURS`.
|
|
57
|
+
* Anything but a whole number of hours from 1 to 720 fails the boot.
|
|
58
|
+
*/
|
|
59
|
+
OIDC_SESSION_HOURS?: string;
|
|
54
60
|
/** `local` / `stage` / `prod`. */
|
|
55
61
|
ENVIRONMENT: string;
|
|
56
62
|
/** Explicit local-only human login bypass. Ignored unless `ENVIRONMENT=local`. */
|
|
@@ -100,6 +106,13 @@ export interface Env {
|
|
|
100
106
|
* `vars`. Rotate by changing the env value.
|
|
101
107
|
*/
|
|
102
108
|
FABRIKA_IAM_PROVISIONING_KEY: string;
|
|
109
|
+
/**
|
|
110
|
+
* **Secret.** Base64 of 32 random bytes: the key that seals the one value IAM must read back, a person's TOTP secret
|
|
111
|
+
* (`src/data-key.ts`). Unset makes TOTP enrolment unavailable; a value that is not 32 bytes fails the boot. Losing it
|
|
112
|
+
* makes every enrolled authenticator unreadable, so those people sign in with a recovery code or an administrator's
|
|
113
|
+
* reset. Never placed in `vars`.
|
|
114
|
+
*/
|
|
115
|
+
FABRIKA_IAM_DATA_KEY?: string;
|
|
103
116
|
/**
|
|
104
117
|
* OIDC provider issuer URL (e.g. `https://accounts.google.com`, an Auth0/Okta/Keycloak/Entra
|
|
105
118
|
* tenant). IAM discovers the endpoints from `${OIDC_ISSUER}/.well-known/openid-configuration`
|
|
@@ -9,8 +9,8 @@ export interface OAuthConfig {
|
|
|
9
9
|
resources: OAuthResourceDto[];
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Parse `OAUTH_CONFIG`. Absent or empty disables OAuth; anything malformed THROWS, so a typo fails the
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Parse `OAUTH_CONFIG`. Absent or empty disables OAuth; anything malformed THROWS, so a typo fails the boot instead of
|
|
13
|
+
* quietly serving fewer clients or scopes than the operator wrote. Unknown keys are refused for the same reason.
|
|
14
|
+
* `clients` may be empty: the command-line client is IAM's own and never listed.
|
|
15
15
|
*/
|
|
16
16
|
export declare function parseOAuthConfig(raw: string | undefined): OAuthConfig | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OAuthConfig } from './oauth-config';
|
|
2
|
+
import type { Services } from './services';
|
|
3
|
+
/**
|
|
4
|
+
* `/oauth/device`: a signed-in person enters the code a device shows, reads what it asks for and decides. GET only
|
|
5
|
+
* renders the entry form, so a link can neither decide nor spend the person's code-entry budget.
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleDevicePage(request: Request, services: Services, config: OAuthConfig): Promise<Response>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { OAUTH_DEVICE_CODE_GRANT_TYPE, type OAuthDeviceAuthorizationRequest, type OAuthDeviceAuthorizationResponse, type OAuthTokenRequest } from '@fabrika/iam-contract';
|
|
2
|
+
import type { Env } from './env';
|
|
3
|
+
import { type EstablishedClient, type OAuthTokenOutcome } from './oauth';
|
|
4
|
+
import type { OAuthConfig } from './oauth-config';
|
|
5
|
+
import type { OAuthDeviceAuthorizationRow } from './repositories/oauth';
|
|
6
|
+
import type { Services } from './services';
|
|
7
|
+
type SigningEnv = Pick<Env, 'FABRIKA_IAM_SIGNING_KEYS' | 'ENVIRONMENT'>;
|
|
8
|
+
export declare const OAUTH_DEVICE_PATH = "/oauth/device";
|
|
9
|
+
/** RFC 8628 §3.2 `expires_in`: a person has five minutes to enter the code and decide. */
|
|
10
|
+
export declare const OAUTH_DEVICE_ATTEMPT_TTL_SECONDS = 300;
|
|
11
|
+
export declare const OAUTH_DEVICE_POLL_INTERVAL_SECONDS = 5;
|
|
12
|
+
export type DeviceStartOutcome = {
|
|
13
|
+
ok: true;
|
|
14
|
+
body: OAuthDeviceAuthorizationResponse;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
error: 'unauthorized_client' | 'invalid_target' | 'invalid_scope' | 'temporarily_unavailable';
|
|
18
|
+
};
|
|
19
|
+
/** The user code as a person types it: upper case, without the separator or spaces. Null when it cannot be one. */
|
|
20
|
+
export declare function normalizeUserCode(raw: string): string | null;
|
|
21
|
+
export declare function formatUserCode(code: string): string;
|
|
22
|
+
export declare function userCodeHash(code: string): Promise<string>;
|
|
23
|
+
/** RFC 8628 §3.1–3.2: record an attempt for the CLI client and answer its codes. */
|
|
24
|
+
export declare function startDeviceAuthorization(services: Services, config: OAuthConfig, request: OAuthDeviceAuthorizationRequest, clientAddress: string | null): Promise<DeviceStartOutcome>;
|
|
25
|
+
export type CodeEntry = {
|
|
26
|
+
kind: 'found';
|
|
27
|
+
attempt: OAuthDeviceAuthorizationRow;
|
|
28
|
+
userCode: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'unknown';
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'throttled';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The pending attempt a signed-in person's code names. Every entry counts against that person before the lookup, and
|
|
36
|
+
* once the budget is spent even a right code is refused until the block ends (RFC 8628 §5.1).
|
|
37
|
+
*/
|
|
38
|
+
export declare function enterUserCode(services: Services, principalId: string, raw: string): Promise<CodeEntry>;
|
|
39
|
+
/** The attempt's stored scope tokens and resources, or null when either does not parse. */
|
|
40
|
+
export declare function attemptRequest(attempt: OAuthDeviceAuthorizationRow): {
|
|
41
|
+
scopes: string[];
|
|
42
|
+
resources: string[];
|
|
43
|
+
} | null;
|
|
44
|
+
/**
|
|
45
|
+
* RFC 8628 §3.4–3.5: one poll of the token endpoint. An approved attempt is spent for a new grant, bound to the IAM
|
|
46
|
+
* session it was approved under, and answers a token for the requested resource and the grant's first refresh token.
|
|
47
|
+
*/
|
|
48
|
+
export declare function redeemDeviceCode(services: Services, env: SigningEnv, client: EstablishedClient, input: Extract<OAuthTokenRequest, {
|
|
49
|
+
grant_type: typeof OAUTH_DEVICE_CODE_GRANT_TYPE;
|
|
50
|
+
}>, requestId: string): Promise<OAuthTokenOutcome>;
|
|
51
|
+
export {};
|
|
@@ -2,6 +2,9 @@ import type { Env } from './env';
|
|
|
2
2
|
import type { Services } from './services';
|
|
3
3
|
export declare const OAUTH_METADATA_PATH = "/.well-known/oauth-authorization-server";
|
|
4
4
|
type SigningEnv = Pick<Env, 'FABRIKA_IAM_SIGNING_KEYS' | 'ENVIRONMENT'>;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The OAuth authorization server's public surface. With `OAUTH_CONFIG` unset every path is 404. `clientAddress` is the
|
|
7
|
+
* composition's client coordinate (`client-address.ts`), null where it names none.
|
|
8
|
+
*/
|
|
9
|
+
export declare function handleOAuth(request: Request, services: Services, env: SigningEnv, requestId: string, clientAddress: string | null): Promise<Response>;
|
|
7
10
|
export {};
|
package/types/src/oauth.d.ts
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
import { type KeyGrant, type PermissionEntry } from '@fabrika/auth-core';
|
|
2
|
-
import type
|
|
3
|
-
import { type OAuthGrantRow, type PrincipalRow, type SessionRow } from './db';
|
|
2
|
+
import { OAUTH_DEVICE_CODE_GRANT_TYPE, type OAuthAuthorizationRequest, type OAuthClientMetadataDocument, type OAuthResourceDto, type OAuthRevocationRequest, type OAuthTokenRequest, type OAuthTokenResponse } from '@fabrika/iam-contract';
|
|
3
|
+
import { type AuditEventInput, type OAuthGrantRow, type PrincipalRow, type SessionRow } from './db';
|
|
4
4
|
import type { Env } from './env';
|
|
5
5
|
import type { ManagedOAuthClient, OAuthConfig } from './oauth-config';
|
|
6
6
|
import type { Services } from './services';
|
|
7
7
|
/** An authorization code is redeemed by the client's back end within seconds of the redirect. */
|
|
8
8
|
export declare const OAUTH_CODE_TTL_SECONDS = 60;
|
|
9
9
|
type SigningEnv = Pick<Env, 'FABRIKA_IAM_SIGNING_KEYS' | 'ENVIRONMENT'>;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* A client an authorization or token request comes from: an operator-registered CIMD client, or the installation's own
|
|
12
|
+
* command-line client, a public client IAM knows without a document. The CLI client has no redirect URI, so it never
|
|
13
|
+
* completes an authorization request; it redeems the grants IAM gives it otherwise and refreshes them.
|
|
14
|
+
*/
|
|
15
|
+
export type EstablishedClient = {
|
|
16
|
+
kind: 'managed';
|
|
11
17
|
registration: ManagedOAuthClient;
|
|
12
18
|
metadata: OAuthClientMetadataDocument;
|
|
13
|
-
}
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'cli';
|
|
21
|
+
clientId: string;
|
|
22
|
+
};
|
|
23
|
+
export type ManagedClient = Extract<EstablishedClient, {
|
|
24
|
+
kind: 'managed';
|
|
25
|
+
}>;
|
|
26
|
+
/** Whether `resource` is served to the command-line client (`cli`) or to the managed clients; never to both. */
|
|
27
|
+
export declare function servesClient(resource: OAuthResourceDto, cli: boolean): boolean;
|
|
28
|
+
/** The resources a grant was given for: every token it mints names one of them. */
|
|
29
|
+
export declare function grantResources(grant: Pick<OAuthGrantRow, 'resource' | 'resources'>): string[];
|
|
30
|
+
/** A stored JSON list of resources, or null when it is not one. */
|
|
31
|
+
export declare function storedResourceList(text: string): string[] | null;
|
|
14
32
|
/**
|
|
15
33
|
* Resolve a client and its redirect URI. Until this succeeds nothing may be redirected to
|
|
16
34
|
* `redirect_uri`. An unregistered client id is refused before any metadata fetch.
|
|
17
35
|
*/
|
|
18
|
-
export declare function establishClient(config: OAuthConfig, clientId: string, redirectUri: string): Promise<
|
|
36
|
+
export declare function establishClient(config: OAuthConfig, clientId: string, redirectUri: string): Promise<ManagedClient | null>;
|
|
19
37
|
/** Record the consent and return the plaintext authorization code — the only time it exists. */
|
|
20
38
|
export declare function grantAuthorization(services: Services, input: {
|
|
21
39
|
request: OAuthAuthorizationRequest;
|
|
@@ -24,23 +42,29 @@ export declare function grantAuthorization(services: Services, input: {
|
|
|
24
42
|
session: SessionRow;
|
|
25
43
|
requestId: string;
|
|
26
44
|
}): Promise<string>;
|
|
45
|
+
/** RFC 6749 §5.2 and RFC 8628 §3.5: what a refused token request answers. */
|
|
46
|
+
export type OAuthTokenError = 'invalid_grant' | 'invalid_target' | 'unauthorized_client' | 'authorization_pending' | 'slow_down' | 'access_denied' | 'expired_token';
|
|
27
47
|
export type OAuthTokenOutcome = {
|
|
28
48
|
ok: true;
|
|
29
49
|
body: OAuthTokenResponse;
|
|
30
50
|
} | {
|
|
31
51
|
ok: false;
|
|
32
|
-
error:
|
|
52
|
+
error: OAuthTokenError;
|
|
33
53
|
};
|
|
34
54
|
/** Redeem a code or rotate a refresh token for a client `authenticateOAuthClient` established. */
|
|
35
|
-
export declare function exchangeOAuthToken(services: Services, env: SigningEnv, client: EstablishedClient, input: OAuthTokenRequest,
|
|
55
|
+
export declare function exchangeOAuthToken(services: Services, env: SigningEnv, client: EstablishedClient, input: Exclude<OAuthTokenRequest, {
|
|
56
|
+
grant_type: typeof OAUTH_DEVICE_CODE_GRANT_TYPE;
|
|
57
|
+
}>, requestId: string): Promise<OAuthTokenOutcome>;
|
|
36
58
|
/** RFC 7009: revoking either token kind revokes its grant. An unknown or foreign token is a silent no-op. */
|
|
37
59
|
export declare function revokeOAuthToken(services: Services, env: SigningEnv, input: OAuthRevocationRequest, requestId: string): Promise<void>;
|
|
60
|
+
/** An access token for `resource`, one of the grant's resources, carrying the grant's live authority there. */
|
|
61
|
+
export declare function mintForGrant(services: Services, env: SigningEnv, grant: OAuthGrantRow, resource: string, now: number): Promise<OAuthTokenResponse | null>;
|
|
38
62
|
/**
|
|
39
63
|
* Everything a grant needs to still mean something, checked at every code exchange and refresh: the
|
|
40
64
|
* grant live, its client and resource still configured, the IAM session it was given under live and
|
|
41
65
|
* usable, the principal an active user. The permissions are resolved live, never from the consent.
|
|
42
66
|
*/
|
|
43
|
-
export declare function grantAuthority(services: Services, grant: OAuthGrantRow, now: number): Promise<{
|
|
67
|
+
export declare function grantAuthority(services: Services, grant: OAuthGrantRow, now: number, resourceUri?: string): Promise<{
|
|
44
68
|
principal: PrincipalRow;
|
|
45
69
|
scopes: string[];
|
|
46
70
|
permissions: PermissionEntry[];
|
|
@@ -48,4 +72,6 @@ export declare function grantAuthority(services: Services, grant: OAuthGrantRow,
|
|
|
48
72
|
} | null>;
|
|
49
73
|
/** The union of the scopes' grants, or null when a scope is no longer configured. */
|
|
50
74
|
export declare function scopeCeiling(resource: OAuthResourceDto, scopes: readonly string[]): KeyGrant[] | null;
|
|
75
|
+
/** The record of a grant's revocation: by its client, or by IAM on a replayed code or refresh token. */
|
|
76
|
+
export declare function grantRevocation(requestId: string, grantId: string, clientId: string, reason: 'code_replay' | 'refresh_replay' | 'device_code_replay' | 'client_revocation'): AuditEventInput;
|
|
51
77
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long an OIDC login lasts before IAM sends its holder back to the provider, in hours. The provider is where an
|
|
3
|
+
* organization blocks a person, so this bounds how long a person blocked there keeps fabrika access.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_OIDC_SESSION_HOURS = 12;
|
|
6
|
+
/** The longest cap: the lifetime of every IAM login (`SESSION_TTL_SECONDS`, 30 days). */
|
|
7
|
+
export declare const MAX_OIDC_SESSION_HOURS: number;
|
|
8
|
+
/**
|
|
9
|
+
* Parse the cap into seconds. Unset or empty means the default; anything but a whole number of hours from 1 to 720 is
|
|
10
|
+
* refused, so a typo fails the boot instead of capping at a value nobody chose.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseOidcSessionSeconds(raw: string | undefined, name?: string): number;
|
|
@@ -92,7 +92,8 @@ export type SqlDialect = 'sqlite' | 'postgres';
|
|
|
92
92
|
* The INSERT of one audit row, for the batch of an unconditional change it records: the row and the change commit
|
|
93
93
|
* together, and a failed insert rolls the change back. Diff and metadata are stored JSON-encoded.
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
/** The INSERT of one audit row; with `guard`, written only when the guard finds its row (see `SqlGuard`). */
|
|
96
|
+
export declare function auditEventStatement(db: SqlDatabase, event: AuditEventInput, guard?: SqlGuard): SqlStatement;
|
|
96
97
|
/**
|
|
97
98
|
* `auditEventStatement` whose `resource_id` is read in the batch by `resourceId`, a one-row SELECT of one column: for
|
|
98
99
|
* a resource whose id the batch itself settles, such as a principal another writer may have created first.
|
|
@@ -6,7 +6,10 @@ export interface OAuthGrantRow {
|
|
|
6
6
|
session_id: string;
|
|
7
7
|
client_id: string;
|
|
8
8
|
app: string;
|
|
9
|
+
/** The grant's first resource; `resources` lists them all when it was given for several. */
|
|
9
10
|
resource: string;
|
|
11
|
+
/** JSON array of every resource of the grant, all of `app`; null when `resource` is the only one. */
|
|
12
|
+
resources: string | null;
|
|
10
13
|
/** JSON array of the consented scope names. */
|
|
11
14
|
scopes: string;
|
|
12
15
|
created_at: number;
|
|
@@ -27,6 +30,27 @@ export interface OAuthRefreshTokenRow {
|
|
|
27
30
|
expires_at: number;
|
|
28
31
|
used_at: number | null;
|
|
29
32
|
}
|
|
33
|
+
/** An RFC 8628 attempt. `principal_id`, `session_id` and `grant_expires_at` are set by its approval, `grant_id` by its redemption. */
|
|
34
|
+
export interface OAuthDeviceAuthorizationRow {
|
|
35
|
+
device_code_hash: string;
|
|
36
|
+
user_code_hash: string;
|
|
37
|
+
client_id: string;
|
|
38
|
+
app: string;
|
|
39
|
+
/** JSON array of the resources the grant will cover, all of `app`. */
|
|
40
|
+
resources: string;
|
|
41
|
+
/** JSON array of the requested scope tokens. */
|
|
42
|
+
scopes: string;
|
|
43
|
+
interval_seconds: number;
|
|
44
|
+
next_poll_at: number;
|
|
45
|
+
created_at: number;
|
|
46
|
+
expires_at: number;
|
|
47
|
+
status: 'pending' | 'approved' | 'denied' | 'redeemed';
|
|
48
|
+
principal_id: string | null;
|
|
49
|
+
session_id: string | null;
|
|
50
|
+
grant_expires_at: number | null;
|
|
51
|
+
grant_id: string | null;
|
|
52
|
+
}
|
|
53
|
+
export type NewOAuthDeviceAuthorization = Pick<OAuthDeviceAuthorizationRow, 'device_code_hash' | 'user_code_hash' | 'client_id' | 'app' | 'resources' | 'scopes' | 'interval_seconds' | 'created_at' | 'expires_at'>;
|
|
30
54
|
/** Codes and refresh tokens are addressed by hash only; the plaintext never reaches this layer. */
|
|
31
55
|
export declare class OAuthRepository {
|
|
32
56
|
private readonly db;
|
|
@@ -45,10 +69,33 @@ export declare class OAuthRepository {
|
|
|
45
69
|
/** Spend a refresh token for rotation. A second presentation gets null and finds the spent row via `refreshToken`. */
|
|
46
70
|
consumeRefreshToken(tokenHash: string, now: number): Promise<OAuthRefreshTokenRow | null>;
|
|
47
71
|
refreshToken(tokenHash: string): Promise<OAuthRefreshTokenRow | null>;
|
|
72
|
+
/** Record a device attempt. False when either code's hash is taken already, so the caller draws new codes. */
|
|
73
|
+
startDeviceAuthorization(row: NewOAuthDeviceAuthorization): Promise<boolean>;
|
|
74
|
+
deviceAuthorization(deviceCodeHash: string): Promise<OAuthDeviceAuthorizationRow | null>;
|
|
75
|
+
/** The attempt a person may still decide: pending and unexpired. */
|
|
76
|
+
pendingDeviceAuthorization(userCodeHash: string, now: number): Promise<OAuthDeviceAuthorizationRow | null>;
|
|
77
|
+
/** Approve a pending attempt under the approver's IAM session. False when it was decided, or expired, meanwhile. */
|
|
78
|
+
approveDeviceAuthorization(userCodeHash: string, approval: {
|
|
79
|
+
principalId: string;
|
|
80
|
+
sessionId: string;
|
|
81
|
+
grantExpiresAt: number;
|
|
82
|
+
}, now: number): Promise<boolean>;
|
|
83
|
+
denyDeviceAuthorization(userCodeHash: string, now: number): Promise<boolean>;
|
|
84
|
+
/**
|
|
85
|
+
* Admit one poll of an attempt (RFC 8628 §3.5). A poll before the interval has passed is refused and lengthens the
|
|
86
|
+
* interval by five seconds, which the client is told to add with `slow_down`.
|
|
87
|
+
*/
|
|
88
|
+
admitDevicePoll(deviceCodeHash: string, now: number): Promise<boolean>;
|
|
89
|
+
/**
|
|
90
|
+
* Spend an approved attempt for `grant`: the claim, the grant, its record and its first refresh token in one batch.
|
|
91
|
+
* Every write after the claim requires the claim this batch made (`grant_id` names this grant), so exactly one poll
|
|
92
|
+
* gives a grant, and a refused or failed claim writes nothing. Answers the claimed row, or null.
|
|
93
|
+
*/
|
|
94
|
+
redeemDeviceAuthorization(deviceCodeHash: string, grant: OAuthGrantRow, refreshTokenHash: string, audit: AuditEventInput, now: number): Promise<OAuthDeviceAuthorizationRow | null>;
|
|
48
95
|
/** Record an accepted client assertion's `jti`. False when the client already presented it: a replay. */
|
|
49
96
|
recordClientAssertion(clientId: string, jti: string, expiresAt: number): Promise<boolean>;
|
|
50
97
|
/**
|
|
51
|
-
* Delete codes, refresh tokens
|
|
98
|
+
* Delete codes, refresh tokens, client assertion ids and device attempts past expiry. Spent rows stay until then because they are what
|
|
52
99
|
* detects a replay. Grants go with their session row (`ON DELETE CASCADE`), which shares their expiry.
|
|
53
100
|
*/
|
|
54
101
|
prune(now: number): Promise<void>;
|