@protobase/cli 0.105.1 → 0.105.3
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/dist/cli/package.js +1 -1
- package/dist/dev/api-forward.js +3 -3
- package/package.json +8 -8
- package/skills/protobase/references/features/sign-in-and-accounts.md +2 -0
- package/skills/protobase/references/reference/auth.md +81 -4
- package/skills/protobase/references/reference/cli.md +1 -1
- package/skills/protobase/references/reference/config/sign-in.md +15 -4
package/dist/cli/package.js
CHANGED
package/dist/dev/api-forward.js
CHANGED
|
@@ -6,10 +6,10 @@ import { request } from "node:http";
|
|
|
6
6
|
//#region src/dev/api-forward.ts
|
|
7
7
|
/**
|
|
8
8
|
* The requests the API process answers: everything under /api, the passkey origins at /.well-known/webauthn, the OAuth
|
|
9
|
-
* discovery documents MCP clients read (`oauthWellKnownPaths`), below which a
|
|
10
|
-
* (`withDevServiceWorker`). Vite serves the rest.
|
|
9
|
+
* discovery documents MCP clients and the OpenID provider's clients read (`oauthWellKnownPaths`), below which a
|
|
10
|
+
* resource's own one is, and the push worker (`withDevServiceWorker`). Vite serves the rest.
|
|
11
11
|
*/
|
|
12
|
-
const apiRequestPattern = /^(\/api(\/|\?|$)|\/\.well-known\/webauthn(\?|$)|\/\.well-known\/oauth-
|
|
12
|
+
const apiRequestPattern = /^(\/api(\/|\?|$)|\/\.well-known\/webauthn(\?|$)|\/\.well-known\/(oauth-authorization-server|oauth-protected-resource|openid-configuration)(\/|\?|$)|\/protobase\.sw\.js(\?|$))/;
|
|
13
13
|
const isApiRequest = (url) => apiRequestPattern.test(url);
|
|
14
14
|
const hopByHop = /* @__PURE__ */ new Set([
|
|
15
15
|
"connection",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.105.
|
|
3
|
+
"version": "0.105.3",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@better-auth/core": "^1.7.12",
|
|
45
45
|
"@hono/node-server": "^2.1.3",
|
|
46
|
-
"@protobase/config": "0.105.
|
|
47
|
-
"@protobase/layout": "0.105.
|
|
48
|
-
"@protobase/query": "0.105.
|
|
49
|
-
"@protobase/schema": "0.105.
|
|
50
|
-
"@protobase/server": "0.105.
|
|
51
|
-
"@protobase/ui": "0.105.
|
|
52
|
-
"@protobase/workflows": "0.105.
|
|
46
|
+
"@protobase/config": "0.105.3",
|
|
47
|
+
"@protobase/layout": "0.105.3",
|
|
48
|
+
"@protobase/query": "0.105.3",
|
|
49
|
+
"@protobase/schema": "0.105.3",
|
|
50
|
+
"@protobase/server": "0.105.3",
|
|
51
|
+
"@protobase/ui": "0.105.3",
|
|
52
|
+
"@protobase/workflows": "0.105.3",
|
|
53
53
|
"@react-email/render": "^2.1.0",
|
|
54
54
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
55
55
|
"@sentry/vite-plugin": "^11.10.0",
|
|
@@ -19,6 +19,7 @@ Sign-in methods, users, roles, organizations and tokens.
|
|
|
19
19
|
- [Changing the address](../reference/auth.md#changing-the-address): People move their account to a new email address from the account page, once they enter the code sent there.
|
|
20
20
|
- [Deleting the account](../reference/auth.md#deleting-the-account): People delete their own account from the account page, after confirming it, in the web app and the mobile app. On by default; an app whose accounts an organization's admins manage turns it off.
|
|
21
21
|
- [Open sign-up](../reference/auth.md#open-sign-up): Anyone can create an account after confirming an emailed code.
|
|
22
|
+
- [Sign-up with the address only](../reference/auth.md#sign-up-with-the-address-only): Open sign-up can ask for nothing but the address, so the emailed sign-in code makes a new person's account on the spot; an invited address still gets the roles it was invited with.
|
|
22
23
|
- [Sign-up for email domains](../reference/auth.md#sign-up-for-email-domains): Open sign-up can take only addresses at your company's email domains, so colleagues make their own account and everyone else still needs an invitation.
|
|
23
24
|
- [Passkeys](../reference/auth.md#passkeys): People sign in with their device's face or fingerprint unlock, or with a security key.
|
|
24
25
|
- [Two-factor authentication](../reference/auth.md#two-factor-authentication): A second step with an authenticator app, backup codes or emailed codes.
|
|
@@ -31,6 +32,7 @@ Sign-in methods, users, roles, organizations and tokens.
|
|
|
31
32
|
- [SAML sign-in](../reference/auth.md#sign-in-with-saml): People sign in through any SAML provider.
|
|
32
33
|
- [OpenID Connect provider](../reference/auth.md#platform-sign-in-provider): A host adds an OpenID Connect provider for people who already have an account.
|
|
33
34
|
- [Token sign-in](../reference/auth.md#token-sign-in): A client that holds a fresh ID token from that provider for this app signs in with it once, in place of an emailed code, and gets the app's own session, with the app's second step when one is on.
|
|
35
|
+
- [Being an OpenID provider](../reference/auth.md#openid-provider-for-other-apps): The app vouches for its people's verified addresses to other apps its admin registers, which sign them in without asking them to allow it, and lets a phone app get a sign-in token for each of those apps, or for any app at the origins it names by pattern, without a browser.
|
|
34
36
|
- [Staff sign-in](../reference/auth.md#staff-sign-in): The team that runs an app signs in as a person to help them, with a reason and a log entry.
|
|
35
37
|
- [Roles](../reference/auth.md#roles): A user holds one or more roles and switches between them without signing in again.
|
|
36
38
|
- [Organizations](../reference/auth.md#organizations): People work in one organization at a time, see only its records, and are invited with their own roles.
|
|
@@ -173,7 +173,7 @@ export { usersPage } from '@protobase/layout' // at /accounts, for admins
|
|
|
173
173
|
export const accountMenu = userMenu((m) => [m.page('accounts', { label: 'Users', icon: 'users' })])
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
New apps have it already. Leave the export out to drop it, or make a page of your own around the [`Users` block](blocks.md#users). It works with or without [organizations](#organizations): an invitation to the app makes an account with the roles the admin ticked, from the same link page and sign-up as an organization's invitation, and someone with an account just signs in. Listing, creating, roles and blocking are Better Auth's admin endpoints (`/api/auth/admin/list-users`, `create-user`, `set-role`, `ban-user`, `unban-user`), whose roles go as a list; the rest are Protobase's, for admins only:
|
|
176
|
+
New apps have it already. Leave the export out to drop it, or make a page of your own around the [`Users` block](blocks.md#users). It works with or without [organizations](#organizations): an invitation to the app makes an account with the roles the admin ticked, from the same link page and sign-up as an organization's invitation, or from [open sign-up](#open-sign-up) with the invited address, and someone with an account just signs in. Listing, creating, roles and blocking are Better Auth's admin endpoints (`/api/auth/admin/list-users`, `create-user`, `set-role`, `ban-user`, `unban-user`), whose roles go as a list; the rest are Protobase's, for admins only:
|
|
177
177
|
|
|
178
178
|
| Endpoint | Does |
|
|
179
179
|
| --- | --- |
|
|
@@ -336,7 +336,7 @@ auth: { signInFirst: 'emailCode' }
|
|
|
336
336
|
```
|
|
337
337
|
|
|
338
338
|
- A code works for 10 minutes, once, and three wrong tries end it; asking again sends a new one and the old one stops working. Codes are stored hashed.
|
|
339
|
-
- It
|
|
339
|
+
- It creates no account, unless [open sign-up asks for the address only](#sign-up-with-the-address-only): an address no account uses gets no code but an email saying so, which suggests signing in with the address the person signed up with. The answer is the same either way, so it does not tell who has an account.
|
|
340
340
|
- Only sign-in codes are mailed this way. The plugin's own email verification and password reset endpoints are off (`404`), and asking for another type of code answers `400`. Its address change is on, as [Changing the address](#changing-the-address) describes.
|
|
341
341
|
- An account with [two-factor authentication](#two-factor-authentication) is asked for its second step after the code too, as after a password.
|
|
342
342
|
- An account created by Protobase 0.3 or earlier, which has a password, is marked verified the first time it uses a code. Otherwise Better Auth would treat the code as taking over an unverified account and delete its password.
|
|
@@ -355,12 +355,29 @@ The sign-in page then offers "Create an account", and so do [sign-in prompts](ui
|
|
|
355
355
|
- It needs mail: without a mailer it is not offered, `GET /api/auth/status` has no `signUp`, and its endpoints answer `404`. Not with [organizations](#organizations), whose people join by invitation.
|
|
356
356
|
- `POST /api/auth/sign-up/send-code` with `{ email }` mails the code. It answers the same whether the address has an account or not; an address that has one is mailed a note saying so instead of a code, with a link to the sign-in page, so nobody can tell from the answer, and no second account is made.
|
|
357
357
|
- `POST /api/auth/sign-up/verify-code` with `{ email, code }` checks the code on its own and answers `{ ticket }`. A code works for 10 minutes, once, and three wrong tries end it; asking again sends a new one. Codes are stored hashed.
|
|
358
|
-
- `POST /api/auth/sign-up/create` with `{ ticket, name, password? }` makes the account for the address whose code was right, and signs in. A ticket works for 30 minutes, once, and is stored hashed; a password the policy refuses leaves it for another try. A used or expired one answers `SIGN_UP_TICKET_INVALID`, and the sign-up starts again with the address.
|
|
358
|
+
- `POST /api/auth/sign-up/create` with `{ ticket, name, password? }` makes the account for the address whose code was right, and signs in. `name` is optional when sign-up [asks for the address only](#sign-up-with-the-address-only). A ticket works for 30 minutes, once, and is stored hashed; a password the policy refuses leaves it for another try. A used or expired one answers `SIGN_UP_TICKET_INVALID`, and the sign-up starts again with the address.
|
|
359
359
|
- The password follows the [sign-in policy](#sign-in-policy) as for an invitation: none while passwords are off, optional while emailed codes are on, 12 characters or more. What the policy requires, such as two-factor authentication, is set up after the first sign-in, as for every account.
|
|
360
|
+
- An address with a pending [invitation to the app](#users-page) gets its account through the invitation: with the roles the admin ticked instead of `role`, and the invitation is used up, as its link would. A revoked or expired invitation counts as none.
|
|
360
361
|
- The three requests are limited per minute and client like sign-in (`signInPerMinute`, default 5), and refused (`NO_ADMIN_YET`) while the store has no user.
|
|
361
362
|
- The `onUserCreated` [hook](#hooks) runs for every account made this way.
|
|
362
363
|
- `createAuthSession` from `@protobase/client` has the three steps as `sendSignUpCode(email)`, `verifySignUpCode(email, code)`, which resolves to the ticket, and `signUp({ ticket, name, password? })`, which resolves to the signed-in user.
|
|
363
364
|
|
|
365
|
+
### Sign-up with the address only
|
|
366
|
+
|
|
367
|
+
An app that needs nothing but a verified address, such as a sign-in server other apps send their people to, has open sign-up ask for the address alone:
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
auth: { roles: ['admin', 'member'], signUp: { role: 'member', fields: ['email'] } }
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
- `fields` is what sign-up asks for: `['email', 'name']` by default, or `['email']`. The address is always one of them; any other list stops the app at start with an error.
|
|
374
|
+
- The [emailed sign-in code](#emailed-sign-in-codes) then signs in an address that has an account, and makes the account of one that has none, on the spot, once its code is right: verified, with `role`, and an empty name the person can fill in on the [account page](#account-page). Asking for the code answers the same and mails the same email whether the address has an account or not.
|
|
375
|
+
- An address with a pending [invitation to the app](#users-page) gets its account through it, as with the sign-up page: the invited roles, and the invitation used up. A revoked or expired one counts as none.
|
|
376
|
+
- An address open sign-up does not take, outside [its domains](#sign-up-for-email-domains) or while the store has no user, still gets the no-account email and no account. While the [sign-in policy](#sign-in-policy) turns emailed codes off, asking for one is refused and nothing is made.
|
|
377
|
+
- "Create an account" makes the account as soon as its code is right, without asking a name; while the policy needs a password, because emailed codes are off, the last page asks only for that.
|
|
378
|
+
- `GET /api/auth/status` answers `signUpFields: ["email"]`, and `["email", "name"]` by default, beside `signUp`.
|
|
379
|
+
- Not with [organizations](#organizations), like all open sign-up: their people come in by invitation, and the emailed code never makes an account there.
|
|
380
|
+
|
|
364
381
|
### Sign-up for email domains
|
|
365
382
|
|
|
366
383
|
A company's app can let colleagues make their own account while everyone else still needs an invitation, with the email domains open sign-up takes:
|
|
@@ -507,7 +524,7 @@ PROTOBASE_OPERATOR_NAME="Protobase Cloud" # shown as "Continue
|
|
|
507
524
|
PROTOBASE_OPERATOR_GROUP=protobase-staff-access # the default
|
|
508
525
|
```
|
|
509
526
|
|
|
510
|
-
Set the first three together or none: some but not all of them stops the app at start with an error. In the config, `auth.operator` takes the same settings and a few more, and `false` turns staff sign-in off whatever the environment says:
|
|
527
|
+
Set the first three together or none: some but not all of them stops the app at start with an error. The one exception is [token sign-in alone](#token-sign-in): `PROTOBASE_SIGN_IN_ISSUER` with `PROTOBASE_SIGN_IN_TOKENS=true`, and no secret. In the config, `auth.operator` takes the same settings and a few more, and `false` turns staff sign-in off whatever the environment says:
|
|
511
528
|
|
|
512
529
|
```ts
|
|
513
530
|
auth: { operator: { issuer, clientId, clientSecret, name: 'Support', group: 'support-leads', scopes: ['groups'], acrValues: ['gold'], sessionMinutes: 15 } }
|
|
@@ -611,6 +628,7 @@ auth: { signInProvider: { issuer, clientId, clientSecret, tokenSignIn: true } }
|
|
|
611
628
|
The client posts `POST /api/auth/sign-in/social` with `{ "provider": "<provider id>", "idToken": { "token": "<ID token>" } }`, as Better Auth's client sends `signIn.social({ provider, idToken: { token } })`, and gets the session cookie with `{ redirect: false, user }`, or `{ twoFactorRedirect: true, twoFactorMethods }` when the [second step](#two-factor-authentication) is due, which it finishes as after a password. Then `GET /api/auth/token` gives it the app's API token as for any session.
|
|
612
629
|
|
|
613
630
|
- **Only this app's own provider:** the app trusts the one provider it is configured with, and a token only for this app. The token must be signed with a key the provider publishes (its discovery's `jwks_uri`) with an asymmetric algorithm, come from the configured issuer, and have this app's client id as its one audience, so a token issued for another app is never accepted here. It must carry an `email` (a `jti` is not needed), live at most 5 minutes from `iat` to `exp`, and have been issued within the last 5 minutes (30 seconds of clock skew allowed). Otherwise it is refused with `401 INVALID_TOKEN`.
|
|
631
|
+
- **Alone, without a client secret:** with the issuer and `PROTOBASE_SIGN_IN_TOKENS=true` but no `PROTOBASE_SIGN_IN_CLIENT_SECRET` (`signInProvider: { issuer, tokenSignIn: true }`), the app is no client of the provider's: it takes tokens whose audience is the origin of its `url`, or `PROTOBASE_SIGN_IN_CLIENT_ID` when set, as from the [token exchange](#token-exchange) of an OpenID provider's `audiences`. Nobody is sent through the provider's pages: the sign-in page shows no button for it, and starting or connecting it answers `403 PROVIDER_PAGES_OFF`.
|
|
614
632
|
- **Once:** each token signs in once. Its issuer and the SHA-256 of its claims are kept in the `verification` table until it expires, with no migration, and a second use answers `401 TOKEN_USED`. The claims count, not the token's text, so the same token written another way is refused too, and so is a second token with exactly the same claims.
|
|
615
633
|
- **Who it signs in:** as through the provider's pages, the account linked to the provider's `sub`, else the account with the address the provider vouches for (`email_verified`), which it links. Nobody is signed up (`401`), and a banned person is refused.
|
|
616
634
|
- **Never recent:** the client can mint a fresh session at will, so a session a token began never counts as [recently signed in](#confirming-an-account-change). Adding a passkey, unlinking a provider, making a personal access token or deleting the account asks it to confirm it's them in place first, and it is never a [strong sign-in](#recent-strong-sign-in) until it confirms it's them.
|
|
@@ -846,6 +864,65 @@ auth: { mcp: true, oauth: { api: true } }
|
|
|
846
864
|
- Notifications and calls refuse these tokens, as they refuse an MCP client's.
|
|
847
865
|
- <gap>The app's API cannot take DPoP-bound access tokens because checking a proof against the API's URLs is not implemented.</gap> A token bound to a key is refused when it is sent as a bearer token.
|
|
848
866
|
|
|
867
|
+
## OpenID provider for other apps
|
|
868
|
+
|
|
869
|
+
With `openIdProvider`, the app is an OpenID provider for the clients its admins register, such as other apps that let people sign in with it: a person signs in on the app's own pages, as they always do, and the client gets an ID token that says who they are. Nobody is asked to allow a client, since only an admin registers one. A phone app the admin registers can also get ID tokens for every app at the origins `audiences` names, with no registration per app, through the [token exchange](#token-exchange).
|
|
870
|
+
|
|
871
|
+
```ts
|
|
872
|
+
auth: { openIdProvider: true }
|
|
873
|
+
auth: { openIdProvider: { connectPage: '/-/connect', audiences: ['https://*.example.app'] } }
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
- **Audiences** are https origins, exact (`https://shop.example.com`) or with one leading wildcard label (`https://*.example.app`, which stands for `shop.example.app` but not `example.app` or `a.b.example.app`). A wildcard needs two labels after it, and a pattern takes no port, path, query or user info; anything else stops the app at start. An app at such an origin gets ID tokens only from the token exchange: no browser is ever sent there, so an authorize whose client id or redirect URI is on such a host is refused (`400 invalid_request`), and so is registering a client with a redirect URI there (`400 REDIRECT_ON_AUDIENCE_HOST`).
|
|
877
|
+
|
|
878
|
+
- **Only registered clients.** Nothing registers itself: `/api/auth/oauth2/register` is closed, and so are the provider's own client management, consent, userinfo, introspection and logout endpoints. A client the admin did not register through the API below is refused with `400 invalid_client` at authorize and at the token endpoint, before anything else, and so is a client in the store from elsewhere, such as one an MCP client registered while the app had `mcp` on. A redirect URI must be one the client registered, character for character, so the person's browser is never sent with a code, or an error, to an address of someone else's.
|
|
879
|
+
- **Not with `mcp`.** MCP clients register themselves, and the provider of this mode is separate from MCP's, so the server refuses to start with both. Serve them from separate apps.
|
|
880
|
+
- **Discovery** is at `/.well-known/openid-configuration`, with the app's `url` as issuer, and the keys at `/api/auth/jwks`. A client uses the authorization code flow with PKCE, with `openid email profile`, and a `nonce`.
|
|
881
|
+
- **The ID token** is signed with the app's [signing keys](#signing-keys) (EdDSA) and lives 5 minutes. It carries `iss` (the app's `url`), `aud` (the client's id, alone), `sub` (the person's user id in this app), `email`, `email_verified`, and `name` when the person has one. It has no `jti`. Another Protobase app takes it as its [platform sign-in provider](#platform-sign-in-provider), through its pages or by [token sign-in](#token-sign-in).
|
|
882
|
+
- **Signing in** goes through the connect page (`connectPage`, default `/-/connect`), which signs the person in and goes straight on to the client. Someone who has not set up what the [sign-in policy](#sign-in-policy) requires is sent to the setup page first, and staff signed in as a person get no token.
|
|
883
|
+
|
|
884
|
+
### Registering clients
|
|
885
|
+
|
|
886
|
+
An admin registers, lists and deletes the clients with their own session; anyone else is refused with `403 ADMIN_ONLY`:
|
|
887
|
+
|
|
888
|
+
```http
|
|
889
|
+
POST /api/auth/openid-provider/clients
|
|
890
|
+
{ "name": "Shop", "redirectUris": ["https://shop.example.com/api/auth/callback/oidc"], "type": "confidential" }
|
|
891
|
+
→ { "clientId": "...", "clientSecret": "..." }
|
|
892
|
+
|
|
893
|
+
GET /api/auth/openid-provider/clients
|
|
894
|
+
→ [{ "clientId": "...", "name": "Shop", "redirectUris": [...], "type": "confidential", "exchange": false }]
|
|
895
|
+
|
|
896
|
+
POST /api/auth/openid-provider/clients/delete
|
|
897
|
+
{ "clientId": "..." }
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
- `confidential` is an app with a server, which authenticates with the secret it gets once, in a Basic header; `public` is an app on a device, such as a phone app, which has no secret and uses PKCE alone.
|
|
901
|
+
- Every client skips consent, must use PKCE, and gets the scopes `openid email profile`.
|
|
902
|
+
- `exchange: true` lets a client exchange its access token for ID tokens of the other clients (below), and gives it refresh tokens (`offline_access`). Only the app that signs people in on their device for the other apps should have it: it can sign its people in to every other client.
|
|
903
|
+
- Deleting a client deletes its tokens too, so its refresh tokens stop at once.
|
|
904
|
+
|
|
905
|
+
### Token exchange
|
|
906
|
+
|
|
907
|
+
A client registered with `exchange: true`, such as a phone app the person signed in to once, gets an ID token for another registered client, or for an origin of `audiences`, without a browser, and posts it to that app's [token sign-in](#token-sign-in). It is the token exchange of RFC 8693 at the token endpoint:
|
|
908
|
+
|
|
909
|
+
```http
|
|
910
|
+
POST /api/auth/oauth2/token
|
|
911
|
+
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
|
|
912
|
+
&client_id=<its own id>
|
|
913
|
+
&subject_token=<its access token>
|
|
914
|
+
&subject_token_type=urn:ietf:params:oauth:token-type:access_token
|
|
915
|
+
&requested_token_type=urn:ietf:params:oauth:token-type:id_token
|
|
916
|
+
&audience=<the other client's id, or an origin such as https://shop.example.app>
|
|
917
|
+
→ { "access_token": "<ID token>", "issued_token_type": "urn:ietf:params:oauth:token-type:id_token", "token_type": "N_A", "expires_in": 300 }
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
- **The subject is the caller's own person.** `subject_token` must be a live access token this app issued to the calling client itself: not an ID token, a refresh token or another client's token, not expired, revoked or from a session that ended. Otherwise it answers `400 invalid_grant`. A client without `exchange` gets `400 unauthorized_client`.
|
|
921
|
+
- **The audience is another registered client, or an origin of `audiences`**: not the caller, not an unknown client and not one the admin did not register (`400 invalid_target`). An origin is matched as the URL parser writes it, label by label, so `http://`, a port, a path or trailing slash, user info, upper case, an extra label (`a.b.example.app`) and look-alikes (`example.app.evil.com`, `evilexample.app`) are refused.
|
|
922
|
+
- **An ID token only.** The answer is an ID token for that client or origin alone, living 5 minutes, with the claims of the client's own sign-in; one for an origin has that origin as `aud`, and a `jti`. No access or refresh token for the other client leaves the app. `requested_token_type` and `subject_token_type` take only the values above (`400 invalid_request`).
|
|
923
|
+
- **A banned person, or one whose address is not verified,** gets none (`400 invalid_grant`). A ban after the token was issued is caught by the other app, which checks its own account at sign-in.
|
|
924
|
+
- The token endpoint takes 20 requests a minute per client address.
|
|
925
|
+
|
|
849
926
|
## Several origins
|
|
850
927
|
|
|
851
928
|
An app can be served on more than one origin, such as its platform address and the customer's own domain. `auth.origins` lists the others; it defaults to `PROTOBASE_ORIGINS`, which a platform sets:
|
|
@@ -253,7 +253,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
253
253
|
"server": "protobase.config.js",
|
|
254
254
|
"public": "public",
|
|
255
255
|
"spa": "index.html",
|
|
256
|
-
"api": ["/api", "/.well-known/oauth-authorization-server", "/.well-known/oauth-protected-resource"],
|
|
256
|
+
"api": ["/api", "/.well-known/oauth-authorization-server", "/.well-known/oauth-protected-resource", "/.well-known/openid-configuration"],
|
|
257
257
|
"theme": "protobase.theme.css",
|
|
258
258
|
"plugins": [
|
|
259
259
|
{ "name": "app", "path": "plugins/app/plugin.json", "api": 1, "protobase": ">=0.12.0", "fields": { "steps": ["enum"] } }
|
|
@@ -61,10 +61,10 @@ export default defineConfig({ auth: { organizations: { create: 'everyone', invit
|
|
|
61
61
|
|
|
62
62
|
## auth.signUp
|
|
63
63
|
|
|
64
|
-
- **Type:** `{ role: string; domains?: string[] }`
|
|
64
|
+
- **Type:** `{ role: string; domains?: string[]; fields?: ('email' | 'name')[] }`
|
|
65
65
|
- **Default:** off
|
|
66
66
|
|
|
67
|
-
Open sign-up: anyone makes their own account from the sign-in page, with `role`, after proving their address with an emailed code. Needs a mailer. `role` is one of [`roles`](#authroles) and never `admin`. `domains` takes only addresses at those email domains, subdomains included, and `PROTOBASE_SIGN_UP_DOMAINS` replaces it; an empty list leaves sign-up off. Not with organizations. See [Open sign-up](../auth.md#open-sign-up)
|
|
67
|
+
Open sign-up: anyone makes their own account from the sign-in page, with `role`, after proving their address with an emailed code. Needs a mailer. `role` is one of [`roles`](#authroles) and never `admin`. `domains` takes only addresses at those email domains, subdomains included, and `PROTOBASE_SIGN_UP_DOMAINS` replaces it; an empty list leaves sign-up off. `fields` is what it asks for, `['email', 'name']` by default; `['email']` has the emailed sign-in code make the account of a new address. Not with organizations. See [Open sign-up](../auth.md#open-sign-up), [Sign-up for email domains](../auth.md#sign-up-for-email-domains) and [Sign-up with the address only](../auth.md#sign-up-with-the-address-only).
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
70
|
export default defineConfig({ auth: { roles: ['admin', 'customer'], signUp: { role: 'customer' } } })
|
|
@@ -167,11 +167,11 @@ export default defineConfig(({ env }) => ({
|
|
|
167
167
|
|
|
168
168
|
## auth.signInProvider
|
|
169
169
|
|
|
170
|
-
- **Type:** `{ issuer: string; clientId
|
|
170
|
+
- **Type:** `{ issuer: string; clientId?: string; clientSecret?: string; provider?: string; name?: string; scopes?: string[]; tokenSignIn?: boolean } | false`
|
|
171
171
|
- **Default:** the provider of the environment variables below, when set
|
|
172
172
|
- **Environment variables:** `PROTOBASE_SIGN_IN_ISSUER`, `PROTOBASE_SIGN_IN_CLIENT_ID`, `PROTOBASE_SIGN_IN_CLIENT_SECRET`, and optionally `PROTOBASE_SIGN_IN_PROVIDER`, `PROTOBASE_SIGN_IN_NAME` and `PROTOBASE_SIGN_IN_TOKENS` (`true` or `false`)
|
|
173
173
|
|
|
174
|
-
An OpenID Connect provider the platform adds for people who already have an account; it never signs anyone up. `provider` is its id (default `oidc`), `name` its button's name, and `tokenSignIn: true` lets a client sign in with a fresh ID token the provider issued for this app ([Token sign-in](../auth.md#token-sign-in), default off). `false` turns it off whatever the environment says. Left out when `socialProviders` has a provider with the same id. See [Platform sign-in provider](../auth.md#platform-sign-in-provider).
|
|
174
|
+
An OpenID Connect provider the platform adds for people who already have an account; it never signs anyone up. `provider` is its id (default `oidc`), `name` its button's name, and `tokenSignIn: true` lets a client sign in with a fresh ID token the provider issued for this app ([Token sign-in](../auth.md#token-sign-in), default off). `false` turns it off whatever the environment says. Left out when `socialProviders` has a provider with the same id. Without `clientSecret` it signs in by token sign-in alone, which `tokenSignIn: true` must then turn on, with tokens for the origin of `url` unless `clientId` names another. See [Platform sign-in provider](../auth.md#platform-sign-in-provider).
|
|
175
175
|
|
|
176
176
|
```ts
|
|
177
177
|
export default defineConfig({ auth: { signInProvider: false } })
|
|
@@ -317,6 +317,17 @@ What the OAuth provider of [`auth.mcp`](#authmcp) serves besides MCP. `api: true
|
|
|
317
317
|
export default defineConfig({ auth: { mcp: true, oauth: { api: true } } })
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
+
## auth.openIdProvider
|
|
321
|
+
|
|
322
|
+
- **Type:** `true | { connectPage?: string; audiences?: string[] }`
|
|
323
|
+
- **Default:** off
|
|
324
|
+
|
|
325
|
+
Makes the app an OpenID provider for the clients its admins register at `/api/auth/openid-provider/clients`, such as other apps that sign people in with it: they get an ID token with the person's `sub`, `email` and `email_verified`, without asking the person to allow them, and nothing else can register. A client allowed to exchange gets ID tokens for the other clients, and for the origins `audiences` names as patterns such as `https://*.example.app`, without a browser. `connectPage` is the page people sign in on (default `/-/connect`). Not with [`auth.mcp`](#authmcp); the server refuses to start with both. See [OpenID provider for other apps](../auth.md#openid-provider-for-other-apps).
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
export default defineConfig({ auth: { openIdProvider: true } })
|
|
329
|
+
```
|
|
330
|
+
|
|
320
331
|
## auth.personalAccessTokens
|
|
321
332
|
|
|
322
333
|
- **Type:** `{ prefix: string }`
|