@softure-ai/auth 0.2.5 → 0.2.6

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +98 -10
  3. package/dist/contract.d.ts +5 -1
  4. package/dist/contract.d.ts.map +1 -1
  5. package/dist/contract.js.map +1 -1
  6. package/dist/index.d.ts +72 -4
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +9 -4
  9. package/dist/index.js.map +1 -1
  10. package/dist/messages/en.d.ts +10 -0
  11. package/dist/messages/en.d.ts.map +1 -1
  12. package/dist/messages/en.js +10 -0
  13. package/dist/messages/en.js.map +1 -1
  14. package/dist/messages/index.d.ts +8 -0
  15. package/dist/messages/index.d.ts.map +1 -1
  16. package/dist/next/actions.d.ts +5 -0
  17. package/dist/next/actions.d.ts.map +1 -1
  18. package/dist/next/actions.js +26 -15
  19. package/dist/next/actions.js.map +1 -1
  20. package/dist/next/index.d.ts +2 -1
  21. package/dist/next/index.d.ts.map +1 -1
  22. package/dist/next/index.js +2 -1
  23. package/dist/next/index.js.map +1 -1
  24. package/dist/next/oidc-cookie.d.ts +7 -0
  25. package/dist/next/oidc-cookie.d.ts.map +1 -0
  26. package/dist/next/oidc-cookie.js +25 -0
  27. package/dist/next/oidc-cookie.js.map +1 -0
  28. package/dist/next/oidc-login-url.d.ts +4 -0
  29. package/dist/next/oidc-login-url.d.ts.map +1 -0
  30. package/dist/next/oidc-login-url.js +13 -0
  31. package/dist/next/oidc-login-url.js.map +1 -0
  32. package/dist/next/oidc-route.d.ts +7 -0
  33. package/dist/next/oidc-route.d.ts.map +1 -0
  34. package/dist/next/oidc-route.js +48 -0
  35. package/dist/next/oidc-route.js.map +1 -0
  36. package/dist/next/pages.d.ts +5 -0
  37. package/dist/next/pages.d.ts.map +1 -1
  38. package/dist/next/pages.js +19 -4
  39. package/dist/next/pages.js.map +1 -1
  40. package/dist/next/params.d.ts +2 -0
  41. package/dist/next/params.d.ts.map +1 -1
  42. package/dist/next/params.js +2 -0
  43. package/dist/next/params.js.map +1 -1
  44. package/dist/next/previous-session.d.ts +6 -0
  45. package/dist/next/previous-session.d.ts.map +1 -0
  46. package/dist/next/previous-session.js +23 -0
  47. package/dist/next/previous-session.js.map +1 -0
  48. package/dist/options.d.ts +99 -1
  49. package/dist/options.d.ts.map +1 -1
  50. package/dist/options.js +80 -0
  51. package/dist/options.js.map +1 -1
  52. package/dist/proxy/index.d.ts.map +1 -1
  53. package/dist/proxy/index.js +3 -1
  54. package/dist/proxy/index.js.map +1 -1
  55. package/dist/schema.d.ts +235 -0
  56. package/dist/schema.d.ts.map +1 -1
  57. package/dist/schema.js +22 -3
  58. package/dist/schema.js.map +1 -1
  59. package/dist/server/change-password.d.ts +1 -1
  60. package/dist/server/change-password.d.ts.map +1 -1
  61. package/dist/server/change-password.js +3 -0
  62. package/dist/server/change-password.js.map +1 -1
  63. package/dist/server/health.d.ts.map +1 -1
  64. package/dist/server/health.js +2 -0
  65. package/dist/server/health.js.map +1 -1
  66. package/dist/server/index.d.ts +1 -0
  67. package/dist/server/index.d.ts.map +1 -1
  68. package/dist/server/index.js +1 -0
  69. package/dist/server/index.js.map +1 -1
  70. package/dist/server/login.d.ts +1 -1
  71. package/dist/server/login.d.ts.map +1 -1
  72. package/dist/server/login.js +3 -1
  73. package/dist/server/login.js.map +1 -1
  74. package/dist/server/oidc/accounts.d.ts +12 -0
  75. package/dist/server/oidc/accounts.d.ts.map +1 -0
  76. package/dist/server/oidc/accounts.js +71 -0
  77. package/dist/server/oidc/accounts.js.map +1 -0
  78. package/dist/server/oidc/context.d.ts +37 -0
  79. package/dist/server/oidc/context.d.ts.map +1 -0
  80. package/dist/server/oidc/context.js +34 -0
  81. package/dist/server/oidc/context.js.map +1 -0
  82. package/dist/server/oidc/discovery.d.ts +24 -0
  83. package/dist/server/oidc/discovery.d.ts.map +1 -0
  84. package/dist/server/oidc/discovery.js +109 -0
  85. package/dist/server/oidc/discovery.js.map +1 -0
  86. package/dist/server/oidc/flow.d.ts +49 -0
  87. package/dist/server/oidc/flow.d.ts.map +1 -0
  88. package/dist/server/oidc/flow.js +168 -0
  89. package/dist/server/oidc/flow.js.map +1 -0
  90. package/dist/server/oidc/id-token.d.ts +36 -0
  91. package/dist/server/oidc/id-token.d.ts.map +1 -0
  92. package/dist/server/oidc/id-token.js +105 -0
  93. package/dist/server/oidc/id-token.js.map +1 -0
  94. package/dist/server/oidc/index.d.ts +4 -0
  95. package/dist/server/oidc/index.d.ts.map +1 -0
  96. package/dist/server/oidc/index.js +4 -0
  97. package/dist/server/oidc/index.js.map +1 -0
  98. package/dist/server/oidc/token-request.d.ts +13 -0
  99. package/dist/server/oidc/token-request.d.ts.map +1 -0
  100. package/dist/server/oidc/token-request.js +49 -0
  101. package/dist/server/oidc/token-request.js.map +1 -0
  102. package/dist/server/password-reset.d.ts +1 -1
  103. package/dist/server/password-reset.d.ts.map +1 -1
  104. package/dist/server/password-reset.js +3 -2
  105. package/dist/server/password-reset.js.map +1 -1
  106. package/dist/server/privacy.d.ts +8 -0
  107. package/dist/server/privacy.d.ts.map +1 -1
  108. package/dist/server/privacy.js +16 -4
  109. package/dist/server/privacy.js.map +1 -1
  110. package/dist/server/rate-limits.d.ts +4 -1
  111. package/dist/server/rate-limits.d.ts.map +1 -1
  112. package/dist/server/rate-limits.js +10 -3
  113. package/dist/server/rate-limits.js.map +1 -1
  114. package/dist/server/register.js +1 -1
  115. package/dist/server/register.js.map +1 -1
  116. package/dist/server/switches.d.ts +1 -1
  117. package/dist/server/switches.d.ts.map +1 -1
  118. package/dist/server/switches.js +3 -1
  119. package/dist/server/switches.js.map +1 -1
  120. package/dist/testing/account.js +1 -1
  121. package/dist/testing/account.js.map +1 -1
  122. package/dist/testing/index.d.ts +1 -0
  123. package/dist/testing/index.d.ts.map +1 -1
  124. package/dist/testing/index.js +3 -1
  125. package/dist/testing/index.js.map +1 -1
  126. package/dist/testing/oidc-provider.d.ts +64 -0
  127. package/dist/testing/oidc-provider.d.ts.map +1 -0
  128. package/dist/testing/oidc-provider.js +181 -0
  129. package/dist/testing/oidc-provider.js.map +1 -0
  130. package/dist/ui/index.d.ts +1 -0
  131. package/dist/ui/index.d.ts.map +1 -1
  132. package/dist/ui/index.js +1 -0
  133. package/dist/ui/index.js.map +1 -1
  134. package/dist/ui/oidc-sign-in.d.ts +25 -0
  135. package/dist/ui/oidc-sign-in.d.ts.map +1 -0
  136. package/dist/ui/oidc-sign-in.js +17 -0
  137. package/dist/ui/oidc-sign-in.js.map +1 -0
  138. package/migrations/0005_create_identities_and_oidc_states.sql +34 -0
  139. package/module.json +3 -2
  140. package/package.json +2 -2
  141. package/src/contract.ts +10 -1
  142. package/src/index.ts +20 -5
  143. package/src/messages/en.ts +10 -0
  144. package/src/next/actions.ts +23 -14
  145. package/src/next/index.ts +2 -0
  146. package/src/next/oidc-cookie.ts +31 -0
  147. package/src/next/oidc-login-url.ts +14 -0
  148. package/src/next/oidc-route.ts +48 -0
  149. package/src/next/pages.tsx +38 -11
  150. package/src/next/params.ts +3 -0
  151. package/src/next/previous-session.ts +23 -0
  152. package/src/options.ts +86 -1
  153. package/src/proxy/index.ts +3 -1
  154. package/src/schema.ts +28 -3
  155. package/src/server/change-password.ts +3 -0
  156. package/src/server/health.ts +2 -0
  157. package/src/server/index.ts +17 -0
  158. package/src/server/login.ts +2 -1
  159. package/src/server/oidc/accounts.ts +82 -0
  160. package/src/server/oidc/context.ts +56 -0
  161. package/src/server/oidc/discovery.ts +133 -0
  162. package/src/server/oidc/flow.ts +196 -0
  163. package/src/server/oidc/id-token.ts +124 -0
  164. package/src/server/oidc/index.ts +14 -0
  165. package/src/server/oidc/token-request.ts +59 -0
  166. package/src/server/password-reset.ts +3 -2
  167. package/src/server/privacy.ts +24 -4
  168. package/src/server/rate-limits.ts +11 -3
  169. package/src/server/register.ts +1 -1
  170. package/src/server/switches.ts +2 -1
  171. package/src/testing/account.ts +1 -1
  172. package/src/testing/index.ts +10 -1
  173. package/src/testing/oidc-provider.ts +248 -0
  174. package/src/ui/index.ts +1 -0
  175. package/src/ui/oidc-sign-in.tsx +60 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,44 @@ Newest first. Each version lists what changed for an app that uses `@softure-ai/
4
4
  production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
5
5
  "Definition of done"). Versions before the first one below are described in their GitHub Releases (`auth@x.y.z`).
6
6
 
7
+ ## 0.2.6
8
+
9
+ Sign in with an OpenID Connect provider (Google), limited to allowed domains or emails (#769). Additive: an app without
10
+ `oidc` sees no change except two new bucket defaults.
11
+
12
+ - `auth({ oidc: { providers: [{ id, name, issuer, clientIdEnv, clientSecretEnv, allowedDomains, allowedEmails,
13
+ createAccounts, ... }] } })`: authorization code flow with PKCE S256, a one-time state bound to the browser by a
14
+ short-lived cookie, a nonce, and the ID token verified against the issuer's JWKS (RS256, ES256). `email_verified`
15
+ is required, then the allowlist; for Google a domain match also needs the `hd` claim (`requireHostedDomain`).
16
+ - New tables `auth.identities` (provider, subject → account; one per provider and account) and `auth.oidc_states`
17
+ (migration `0005`). A first sign-in links the account with the same verified email or creates one without a usable
18
+ password; later sign-ins find it by the provider's subject.
19
+ - `password: { enabled: false }`: only the provider buttons; login, registration, reset and password change refuse.
20
+ - `oidcSignInAction` and `oidcCallbackRoute` in `/next`, `OidcSignIn` in `/ui`, `startOidcSignIn` and
21
+ `completeOidcSignIn` in `/server`, `createFakeOidcProvider` in `/testing`. `LoginPage` shows the buttons and the
22
+ `?oidc_error=` message.
23
+ - `AUTH_RATE_LIMIT_BUCKETS` gains `oidc-start` and `oidc-callback` (20 per 15 minutes per client address), required
24
+ only with a provider. New error codes `auth.oidc_failed`, `auth.oidc_cancelled`, `auth.oidc_not_allowed`,
25
+ `auth.oidc_no_account`; new copy `oidc.signInWith`, `oidc.divider` and the four error messages.
26
+ - `RegisteredEvent` gains `oidcProvider` (`null` from the register form); `ChangePasswordErrorCode` gains
27
+ `auth.forbidden`. The privacy export lists `identities`, and the deletion removes them.
28
+ - Needs `@softure-ai/core` `^0.2.4` (form bodies and error bodies of `requestJson`).
29
+
30
+ Migration for an app that wants Google-only sign-in (for example one behind Cloudflare Access today):
31
+
32
+ 1. Run `softure migrate` (adds the two tables).
33
+ 2. In Google Cloud, create an OAuth client of type "Web application" with the redirect URI
34
+ `<APP_ORIGIN>/api/auth/oidc/google/callback`; for a Workspace-only app set the consent screen to "Internal".
35
+ 3. Set `GOOGLE_AUTH_CLIENT_ID` and `GOOGLE_AUTH_CLIENT_SECRET` in every environment.
36
+ 4. Add the provider to `auth({ oidc: { providers: [...] } })` with `issuer: "https://accounts.google.com"` and
37
+ `allowedDomains` (and/or `allowedEmails`), and `password: { enabled: false }` to drop the password form.
38
+ 5. Mount `app/api/auth/oidc/[provider]/callback/route.ts` with `export { oidcCallbackRoute as GET } from
39
+ "@softure-ai/auth/next";`. The app's security buckets already have the new ones when it spreads
40
+ `AUTH_RATE_LIMIT_BUCKETS`; otherwise add `oidc-start` and `oidc-callback`.
41
+ 6. Sign in once: the existing owner account (same email) is linked, nothing else changes. Then the outer sign-in in
42
+ front of the host (Cloudflare Access) and its bypass list can go, and the `create-account` password account and
43
+ change-password page are no longer needed.
44
+
7
45
  ## 0.2.5
8
46
 
9
47
  - The auth forms' submit button keeps its width while sending (#616): `LoginForm`, `RegisterForm`,
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # @softure-ai/auth
2
2
 
3
3
  Accounts for a Next.js app: register with a required consent, login, logout, password change,
4
- password reset by an emailed link, roles with admin-only surfaces that fail closed, database sessions, a route guard for `proxy.ts`, and ready pages and forms. The reference module
4
+ password reset by an emailed link, sign-in with an OpenID Connect provider (Google) limited to allowed domains or
5
+ emails, roles with admin-only surfaces that fail closed, database sessions, a route guard for `proxy.ts`, and ready pages and forms. The reference module
5
6
  of the SOFTURE standard (docs/02): it has every layer, from migrations to messages. It counts
6
7
  attempts with the rate limiter of `@softure-ai/security`, and its route guard is separate from
7
8
  channel tagging.
@@ -17,7 +18,9 @@ script), a `create-account` script for the first account of an app with registra
17
18
  `@softure-ai/auth/mailing` sends password reset mails through `@softure-ai/mailing`
18
19
  (`mailingResetSender()`); `@softure-ai/auth/jobs` sends them from a background job of `@softure-ai/jobs` with
19
20
  retry (`enqueuePasswordReset`, `passwordResetJobHandlers`). `@softure-ai/auth/testing` creates accounts directly in the database for
20
- tests (`createTestAccount`, section 4, "Tests").
21
+ tests (`createTestAccount`, section 4, "Tests") and ships a fake OpenID Connect provider (`createFakeOidcProvider`).
22
+ `auth({ oidc })` adds "Sign in with Google" (or any OpenID Connect provider) next to the password form, or instead of it
23
+ with `password: { enabled: false }` (section 3, "OpenID Connect sign-in").
21
24
 
22
25
  ## 2. Installation
23
26
 
@@ -119,10 +122,79 @@ successful or not, so a test suite that logs in many times from one address must
119
122
  passwords for one email, from any addresses, block logins to that account for the rest of the
120
123
  window, the owner's included. Raise its limit if that trade-off is wrong for your app. Auth checks
121
124
  at its first call that the buckets it counts in exist and names the missing ones: the three
122
- `password-reset*` buckets only when `passwordReset.send` is set. A request whose client address
125
+ `password-reset*` buckets only when `passwordReset.send` is set, `oidc-start` and `oidc-callback` (per client address)
126
+ only with an OpenID Connect provider. A request whose client address
123
127
  cannot be resolved is refused (`security.client_unidentified`); the security README shows resolver
124
128
  chains for production and for development and test stacks.
125
129
 
130
+ ### OpenID Connect sign-in
131
+
132
+ Sign in with Google, or any OpenID Connect provider, for the accounts of a Workspace domain or a short list of
133
+ emails. Off without providers. With `password: { enabled: false }` it is the only way in: no password, no
134
+ registration form, no outer sign-in in front of the host.
135
+
136
+ ```ts
137
+ auth({
138
+ oidc: {
139
+ providers: [
140
+ {
141
+ id: "google", // the callback is /api/auth/oidc/google/callback
142
+ name: "Google", // the button reads "Sign in with Google" (messages.oidc.signInWith)
143
+ issuer: "https://accounts.google.com", // discovery: <issuer>/.well-known/openid-configuration
144
+ clientIdEnv: "GOOGLE_AUTH_CLIENT_ID",
145
+ clientSecretEnv: "GOOGLE_AUTH_CLIENT_SECRET",
146
+ allowedDomains: ["example.com"], // a verified email of these domains...
147
+ allowedEmails: ["partner@other.test"], // ...or one of these emails
148
+ authorizeParams: { prompt: "select_account", hd: "example.com" }, // optional, sent as they are
149
+ createAccounts: true, // default; false only links existing accounts
150
+ },
151
+ ],
152
+ },
153
+ password: { enabled: false }, // optional: hide the password form and refuse every password route
154
+ });
155
+ ```
156
+
157
+ At the provider, register `<appOrigin>/api/auth/oidc/<id>/callback` as the redirect URI (Google: an OAuth client of
158
+ type "Web application"; for a Workspace-only app, set the consent screen to "Internal") and put its id and secret in
159
+ the variables the provider names.
160
+
161
+ - **Flow.** The button posts to `oidcSignInAction`: it counts `oidc-start`, stores the sign-in (`auth.oidc_states`:
162
+ the sha256 of a one-time `state`, a `nonce`, a PKCE S256 verifier and `next`), keeps the state in a short-lived
163
+ `<cookie>_oidc` cookie (host-only, `SameSite=Lax`) and sends the browser to the provider. The callback route counts
164
+ `oidc-callback`, requires the cookie's state (so a callback started in another browser is refused), consumes the
165
+ row, exchanges the code (client secret in the form, or `clientAuth: "basic"`) and verifies the ID token: RS256 or
166
+ ES256 signature against the issuer's JWKS (refetched once a minute at most when a key id is unknown), `iss`,
167
+ `aud`/`azp`, `exp`, `iat`, `nonce`. Discovery must name the configured issuer and https endpoints (http only on
168
+ localhost).
169
+ - **Who may sign in.** `email_verified` is required, then the email must be in `allowedEmails` or its domain in
170
+ `allowedDomains` (one of the two lists is required). For `https://accounts.google.com`, `requireHostedDomain`
171
+ defaults to true: a domain match also needs Google's `hd` claim to name that domain, because a consumer Google
172
+ account can carry a verified address of any domain. A refused identity goes back to the login page with
173
+ `?oidc_error=auth.oidc_not_allowed` and never gets an account.
174
+ - **Accounts.** The provider's subject finds the account (`auth.identities`), so an email change at the provider does
175
+ not lock its owner out. A first sign-in links the account with the same verified email, or creates one (with an
176
+ unusable password) when `createAccounts` is on; account creation does not look at `registrationClosed`, the
177
+ allowlist is the gate. An account keeps one identity per provider: a new subject with an email that already has one
178
+ (a recycled address) is refused with `auth.oidc_no_account`. `onRegistered` runs for a created account with
179
+ `consent: null`, `fields: {}` and `oidcProvider: "<id>"`.
180
+ - **Session.** The callback ends the sessions the browser held and opens a normal auth session, so `requireUser`,
181
+ `requireRole`, `adminEmails` and every module built on auth work unchanged. It answers a `303` to `next` (through
182
+ `rewriteRedirect`), or to the login page with `?oidc_error=<code>`: `auth.oidc_failed` (the reason is in the log
183
+ only: `OpenID Connect sign-in with google failed: id_token audience`), `auth.oidc_cancelled`,
184
+ `auth.oidc_not_allowed`, `auth.oidc_no_account`, or a rate limit code.
185
+ - **Passwords off.** `password: { enabled: false }` (needs a provider): `LoginPage` shows only the provider buttons,
186
+ `loginUser` answers `auth.invalid_credentials`, registration is closed, password reset is off and the
187
+ change-password page is not found (`changePassword` answers `auth.forbidden`).
188
+ - **Your own page.** `OidcSignIn` from `@softure-ai/auth/ui` renders the buttons
189
+ (`<OidcSignIn action={oidcSignInAction} providers={[{ id: "google", name: "Google" }]} messages={…} next="/" />`),
190
+ with `error`, `hasDivider`, `classNames` (`root`, `form`, `submit`, `divider`), `submitVariant` (`secondary` by
191
+ default) and `unstyled`. `startOidcSignIn` and `completeOidcSignIn` in `@softure-ai/auth/server` are the flow
192
+ without Next.
193
+ - **Tests.** `createFakeOidcProvider({ clock })` from `@softure-ai/auth/testing` is a provider in memory (discovery,
194
+ JWKS, token endpoint, real RS256 or ES256 signatures): pass `fake.definition` as a provider, `fake.fetch` as
195
+ `oidc.fetch` and `fake.env` as the context's `env`; `fake.signIn(authorizeUrl, { subject, email, hostedDomain })`
196
+ answers the callback URL. It can break on purpose (`claims`, `signWith`, `rotateKeys`, `failNext`, `setDiscovery`).
197
+
126
198
  ## 4. Mounting
