@o3co/create-auth-provider 0.15.0 → 0.17.0-rc.1
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.ja.md +139 -48
- package/README.md +138 -47
- package/dist/index.d.mts +33 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +118 -59
- package/dist/internal/template-filter.d.mts +7 -10
- package/dist/internal/template-filter.d.mts.map +1 -1
- package/dist/internal/template-filter.mjs +7 -10
- package/package.json +6 -4
- package/templates/standalone/.dockerignore +15 -2
- package/templates/standalone/.env.example +69 -24
- package/templates/standalone/Dockerfile +7 -3
- package/templates/standalone/README.ja.md +677 -184
- package/templates/standalone/README.md +699 -238
- package/templates/standalone/config/application.conf +203 -325
- package/templates/standalone/config/clients.yaml +2 -0
- package/templates/standalone/config/clients.yaml.example +4 -0
- package/templates/standalone/config/development.conf +13 -4
- package/templates/standalone/config/mailpit.conf +8 -0
- package/templates/standalone/config/production.conf +5 -6
- package/templates/standalone/config/reference.conf +399 -0
- package/templates/standalone/docker-compose.mailpit.yml +36 -0
- package/templates/standalone/docker-compose.production.yml +58 -30
- package/templates/standalone/docker-compose.yml +13 -3
- package/templates/standalone/gitignore +4 -2
- package/templates/standalone/package.json +9 -6
- package/templates/standalone/src/__tests__/access-token-lifetime-alias.test.mts +65 -32
- package/templates/standalone/src/__tests__/adapters.test.mts +358 -0
- package/templates/standalone/src/__tests__/all-modules-composition.fixture.mts +1178 -0
- package/templates/standalone/src/__tests__/all-modules-composition.multi.test.mts +256 -0
- package/templates/standalone/src/__tests__/all-modules-composition.test.mts +1119 -0
- package/templates/standalone/src/__tests__/audit-sink.test.mts +78 -76
- package/templates/standalone/src/__tests__/configPath.test.mts +13 -11
- package/templates/standalone/src/__tests__/core-federations.test.mts +226 -0
- package/templates/standalone/src/__tests__/core-sections.test.mts +190 -0
- package/templates/standalone/src/__tests__/device-code-store-client-module.test.mts +9 -14
- package/templates/standalone/src/__tests__/documented-env-overrides.test.mts +672 -271
- package/templates/standalone/src/__tests__/federation-grants-composition.test.mts +480 -78
- package/templates/standalone/src/__tests__/federation-grants-survive-logout.test.mts +102 -66
- package/templates/standalone/src/__tests__/federation-token-refresh-outage.test.mts +135 -0
- package/templates/standalone/src/__tests__/google-federation-config-module.test.mts +49 -18
- package/templates/standalone/src/__tests__/google-session.fixture.mts +315 -0
- package/templates/standalone/src/__tests__/host-routes.test.mts +134 -0
- package/templates/standalone/src/__tests__/library-references.fixture.mts +183 -0
- package/templates/standalone/src/__tests__/listen.test.mts +121 -0
- package/templates/standalone/src/__tests__/logger-projection.test.mts +77 -0
- package/templates/standalone/src/__tests__/mail-sender.test.mts +134 -0
- package/templates/standalone/src/__tests__/mailpit-compose.test.mts +328 -0
- package/templates/standalone/src/__tests__/metrics.test.mts +17 -7
- package/templates/standalone/src/__tests__/mfa-switch.redis.test.mts +123 -0
- package/templates/standalone/src/__tests__/mfa-switch.test.mts +780 -0
- package/templates/standalone/src/__tests__/oidc-federation-config-module.test.mts +52 -46
- package/templates/standalone/src/__tests__/own-modules.test.mts +1457 -0
- package/templates/standalone/src/__tests__/post-logout-redirect.test.mts +183 -0
- package/templates/standalone/src/__tests__/redis-connection-error-log.test.mts +135 -0
- package/templates/standalone/src/__tests__/redis-rate-limiter-config-survives.test.mts +112 -81
- package/templates/standalone/src/__tests__/refresh-token-family-client-module.test.mts +25 -31
- package/templates/standalone/src/__tests__/replica-safety.test.mts +166 -145
- package/templates/standalone/src/__tests__/router-error-answers.test.mts +146 -0
- package/templates/standalone/src/__tests__/scaffold-assets.test.mts +275 -95
- package/templates/standalone/src/__tests__/sections.test.mts +480 -0
- package/templates/standalone/src/__tests__/session-logout-invalidates-token.test.mts +67 -55
- package/templates/standalone/src/__tests__/session-requirements.test.mts +299 -0
- package/templates/standalone/src/__tests__/shutdown.test.mts +319 -115
- package/templates/standalone/src/__tests__/smoke.test.mts +179 -233
- package/templates/standalone/src/__tests__/store-credential.test.mts +317 -0
- package/templates/standalone/src/__tests__/supertest-loopback.test.mts +182 -11
- package/templates/standalone/src/__tests__/three-tier-resolution.test.mts +108 -95
- package/templates/standalone/src/__tests__/two-phase-config.test.mts +438 -0
- package/templates/standalone/src/__tests__/upstream-amr.acceptance.test.mts +390 -0
- package/templates/standalone/src/adapters.mts +149 -0
- package/templates/standalone/src/app.mts +71 -115
- package/templates/standalone/src/buildModules.mts +229 -251
- package/templates/standalone/src/configPath.mts +422 -29
- package/templates/standalone/src/listen.mts +60 -0
- package/templates/standalone/src/logger.mts +31 -57
- package/templates/standalone/src/metrics.mts +24 -47
- package/templates/standalone/src/mfaSwitch.mts +262 -0
- package/templates/standalone/src/modules.mts +480 -464
- package/templates/standalone/src/rootRenames.mts +79 -0
- package/templates/standalone/src/routes.mts +89 -0
- package/templates/standalone/src/sections.mts +366 -0
- package/templates/standalone/src/shutdown.mts +54 -126
- package/templates/standalone/tests/index.test.js +2 -2
- package/templates/standalone/tests/package-lock.json +1615 -2223
- package/templates/standalone/tests/package.json +2 -2
- package/templates/standalone/tests/vitest.config.mjs +26 -0
- package/templates/standalone/vitest.config.mts +8 -7
- package/templates/standalone/vitest.supertest-loopback.mts +97 -69
- package/templates/versions.json +18 -15
- package/templates/standalone/src/__tests__/terminal-error.test.mts +0 -96
- package/templates/standalone/src/terminalError.mts +0 -60
|
@@ -14,14 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import
|
|
18
|
-
import { makeValidAppConfig } from "@o3co/auth-provider-core/testing";
|
|
17
|
+
import { coreConfigForTests, makeValidAppConfig } from "@o3co/auth-provider-core/testing";
|
|
19
18
|
import { describe, expect, it } from "vitest";
|
|
20
19
|
import { buildModules } from "../buildModules.mjs";
|
|
20
|
+
import type { Switches } from "../configPath.mjs";
|
|
21
21
|
import { oidcFederationConfigModule } from "../modules.mjs";
|
|
22
|
+
import { inProcessAdapters } from "./library-references.fixture.mjs";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* The scaffold turns every enabled `core.federations.<name>` of type
|
|
25
26
|
* `oidc` into one instance of the generic OIDC federation module, fed by a
|
|
26
27
|
* single config bridge. A deployment adds an IdP with configuration only.
|
|
27
28
|
*/
|
|
@@ -40,45 +41,46 @@ const okta = {
|
|
|
40
41
|
callbackURL: "https://auth.test/session/oauth/federation/okta/callback",
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
/** Core's valid fixture, with the federations under test and every
|
|
44
|
-
const configWith = (federations: Record<string, unknown>):
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} as unknown as
|
|
51
|
-
};
|
|
44
|
+
/** Core's valid fixture, with the federations under test and every store in process. */
|
|
45
|
+
const configWith = (federations: Record<string, unknown>): Switches =>
|
|
46
|
+
({
|
|
47
|
+
...makeValidAppConfig(),
|
|
48
|
+
...coreConfigForTests({ declaredAbsent: ["auditSink"], federations: federations as never }),
|
|
49
|
+
adapters: inProcessAdapters(),
|
|
50
|
+
mfaMode: "off",
|
|
51
|
+
}) as unknown as Switches;
|
|
52
52
|
|
|
53
|
-
describe("oidcFederationConfigModule
|
|
53
|
+
describe("oidcFederationConfigModule", () => {
|
|
54
54
|
it("has the scaffold's module name and reads config", () => {
|
|
55
|
-
expect(oidcFederationConfigModule.name).toBe("
|
|
55
|
+
expect(oidcFederationConfigModule.name).toBe("oidc-federation-config");
|
|
56
56
|
expect(oidcFederationConfigModule.requires).toEqual(["config"]);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
it("reads every enabled oidc section into the slot, keyed by federation name", () => {
|
|
60
60
|
const out = bridge({
|
|
61
61
|
config: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
core: {
|
|
63
|
+
federations: {
|
|
64
|
+
okta: { enabled: true, type: "oidc", ...okta },
|
|
65
|
+
keycloak: {
|
|
66
|
+
enabled: true,
|
|
67
|
+
type: "oidc",
|
|
68
|
+
clientUrl: "https://app.test/",
|
|
69
|
+
oidc: {
|
|
70
|
+
issuer: "https://kc.test/realms/dev",
|
|
71
|
+
clientId: "kc-client",
|
|
72
|
+
clientSecret: "kc-secret",
|
|
73
|
+
callbackURL: "https://auth.test/session/oauth/federation/keycloak/callback",
|
|
74
|
+
},
|
|
73
75
|
},
|
|
76
|
+
google: {
|
|
77
|
+
enabled: true,
|
|
78
|
+
clientId: "g",
|
|
79
|
+
clientSecret: "s",
|
|
80
|
+
callbackURL: "https://auth.test/g",
|
|
81
|
+
},
|
|
82
|
+
paused: { enabled: false, type: "oidc", ...okta },
|
|
74
83
|
},
|
|
75
|
-
google: {
|
|
76
|
-
enabled: true,
|
|
77
|
-
clientId: "g",
|
|
78
|
-
clientSecret: "s",
|
|
79
|
-
callbackURL: "https://auth.test/g",
|
|
80
|
-
},
|
|
81
|
-
paused: { enabled: false, type: "oidc", ...okta },
|
|
82
84
|
},
|
|
83
85
|
},
|
|
84
86
|
});
|
|
@@ -93,17 +95,21 @@ describe("oidcFederationConfigModule (#524)", () => {
|
|
|
93
95
|
it("refuses a malformed section at boot, naming the field", () => {
|
|
94
96
|
const { issuer: _dropped, ...noIssuer } = okta;
|
|
95
97
|
expect(() =>
|
|
96
|
-
bridge({
|
|
97
|
-
|
|
98
|
+
bridge({
|
|
99
|
+
config: { core: { federations: { okta: { enabled: true, type: "oidc", ...noIssuer } } } },
|
|
100
|
+
}),
|
|
101
|
+
).toThrow(/core\.federations\.okta\.issuer/);
|
|
98
102
|
});
|
|
99
103
|
|
|
100
104
|
it("is an empty slot when no section is of type oidc", () => {
|
|
101
|
-
expect(bridge({ config: { federations: { google: { enabled: false } } } })).toEqual(
|
|
105
|
+
expect(bridge({ config: { core: { federations: { google: { enabled: false } } } } })).toEqual(
|
|
106
|
+
{},
|
|
107
|
+
);
|
|
102
108
|
});
|
|
103
109
|
});
|
|
104
110
|
|
|
105
|
-
describe("buildModules gating for OIDC federations
|
|
106
|
-
it("lists one federation
|
|
111
|
+
describe("buildModules gating for OIDC federations", () => {
|
|
112
|
+
it("lists one federation-oidc-<name> per enabled section, plus the bridge once", () => {
|
|
107
113
|
const names = buildModules(
|
|
108
114
|
configWith({
|
|
109
115
|
okta: { enabled: true, type: "oidc", ...okta },
|
|
@@ -111,10 +117,10 @@ describe("buildModules gating for OIDC federations (#524)", () => {
|
|
|
111
117
|
google: { enabled: false },
|
|
112
118
|
}),
|
|
113
119
|
).map((m) => m.name);
|
|
114
|
-
expect(names).toContain("federation
|
|
115
|
-
expect(names).toContain("federation
|
|
116
|
-
expect(names.filter((n) => n === "
|
|
117
|
-
expect(names).not.toContain("federation
|
|
120
|
+
expect(names).toContain("federation-oidc-okta");
|
|
121
|
+
expect(names).toContain("federation-oidc-keycloak");
|
|
122
|
+
expect(names.filter((n) => n === "oidc-federation-config")).toHaveLength(1);
|
|
123
|
+
expect(names).not.toContain("federation-google");
|
|
118
124
|
});
|
|
119
125
|
|
|
120
126
|
it("a google section of type oidc is the generic provider, not the built-in Google pair", () => {
|
|
@@ -123,16 +129,16 @@ describe("buildModules gating for OIDC federations (#524)", () => {
|
|
|
123
129
|
const names = buildModules(
|
|
124
130
|
configWith({ google: { enabled: true, type: "oidc", ...okta } }),
|
|
125
131
|
).map((m) => m.name);
|
|
126
|
-
expect(names).toContain("federation
|
|
127
|
-
expect(names).not.toContain("federation
|
|
128
|
-
expect(names).not.toContain("
|
|
132
|
+
expect(names).toContain("federation-oidc-google");
|
|
133
|
+
expect(names).not.toContain("federation-google");
|
|
134
|
+
expect(names).not.toContain("google-federation-config");
|
|
129
135
|
});
|
|
130
136
|
|
|
131
137
|
it("lists nothing OIDC when no section is enabled (the shipped default)", () => {
|
|
132
138
|
const names = buildModules(
|
|
133
139
|
configWith({ google: { enabled: false }, oidc: { enabled: false, type: "oidc" } }),
|
|
134
140
|
).map((m) => m.name);
|
|
135
|
-
expect(names.some((n) => n.startsWith("federation
|
|
136
|
-
expect(names).not.toContain("
|
|
141
|
+
expect(names.some((n) => n.startsWith("federation-oidc-"))).toBe(false);
|
|
142
|
+
expect(names).not.toContain("oidc-federation-config");
|
|
137
143
|
});
|
|
138
144
|
});
|