@jskit-ai/auth-provider-oidc-core 0.2.46 → 0.2.48
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/CHANGELOG.md +1 -0
- package/package.json +5 -5
- package/patterns/oidc-sign-in/example/package.json +2 -2
- package/src/server/lib/config.js +6 -6
- package/src/server/lib/service.js +4 -4
- package/test/providerRuntime.test.js +1 -1
- package/test/relyingPartySecurity.test.js +1 -1
- package/test-support/harness.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- **Breaking:** staging and production (`APP_ENV`), not `NODE_ENV=production`, require `AUTH_OIDC_SESSION_SECRET` and use the `__Host-` session cookie; the config's `isProduction` is now `isDeployed`.
|
|
5
6
|
- The second-factor operations (`getSecondFactorStatus`, `startSecondFactorSetup`, `confirmSecondFactorSetup`, `verifySecondFactor`, `replaceSecondFactorRecoveryCodes`, `removeSecondFactor`, `listSecondFactors`, `resetSecondFactor`) answer `AUTH_OPERATION_UNSUPPORTED`, and `features.secondFactor` is false: the hub asks for its own second factors.
|
|
6
7
|
- `./server/lib/index` exports `OIDC_CLIENT_INFRASTRUCTURE_TABLES` (`auth_oidc_clients`, `auth_oidc_sessions`, `auth_oidc_logout_tokens`), the protocol state the relying party keeps outside table resources, for an app test's `expectEveryTableOwned({ infrastructureTables })`.
|
|
7
8
|
- An ordinary request synchronizes the app profile only when it is missing or no longer matches the identity its session keeps from sign-in (`onlyWhenChanged`); sign-in synchronizes in full. The session is still read on every request. Visible difference: a personal workspace, owner membership or settings row deleted while someone is signed in comes back at their next sign-in instead of their next request.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/auth-provider-oidc-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.48",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"openid-client": "6.8.8"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@jskit-ai/auth-provider-local-core": "0.2.
|
|
24
|
-
"@jskit-ai/auth-web": "0.2.
|
|
23
|
+
"@jskit-ai/auth-provider-local-core": "0.2.36",
|
|
24
|
+
"@jskit-ai/auth-web": "0.2.44",
|
|
25
25
|
"oidc-provider": "9.12.2"
|
|
26
26
|
},
|
|
27
27
|
"description": "Sign in through any OpenID Connect issuer: self-registration or a static client, app-owned sessions, and back-channel logout.",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@jskit-ai/auth-core": "0.2.
|
|
95
|
-
"@jskit-ai/kernel": "0.2.
|
|
94
|
+
"@jskit-ai/auth-core": "0.2.30",
|
|
95
|
+
"@jskit-ai/kernel": "0.2.27"
|
|
96
96
|
}
|
|
97
97
|
}
|
package/src/server/lib/config.js
CHANGED
|
@@ -44,13 +44,13 @@ function resolveAppName(appRoot) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function resolveSessionSecret(env, { appRoot,
|
|
47
|
+
function resolveSessionSecret(env, { appRoot, isDeployed }) {
|
|
48
48
|
const explicit = text(env.AUTH_OIDC_SESSION_SECRET);
|
|
49
49
|
if (explicit) {
|
|
50
50
|
if (explicit.length < 32) throw new Error("AUTH_OIDC_SESSION_SECRET must be at least 32 characters.");
|
|
51
51
|
return explicit;
|
|
52
52
|
}
|
|
53
|
-
if (
|
|
53
|
+
if (isDeployed) throw new Error("AUTH_OIDC_SESSION_SECRET is required in staging and production.");
|
|
54
54
|
const storeDir = path.resolve(appRoot, text(env.AUTH_OIDC_STORE_DIR) || DEFAULT_STORE_DIR);
|
|
55
55
|
const secretPath = path.join(storeDir, SESSION_SECRET_FILE);
|
|
56
56
|
try {
|
|
@@ -69,12 +69,12 @@ function resolveSessionSecret(env, { appRoot, isProduction }) {
|
|
|
69
69
|
* Reads the OIDC sign-in Env. Malformed values stop the app with one sentence.
|
|
70
70
|
* A missing issuer or client is not fatal: the app runs and sign-in explains
|
|
71
71
|
* what to set (`setupProblem`), so a project can be prepared before its
|
|
72
|
-
* accounts hub exists.
|
|
72
|
+
* accounts hub exists. Whether it is deployed is worked out once, by auth-core's dev auth
|
|
73
73
|
* policy, so sign-in and dev sign-in agree on it.
|
|
74
74
|
*/
|
|
75
75
|
function resolveOidcConfig({ env = {}, appRoot = process.cwd() } = {}) {
|
|
76
76
|
const devAuth = resolveDevAuthPolicyFromEnv(env);
|
|
77
|
-
const {
|
|
77
|
+
const { isDeployed } = devAuth;
|
|
78
78
|
const issuerValue = text(env.AUTH_OIDC_ISSUER);
|
|
79
79
|
const registrationToken = text(env.AUTH_OIDC_REGISTRATION_TOKEN);
|
|
80
80
|
const clientId = text(env.AUTH_OIDC_CLIENT_ID);
|
|
@@ -105,14 +105,14 @@ function resolveOidcConfig({ env = {}, appRoot = process.cwd() } = {}) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
return Object.freeze({
|
|
108
|
-
|
|
108
|
+
isDeployed,
|
|
109
109
|
issuer,
|
|
110
110
|
registrationToken,
|
|
111
111
|
staticClient: clientId ? Object.freeze({ clientId, clientSecret }) : null,
|
|
112
112
|
label: text(env.AUTH_OIDC_LABEL) || AUTH_OIDC_DEFAULT_LABEL,
|
|
113
113
|
appName: resolveAppName(appRoot),
|
|
114
114
|
appPublicOrigin,
|
|
115
|
-
sessionSecret: resolveSessionSecret(env, { appRoot,
|
|
115
|
+
sessionSecret: resolveSessionSecret(env, { appRoot, isDeployed }),
|
|
116
116
|
devAuth,
|
|
117
117
|
setupProblem: setupProblem?.message || "",
|
|
118
118
|
setupProblemCode: setupProblem?.code || ""
|
|
@@ -89,11 +89,11 @@ function buildResult(identity, { session = null, appProfile = null } = {}) {
|
|
|
89
89
|
*/
|
|
90
90
|
function createOidcAuthService({ config, store, issuer, profileProjector, logger, now = Date.now }) {
|
|
91
91
|
const sealer = createTransactionSealer({ secret: config.sessionSecret, now });
|
|
92
|
-
const secureCookies = config.
|
|
93
|
-
//
|
|
92
|
+
const secureCookies = config.isDeployed;
|
|
93
|
+
// Staging and production sessions use a host-only __Host- cookie, like the other providers.
|
|
94
94
|
const sessionCookie = hostOnlyCookieName(SESSION_COOKIE, secureCookies);
|
|
95
95
|
const appProfileProjection = profileProjector !== noAppProfiles;
|
|
96
|
-
const devLoginEnabled = config.devAuth.enabled === true && config.devAuth.
|
|
96
|
+
const devLoginEnabled = config.devAuth.enabled === true && config.devAuth.isDeployed !== true;
|
|
97
97
|
const capabilities = normalizeAuthCapabilities({
|
|
98
98
|
provider: { id: AUTH_OIDC_PROVIDER_ID, label: config.label },
|
|
99
99
|
features: {
|
|
@@ -162,7 +162,7 @@ function createOidcAuthService({ config, store, issuer, profileProjector, logger
|
|
|
162
162
|
} catch {
|
|
163
163
|
throw new AppError(400, "This request has no usable address.", { code: "auth.oidc.request.noAddress" });
|
|
164
164
|
}
|
|
165
|
-
if (origin.protocol === "http:" && !isLoopbackHostname(origin.hostname) && config.
|
|
165
|
+
if (origin.protocol === "http:" && !isLoopbackHostname(origin.hostname) && config.isDeployed) {
|
|
166
166
|
throw new AppError(400, "Set APP_PUBLIC_URL so sign-in returns to this app's https address.", {
|
|
167
167
|
code: "auth.oidc.request.publicUrlRequired"
|
|
168
168
|
});
|
|
@@ -44,7 +44,7 @@ async function startApp(t, { env = {}, configureExtensions = () => {} } = {}) {
|
|
|
44
44
|
"runtime.app-root": appRoot,
|
|
45
45
|
"runtime.database": { knex },
|
|
46
46
|
"runtime.env": {
|
|
47
|
-
|
|
47
|
+
APP_ENV: "test",
|
|
48
48
|
AUTH_OIDC_ISSUER: issuer.issuer,
|
|
49
49
|
AUTH_OIDC_REGISTRATION_TOKEN: issuer.registrationToken,
|
|
50
50
|
...env
|
|
@@ -148,7 +148,7 @@ test("production sessions use a host-only __Host- cookie", async (t) => {
|
|
|
148
148
|
const issuer = await startMockIssuer();
|
|
149
149
|
const rp = await createRelyingParty({
|
|
150
150
|
issuer,
|
|
151
|
-
env: { NODE_ENV: "production", AUTH_OIDC_SESSION_SECRET: "fixture-oidc-session-secret-0123456789" }
|
|
151
|
+
env: { APP_ENV: "production", NODE_ENV: "production", AUTH_OIDC_SESSION_SECRET: "fixture-oidc-session-secret-0123456789" }
|
|
152
152
|
});
|
|
153
153
|
t.after(async () => {
|
|
154
154
|
await rp.close();
|
package/test-support/harness.js
CHANGED
|
@@ -82,7 +82,7 @@ async function createRelyingParty({ issuer, env = {}, fetchImpl = globalThis.fet
|
|
|
82
82
|
const config = resolveOidcConfig({
|
|
83
83
|
appRoot,
|
|
84
84
|
env: {
|
|
85
|
-
|
|
85
|
+
APP_ENV: "development",
|
|
86
86
|
AUTH_OIDC_ISSUER: issuer.issuer,
|
|
87
87
|
AUTH_OIDC_REGISTRATION_TOKEN: issuer.registrationToken,
|
|
88
88
|
...env
|