127
199
 
128
200
  One line per file, owned by the app (docs/02 §8):
@@ -139,8 +211,12 @@ export { ForgotPasswordPage as default } from "@softure-ai/auth/next";
139
211
  export { ResetPasswordPage as default } from "@softure-ai/auth/next";
140
212
  // app/api/auth/session/route.ts: { user: { id, email } | null }, never cached
141
213
  export { getSessionRoute as GET } from "@softure-ai/auth/next";
214
+ // app/api/auth/oidc/[provider]/callback/route.ts (with auth({ oidc })): the OpenID Connect callback
215
+ export { oidcCallbackRoute as GET } from "@softure-ai/auth/next";
142
216
  ```
143
217
 
218
+ The route guard never guards `/api/auth/oidc/…`: a visitor arrives there without a session.
219
+
144
220
  The register page takes a consent label (links to your terms) and inputs of your own through
145
221
  `createRegisterPage`, so you keep the module's page:
146
222
 
@@ -549,8 +625,8 @@ module itself.
549
625
 
550
626
  `softure migrate` applies `migrations/0001_create_users_and_sessions.sql`,
551
627
  `0002_create_user_roles.sql`, `0003_create_password_resets.sql` and
552
- `0004_index_users_created_at.sql` (an index on `users.created_at` for billing's reminder mail)
553
- after security's.
628
+ `0004_index_users_created_at.sql` (an index on `users.created_at` for billing's reminder mail) and
629
+ `0005_create_identities_and_oidc_states.sql` after security's.
554
630
 
555
631
  - `auth.users(id uuid, email, password_hash, created_at, password_changed_at)`: the email is stored
556
632
  trimmed and lowercased (`CHECK`), unique; the hash must be a `scrypt$…` string.
@@ -560,6 +636,11 @@ after security's.
560
636
  `(user_id, role)`; the role name has the declared shape (`CHECK`).
561
637
  - `auth.password_resets(user_id → users ON DELETE CASCADE, token_hash, created_at, expires_at)`,
562
638
  primary key `user_id` (one pending link per account), unique `token_hash` (sha256 only).
639
+ - `auth.identities(provider, subject, user_id → users ON DELETE CASCADE, email, created_at, last_login_at)`, primary
640
+ key `(provider, subject)`, unique `(user_id, provider)`: the OpenID Connect identities; `email` is the verified
641
+ email of the last sign-in.
642
+ - `auth.oidc_states(state_hash, provider, nonce, code_verifier, next_path, created_at, expires_at)`: sign-ins in
643
+ flight (sha256 of the state only), one-time; expired rows go when the next sign-in starts.
563
644
 
564
645
  Your own tables reference `users.id` (exported as the Drizzle table `users`; roles as `userRoles`); keep app columns in
565
646
  your own 1:1 table, never in `auth.users`. Expired sessions of a user are deleted at their next
@@ -603,6 +684,7 @@ its NFC form fails, then rehashes it in NFC.
603
684
  | Name | Required | Meaning |
604
685
  | --- | --- | --- |
605
686
  | `SOFTURE_SWITCH_AUTH_REGISTRATION_CLOSED` | no | `true` / `1` closes registration, `false` / `0` opens it, over the declared default. Any other value closes it and logs the variable name. When the app defines the switch in `@softure-ai/feature-switches`, that module reads this variable by its own rules (`on` / `off` too; an unreadable value gives the fail mode). |
687
+ | `<clientIdEnv>`, `<clientSecretEnv>` | with `oidc` | The client id and secret of each OpenID Connect provider, under the names its entry declares (e.g. `GOOGLE_AUTH_CLIENT_ID`, `GOOGLE_AUTH_CLIENT_SECRET`). A missing one fails the sign-in and logs the variable's name. |
606
688
  | `SEED_EMAIL`, `SEED_PASSWORD` | for `runSeedAccount` | The development account the seed entry creates (section 4, "Development seed"). |
607
689
 
608
690
  ## 7. Switches
@@ -642,19 +724,20 @@ replace with your own page around the forms.
642
724
  `auth({ messages: { en: { login: { title: "Sign in to Acme" } } } })`; another language is the app's own
643
725
  translation under its locale, `auth({ messages: { de: authDe } })`. Groups: `fields`, `login`,
644
726
  `register`, `changePassword`, `forgotPassword`, `resetPassword`, `resetMail` (the reset mail of
645
- `mailingResetSender()`; `minutes` holds plural forms), `logout`, and `errors.{auth,security,core}` keyed by the error code
727
+ `mailingResetSender()`; `minutes` holds plural forms), `logout`, `oidc` (`signInWith` with `{provider}`, `divider`), and `errors.{auth,security,core}` keyed by the error code
646
728
  (`auth.invalid_credentials` → `errors.auth.invalid_credentials`). `getAuthErrorMessage(messages, code)`
647
729
  looks one up.
648
730
 
649
731
  ## 10. Hooks
650
732
 
651
- `onRegistered({ user, consent, fields }, ctx)`: after the user row is inserted, in the same
733
+ `onRegistered({ user, consent, fields, oidcProvider }, ctx)`: after the user row is inserted, in the same
652
734
  transaction (`ctx.db` is the transaction). `consent` is `{ acceptedAt }`, or `null` with
653
735
  `requireConsent: false`. `fields` holds the declared `registrationFields` the form sent, by name
654
736
  (strings cut to 512 characters, empty ones left out). They come from the client, and a link can set
655
737
  a carried one, so validate them before you store them. The hook runs inside the register action,
656
738
  so it can also read the request (`headers()`, `cookies()` from `next/headers`). A thrown error rolls the registration back and the user sees a generic
657
- failure. `@softure-ai/privacy` stores the consent through it.
739
+ failure. `@softure-ai/privacy` stores the consent through it. An account created by an OpenID Connect sign-in runs it
740
+ too, with `consent: null`, `fields: {}` and `oidcProvider` set to the provider's id (`null` for the register form).
658
741
 
659
742
  `passwordReset.send(link, user, details)`: after a reset request is answered, for an existing
660
743
  account only (section 4, "Password reset"). `mailingResetSender()` from `@softure-ai/auth/mailing`
@@ -670,9 +753,10 @@ contributes to `@softure-ai/privacy` (`privacy` flags on):
670
753
 
671
754
  - **Export** (`exportAuthUserData`): the account (id, email, `createdAt`, `passwordChangedAt`),
672
755
  stored roles with their grant dates, sessions (created and expiry dates) and a pending reset link
673
- (created and expiry dates). Never the password hash or a token hash. A role held through
756
+ (created and expiry dates), and OpenID Connect identities (provider, subject, email, created and last sign-in
757
+ dates). Never the password hash or a token hash. A role held through
674
758
  `adminEmails` is configuration, so it is not in the export.
675
- - **Deletion** (`deleteAuthUserData`): the user's sessions, pending reset, roles and then the
759
+ - **Deletion** (`deleteAuthUserData`): the user's sessions, pending reset, roles, identities and then the
676
760
  account row, so every session ends with the account. Privacy runs auth after the modules that
677
761
  depend on it, and the app's contributors before all modules.
678
762
 
@@ -696,5 +780,9 @@ Rate limit rows of `security` hold only SHA-256 prefixes of the email and user i
696
780
  - A temporary password from the script is not forced to change at the next login.
697
781
  - `maxAccounts` limits the `create-account` script only; registration does not count accounts. An app that must hold
698
782
  at most N accounts keeps registration closed.
783
+ - OpenID Connect: no Front-Channel or Back-Channel Logout (a sign-out at the provider leaves the app's session), no
784
+ refresh of the account's email from the provider (`users.email` keeps the first one; `identities.email` follows),
785
+ and `isCurrentPassword` cannot re-check an account that has no password of its own. With passwords on and reset
786
+ configured, the owner of an account created by a sign-in can still set a password through a reset link.
699
787
  - A registration attempt reveals whether an email has an account (`auth.email_taken`); the
700
788
  `register` rate limit bounds how fast anyone can ask.
@@ -1,6 +1,8 @@
1
1
  import type { CoreErrorCode } from "@softure-ai/core";
2
2
  import type { SecurityErrorCode } from "@softure-ai/security";
3
- export type AuthErrorCode = "auth.invalid_credentials" | "auth.email_invalid" | "auth.email_taken" | "auth.password_too_short" | "auth.password_too_long" | "auth.consent_required" | "auth.registration_closed" | "auth.current_password_invalid" | "auth.password_unchanged" | "auth.unauthenticated" | "auth.forbidden" | "auth.reset_token_invalid" | "auth.password_reset_unavailable";
3
+ export type AuthErrorCode = "auth.invalid_credentials" | "auth.email_invalid" | "auth.email_taken" | "auth.password_too_short" | "auth.password_too_long" | "auth.consent_required" | "auth.registration_closed" | "auth.current_password_invalid" | "auth.password_unchanged" | "auth.unauthenticated" | "auth.forbidden" | "auth.reset_token_invalid" | "auth.password_reset_unavailable" | "auth.oidc_failed" | "auth.oidc_cancelled" | "auth.oidc_not_allowed" | "auth.oidc_no_account";
4
+ /** Why an OpenID Connect sign-in did not open a session; the login page shows it (`?oidc_error=`). */
5
+ export type OidcSignInErrorCode = Extract<AuthErrorCode, `auth.oidc_${string}`>;
4
6
  /** Every code an auth form can show: its own, the rate limiter's and the generic ones. */
5
7
  export type AuthFormErrorCode = AuthErrorCode | Extract<SecurityErrorCode, "security.rate_limited" | "security.client_unidentified"> | CoreErrorCode;
6
8
  /** A signed-up account, as the app sees it. The password hash never leaves the module. */
@@ -27,6 +29,8 @@ export interface RegisteredEvent {
27
29
  } | null;
28
30
  /** The declared `registrationFields` the form sent, by name; client input, so validate it. */
29
31
  readonly fields: Readonly<Record<string, string>>;
32
+ /** The OpenID Connect provider of a sign-in that created the account; null for the register form. */
33
+ readonly oidcProvider: string | null;
30
34
  }
31
35
  /** The fields of the auth forms that can carry their own error. */
32
36
  export type AuthFormField = "email" | "password" | "currentPassword" | "newPassword" | "consent";
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/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ract.ts"],"names":[],"mappings":"AAkEA,MAAM,CAAC,MAAM,uBAAuB,GAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AA2EA,MAAM,CAAC,MAAM,uBAAuB,GAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -10,7 +10,8 @@ export declare const REGISTRATION_CLOSED_ENV = "SOFTURE_SWITCH_AUTH_REGISTRATION
10
10
  * Rate limit buckets auth consumes, with defaults to spread into `security({ buckets })`:
11
11
  * `register` and `login` per client address, `login-account` per email, `change-password` per user,
12
12
  * `password-reset` (link requests) and `password-reset-confirm` (new passwords) per client address,
13
- * and `password-reset-account` per email, which bounds the mails one address can receive.
13
+ * `password-reset-account` per email, which bounds the mails one address can receive, and `oidc-start` and
14
+ * `oidc-callback` (OpenID Connect sign-ins started and completed) per client address.
14
15
  */
15
16
  export declare const AUTH_RATE_LIMIT_BUCKETS: {
16
17
  readonly register: {
@@ -48,6 +49,16 @@ export declare const AUTH_RATE_LIMIT_BUCKETS: {
48
49
  readonly windowMinutes: 15;
49
50
  readonly key: "ip";
50
51
  };
52
+ readonly "oidc-start": {
53
+ readonly limit: 20;
54
+ readonly windowMinutes: 15;
55
+ readonly key: "ip";
56
+ };
57
+ readonly "oidc-callback": {
58
+ readonly limit: 20;
59
+ readonly windowMinutes: 15;
60
+ readonly key: "ip";
61
+ };
51
62
  };
52
63
  /**
53
64
  * Enables accounts in `softure.config.ts` (next to `security({ ... })`):
@@ -131,6 +142,10 @@ export declare const auth: import("@softure-ai/core").ModuleFactory<{
131
142
  logout: {
132
143
  submit: string;
133
144
  };
145
+ oidc: {
146
+ signInWith: string;
147
+ divider: string;
148
+ };
134
149
  errors: {
135
150
  auth: {
136
151
  invalid_credentials: string;
@@ -146,6 +161,10 @@ export declare const auth: import("@softure-ai/core").ModuleFactory<{
146
161
  forbidden: string;
147
162
  reset_token_invalid: string;
148
163
  password_reset_unavailable: string;
164
+ oidc_failed: string;
165
+ oidc_cancelled: string;
166
+ oidc_not_allowed: string;
167
+ oidc_no_account: string;
149
168
  };
150
169
  security: {
151
170
  rate_limited: string;
@@ -158,6 +177,7 @@ export declare const auth: import("@softure-ai/core").ModuleFactory<{
158
177
  };
159
178
  }, import("zod").ZodObject<{
160
179
  password: import("zod").ZodPrefault<import("zod").ZodObject<{
180
+ enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
161
181
  minLength: import("zod").ZodDefault<import("zod").ZodNumber>;
162
182
  scrypt: import("zod").ZodPrefault<import("zod").ZodObject<{
163
183
  cost: import("zod").ZodDefault<import("zod").ZodNumber>;
@@ -187,16 +207,64 @@ export declare const auth: import("@softure-ai/core").ModuleFactory<{
187
207
  enqueue: import("zod").ZodOptional<import("zod").ZodCustom<import("./password-reset-sender.js").PasswordResetEnqueuer, import("./password-reset-sender.js").PasswordResetEnqueuer>>;
188
208
  ttlMinutes: import("zod").ZodDefault<import("zod").ZodNumber>;
189
209
  }, import("zod/v4/core").$strict>>;
210
+ oidc: import("zod").ZodPrefault<import("zod").ZodObject<{
211
+ providers: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodPipe<import("zod").ZodObject<{
212
+ id: import("zod").ZodString;
213
+ name: import("zod").ZodString;
214
+ issuer: import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string, string>>;
215
+ clientIdEnv: import("zod").ZodString;
216
+ clientSecretEnv: import("zod").ZodOptional<import("zod").ZodString>;
217
+ clientAuth: import("zod").ZodDefault<import("zod").ZodEnum<{
218
+ body: "body";
219
+ basic: "basic";
220
+ }>>;
221
+ scopes: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
222
+ authorizeParams: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
223
+ allowedDomains: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
224
+ allowedEmails: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodEmail>>>;
225
+ requireHostedDomain: import("zod").ZodOptional<import("zod").ZodBoolean>;
226
+ createAccounts: import("zod").ZodDefault<import("zod").ZodBoolean>;
227
+ }, import("zod/v4/core").$strict>, import("zod").ZodTransform<{
228
+ requireHostedDomain: boolean;
229
+ id: string;
230
+ name: string;
231
+ issuer: string;
232
+ clientIdEnv: string;
233
+ clientAuth: "body" | "basic";
234
+ scopes: string[];
235
+ authorizeParams: Record<string, string>;
236
+ allowedDomains: string[];
237
+ allowedEmails: string[];
238
+ createAccounts: boolean;
239
+ clientSecretEnv?: string | undefined;
240
+ }, {
241
+ id: string;
242
+ name: string;
243
+ issuer: string;
244
+ clientIdEnv: string;
245
+ clientAuth: "body" | "basic";
246
+ scopes: string[];
247
+ authorizeParams: Record<string, string>;
248
+ allowedDomains: string[];
249
+ allowedEmails: string[];
250
+ createAccounts: boolean;
251
+ clientSecretEnv?: string | undefined;
252
+ requireHostedDomain?: boolean | undefined;
253
+ }>>>>;
254
+ stateTtlMinutes: import("zod").ZodDefault<import("zod").ZodNumber>;
255
+ httpTimeoutMs: import("zod").ZodDefault<import("zod").ZodNumber>;
256
+ fetch: import("zod").ZodOptional<import("zod").ZodCustom<import("@softure-ai/core").FetchFunction, import("@softure-ai/core").FetchFunction>>;
257
+ }, import("zod/v4/core").$strict>>;
190
258
  onRegistered: import("zod").ZodOptional<import("zod").ZodCustom<import("./options.js").OnRegisteredHook, import("./options.js").OnRegisteredHook>>;
191
259
  rewriteRedirect: import("zod").ZodOptional<import("zod").ZodCustom<import("./options.js").RewriteRedirect, import("./options.js").RewriteRedirect>>;
192
260
  }, import("zod/v4/core").$strict>>;
193
261
  export { INITIAL_AUTH_FORM_STATE } from "./contract.js";
194
- export type { AuthErrorCode, AuthFormErrorCode, AuthFormField, AuthFormState, AuthUser, NewSession, RegisteredEvent, SignedIn, } from "./contract.js";
262
+ export type { AuthErrorCode, AuthFormErrorCode, AuthFormField, AuthFormState, AuthUser, NewSession, OidcSignInErrorCode, RegisteredEvent, SignedIn, } from "./contract.js";
195
263
  export { authMessages, getAuthErrorMessage, type AuthMessages } from "./messages/index.js";
196
- export type { AuthOptions, AuthOptionsInput, OnRegisteredHook, RewriteRedirect, RewriteRedirectContext, ScryptParams } from "./options.js";
264
+ export { OIDC_PROVIDER_ID_PATTERN, type AuthOptions, type AuthOptionsInput, type OidcProvider, type OidcProviderInput, type OnRegisteredHook, type RewriteRedirect, type RewriteRedirectContext, type ScryptParams, } from "./options.js";
197
265
  export { consolePasswordResetSender, type PasswordResetDetails, type PasswordResetEnqueuer, type PasswordResetSender, } from "./password-reset-sender.js";
198
266
  export { getSessionCookie, type SessionCookie } from "./session-cookie.js";
199
267
  export { toSafeNextPath } from "./safe-next-path.js";
200
268
  export { ADMIN_ROLE, ROLE_NAME_PATTERN } from "./roles.js";
201
- export { passwordResets, sessions, userRoles, users } from "./schema.js";
269
+ export { identities, oidcStates, passwordResets, sessions, userRoles, users } from "./schema.js";
202
270
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,2DAA2D;AAC3D,eAAO,MAAM,0BAA0B,6BAA6B,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,4CAA4C,CAAC;AAEjF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQ+B,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAwCf,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAyCf,CAAC;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EACL,wBAAwB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -18,7 +18,8 @@ export const REGISTRATION_CLOSED_ENV = "SOFTURE_SWITCH_AUTH_REGISTRATION_CLOSED"
18
18
  * Rate limit buckets auth consumes, with defaults to spread into `security({ buckets })`:
19
19
  * `register` and `login` per client address, `login-account` per email, `change-password` per user,
20
20
  * `password-reset` (link requests) and `password-reset-confirm` (new passwords) per client address,
21
- * and `password-reset-account` per email, which bounds the mails one address can receive.
21
+ * `password-reset-account` per email, which bounds the mails one address can receive, and `oidc-start` and
22
+ * `oidc-callback` (OpenID Connect sign-ins started and completed) per client address.
22
23
  */
23
24
  export const AUTH_RATE_LIMIT_BUCKETS = {
24
25
  register: { limit: 5, windowMinutes: 15, key: "ip" },
@@ -28,6 +29,8 @@ export const AUTH_RATE_LIMIT_BUCKETS = {
28
29
  "password-reset": { limit: 10, windowMinutes: 15, key: "ip" },
29
30
  "password-reset-account": { limit: 3, windowMinutes: 15, key: "account" },
30
31
  "password-reset-confirm": { limit: 10, windowMinutes: 15, key: "ip" },
32
+ "oidc-start": { limit: 20, windowMinutes: 15, key: "ip" },
33
+ "oidc-callback": { limit: 20, windowMinutes: 15, key: "ip" },
31
34
  };
32
35
  /**
33
36
  * Enables accounts in `softure.config.ts` (next to `security({ ... })`):
@@ -36,10 +39,10 @@ export const AUTH_RATE_LIMIT_BUCKETS = {
36
39
  export const auth = defineModule({
37
40
  manifest: {
38
41
  id: MODULE_ID,
39
- version: "0.2.5",
42
+ version: "0.2.6",
40
43
  dependsOn: { security: "^0.2.0", mailing: "^0.2.0?", ops: "^0.2.0?", jobs: "^0.1.1?" },
41
44
  dbSchema: "auth",
42
- tables: ["users", "sessions", "user_roles", "password_resets"],
45
+ tables: ["users", "sessions", "user_roles", "password_resets", "identities", "oidc_states"],
43
46
  env: [
44
47
  {
45
48
  name: REGISTRATION_CLOSED_ENV,
@@ -64,6 +67,7 @@ export const auth = defineModule({
64
67
  { kind: "page", path: "app/forgot-password/page.tsx", export: "ForgotPasswordPage" },
65
68
  { kind: "page", path: "app/reset-password/page.tsx", export: "ResetPasswordPage" },
66
69
  { kind: "route-handler", path: "app/api/auth/session/route.ts", export: "getSessionRoute" },
70
+ { kind: "route-handler", path: "app/api/auth/oidc/[provider]/callback/route.ts", export: "oidcCallbackRoute" },
67
71
  { kind: "middleware", path: "proxy.ts", export: "createAuthGuard" },
68
72
  ],
69
73
  privacy: { exports: true, deletes: true },
@@ -76,9 +80,10 @@ export const auth = defineModule({
76
80
  });
77
81
  export { INITIAL_AUTH_FORM_STATE } from "./contract.js";
78
82
  export { authMessages, getAuthErrorMessage } from "./messages/index.js";
83
+ export { OIDC_PROVIDER_ID_PATTERN, } from "./options.js";
79
84
  export { consolePasswordResetSender, } from "./password-reset-sender.js";
80
85
  export { getSessionCookie } from "./session-cookie.js";
81
86
  export { toSafeNextPath } from "./safe-next-path.js";
82
87
  export { ADMIN_ROLE, ROLE_NAME_PATTERN } from "./roles.js";
83
- export { passwordResets, sessions, userRoles, users } from "./schema.js";
88
+ export { identities, oidcStates, passwordResets, sessions, userRoles, users } from "./schema.js";
84
89
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,qIAAqI;AACrI,sGAAsG;AACtG,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC;AAEhC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,0BAA0B,GAAG,0BAA0B,CAAC;AAErE;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,yCAAyC,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,GAAG,EA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0B,GAI3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC"}
@@ -69,6 +69,12 @@ export declare const en: {
69
69
  logout: {
70
70
  submit: string;
71
71
  };
72
+ oidc: {
73
+ /** The button of an OpenID Connect provider; `{provider}` is its `name` (e.g. Google). */
74
+ signInWith: string;
75
+ /** Between the provider buttons and the password form. */
76
+ divider: string;
77
+ };
72
78
  errors: {
73
79
  auth: {
74
80
  invalid_credentials: string;
@@ -84,6 +90,10 @@ export declare const en: {
84
90
  forbidden: string;
85
91
  reset_token_invalid: string;
86
92
  password_reset_unavailable: string;
93
+ oidc_failed: string;
94
+ oidc_cancelled: string;
95
+ oidc_not_allowed: string;
96
+ oidc_no_account: string;
87
97
  };
88
98
  security: {
89
99
  rate_limited: string;
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/messages/en.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2DX,qFAAqF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCxF,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/messages/en.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2DX,qFAAqF;;;;;;;;;;;;;QAQrF,0FAA0F;;QAE1F,0DAA0D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC7D,CAAC"}
@@ -64,6 +64,12 @@ export const en = {
64
64
  logout: {
65
65
  submit: "Log out",
66
66
  },
67
+ oidc: {
68
+ /** The button of an OpenID Connect provider; `{provider}` is its `name` (e.g. Google). */
69
+ signInWith: "Sign in with {provider}",
70
+ /** Between the provider buttons and the password form. */
71
+ divider: "or",
72
+ },
67
73
  errors: {
68
74
  auth: {
69
75
  invalid_credentials: "The email or password is incorrect.",
@@ -79,6 +85,10 @@ export const en = {
79
85
  forbidden: "You do not have access to this.",
80
86
  reset_token_invalid: "This link has expired or has already been used. Ask for a new one.",
81
87
  password_reset_unavailable: "Password reset is not available.",
88
+ oidc_failed: "Signing in did not work. Try again.",
89
+ oidc_cancelled: "Signing in was cancelled.",
90
+ oidc_not_allowed: "This account may not sign in here.",
91
+ oidc_no_account: "There is no account for this sign-in. Ask for access.",
82
92
  },
83
93
  security: {
84
94
  rate_limited: "Too many attempts. Wait a few minutes and try again.",
@@ -1 +1 @@
1
- {"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/messages/en.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,MAAM,EAAE;QACN,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,UAAU;QACpB,eAAe,EAAE,kBAAkB;QACnC,WAAW,EAAE,cAAc;QAC3B,eAAe,EAAE,kCAAkC;QACnD,OAAO,EAAE,uDAAuD;KACjE;IACD,KAAK,EAAE;QACL,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,aAAa;QACtB,SAAS,EAAE,iBAAiB;QAC5B,YAAY,EAAE,YAAY;QAC1B,cAAc,EAAE,uBAAuB;KACxC;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,mBAAmB;QAC1B,IAAI,EAAE,oBAAoB;QAC1B,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,WAAW;QACpB,UAAU,E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D,SAAS,EAAE,iCAAiC;YAC5C,mBAAmB,EAAE,oEAAoE;YACzF,0BAA0B,EAAE,kCAAkC;YAC9D,WAAW,EAAE,qCAAqC;YAClD,cAAc,EAAE,2BAA2B;YAC3C,gBAAgB,EAAE,oCAAoC;YACtD,eAAe,EAAE,uDAAuD;SACzE;QACD,QAAQ,EAAE;YACR,YAAY,EAAE,sDAAsD;YACpE,mBAAmB,EAAE,oEAAoE;SAC1F;QACD,IAAI,EAAE;YACJ,eAAe,EAAE,0DAA0D;YAC3E,UAAU,EAAE,0DAA0D;SACvE;KACF;CACF,CAAC"}
@@ -72,6 +72,10 @@ export declare const authMessages: {
72
72
  logout: {
73
73
  submit: string;
74
74
  };
75
+ oidc: {
76
+ signInWith: string;
77
+ divider: string;
78
+ };
75
79
  errors: {
76
80
  auth: {
77
81
  invalid_credentials: string;
@@ -87,6 +91,10 @@ export declare const authMessages: {
87
91
  forbidden: string;
88
92
  reset_token_invalid: string;
89
93
  password_reset_unavailable: string;
94
+ oidc_failed: string;
95
+ oidc_cancelled: string;
96
+ oidc_not_allowed: string;
97
+ oidc_no_account: string;
90
98
  };
91
99
  security: {
92
100
  rate_limited: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,0GAA0G;AAC1G,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAS,CAAC;AAEnC,MAAM,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC;AAErC,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAI3F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,0GAA0G;AAC1G,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAS,CAAC;AAEnC,MAAM,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC;AAErC,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAI3F"}
@@ -14,6 +14,11 @@ export declare function forgotPasswordAction(_previous: AuthFormState, formData:
14
14
  * and its token is used by then.
15
15
  */
16
16
  export declare function resetPasswordAction(_previous: AuthFormState, formData: FormData): Promise<AuthFormState>;
17
+ /**
18
+ * Starts an OpenID Connect sign-in: the provider button's form posts `provider` and `next`. The state goes into a
19
+ * short-lived cookie and the browser to the provider; a failure goes back to the login page, which shows its code.
20
+ */
21
+ export declare function oidcSignInAction(formData: FormData): Promise<void>;
17
22
  /** Where to go after logout: a path on this app, checked like login's `next`. */
18
23
  export interface LogoutInput {
19
24
  readonly next?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/next/actions.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAoC,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA8EtF,wBAAsB,WAAW,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,CAiBtG;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,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