or3-provider-basic-auth 0.0.17 → 0.0.19
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/README.md
CHANGED
|
@@ -5,6 +5,13 @@ Basic-auth provider for OR3 Chat SSR mode.
|
|
|
5
5
|
Rejected registration requests preserve existing login cookies, including when
|
|
6
6
|
the request fails the mutation origin policy. Sign-out still clears the session.
|
|
7
7
|
|
|
8
|
+
After credentials are accepted, OR3 Chat loads the canonical workspace session.
|
|
9
|
+
Updated hosts show a persistent **Unable to load your account** notification
|
|
10
|
+
with **Retry** if that step fails. Retry reuses the accepted credentials, so a
|
|
11
|
+
temporary workspace-service outage does not require registering again or
|
|
12
|
+
resubmitting a password. Local Convex development requires its backend to remain
|
|
13
|
+
running alongside OR3 Chat. This recovery feedback is provided by the host.
|
|
14
|
+
|
|
8
15
|
Requires **Node.js 24.22.1 or newer on the 24.x line**, matching OR3 Chat. Development and CI pin **24.22.1** in `.node-version`.
|
|
9
16
|
|
|
10
17
|
This package registers:
|
|
@@ -191,6 +198,12 @@ Optional:
|
|
|
191
198
|
- `OR3_BASIC_AUTH_ALLOW_INSECURE_DEV` (`true` in non-production to start with missing secrets instead of failing)
|
|
192
199
|
- `OR3_PLUGIN_DEV_COOKIE_SCOPE` (set by the isolated plugin development launcher to keep browser sessions separate across local hosts)
|
|
193
200
|
|
|
201
|
+
When both bootstrap values are set, the first account is created before the
|
|
202
|
+
server accepts requests. An existing account is preserved on restart; changing
|
|
203
|
+
the bootstrap password does not reset it. Bootstrap errors stop startup rather
|
|
204
|
+
than leaving the server available with an unusable initial login. Request-time
|
|
205
|
+
password hashing remains asynchronous.
|
|
206
|
+
|
|
194
207
|
Registration mode is a core-auth policy, not a provider setting:
|
|
195
208
|
|
|
196
209
|
- `OR3_AUTH_REGISTRATION_MODE=open|invite_only|disabled`
|
package/dist/module.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import bcrypt from "bcryptjs";
|
|
2
2
|
import { newPasswordFitsBcrypt } from "../../password-policy.js";
|
|
3
3
|
const PASSWORD_COST = 12;
|
|
4
|
-
|
|
4
|
+
function assertPasswordLength(password) {
|
|
5
5
|
if (!newPasswordFitsBcrypt(password)) {
|
|
6
6
|
throw new RangeError("New passwords must be 72 UTF-8 bytes or fewer.");
|
|
7
7
|
}
|
|
8
|
+
}
|
|
9
|
+
export function hashPasswordSync(password) {
|
|
10
|
+
assertPasswordLength(password);
|
|
11
|
+
return bcrypt.hashSync(password, PASSWORD_COST);
|
|
12
|
+
}
|
|
13
|
+
export async function hashPassword(password) {
|
|
14
|
+
assertPasswordLength(password);
|
|
8
15
|
return await bcrypt.hash(password, PASSWORD_COST);
|
|
9
16
|
}
|
|
10
17
|
export async function verifyPassword(password, hash) {
|
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
isBasicAuthInsecureDevEscapeHatchEnabled,
|
|
13
13
|
validateBasicAuthConfig
|
|
14
14
|
} from "../lib/config.js";
|
|
15
|
-
import {
|
|
15
|
+
import { hashPasswordSync } from "../lib/password.js";
|
|
16
16
|
import { ensureBootstrapAccount, findAccountByEmail } from "../lib/session-store.js";
|
|
17
17
|
import { basicAuthAdminAdapter } from "../admin/adapters/auth-basic-auth.js";
|
|
18
|
-
|
|
18
|
+
function ensureBootstrapUserIfConfigured() {
|
|
19
19
|
const config = getBasicAuthConfig();
|
|
20
20
|
const email = config.bootstrapEmail?.trim();
|
|
21
21
|
const password = config.bootstrapPassword;
|
|
@@ -25,14 +25,14 @@ async function ensureBootstrapUserIfConfigured() {
|
|
|
25
25
|
if (findAccountByEmail(email)) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const passwordHash =
|
|
28
|
+
const passwordHash = hashPasswordSync(password);
|
|
29
29
|
ensureBootstrapAccount({
|
|
30
30
|
email,
|
|
31
31
|
passwordHash,
|
|
32
32
|
displayName: email
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
export default defineNitroPlugin(
|
|
35
|
+
export default defineNitroPlugin(() => {
|
|
36
36
|
const runtimeConfig = useRuntimeConfig();
|
|
37
37
|
const diagnostics = validateBasicAuthConfig(runtimeConfig);
|
|
38
38
|
for (const warning of diagnostics.warnings) {
|
|
@@ -54,6 +54,7 @@ export default defineNitroPlugin(async () => {
|
|
|
54
54
|
}
|
|
55
55
|
throw new Error(message);
|
|
56
56
|
}
|
|
57
|
+
ensureBootstrapUserIfConfigured();
|
|
57
58
|
registerAuthProvider({
|
|
58
59
|
id: BASIC_AUTH_PROVIDER_ID,
|
|
59
60
|
order: 100,
|
|
@@ -61,5 +62,4 @@ export default defineNitroPlugin(async () => {
|
|
|
61
62
|
});
|
|
62
63
|
registerProviderTokenBroker(BASIC_AUTH_PROVIDER_ID, createBasicAuthTokenBroker);
|
|
63
64
|
registerProviderAdminAdapter(basicAuthAdminAdapter);
|
|
64
|
-
await ensureBootstrapUserIfConfigured();
|
|
65
65
|
});
|