@xemahq/oidc-session-nest 1.0.1 → 1.1.0

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 (54) hide show
  1. package/README.md +26 -0
  2. package/dist/config/oidc-session-config-error.d.ts +4 -0
  3. package/dist/config/oidc-session-config-error.d.ts.map +1 -0
  4. package/dist/config/oidc-session-config-error.js +11 -0
  5. package/dist/config/oidc-session-config-error.js.map +1 -0
  6. package/dist/config/oidc-session-env.d.ts +4 -0
  7. package/dist/config/oidc-session-env.d.ts.map +1 -1
  8. package/dist/config/oidc-session-env.js +61 -6
  9. package/dist/config/oidc-session-env.js.map +1 -1
  10. package/dist/config/oidc-session-options.d.ts +10 -4
  11. package/dist/config/oidc-session-options.d.ts.map +1 -1
  12. package/dist/config/oidc-session-options.js +49 -20
  13. package/dist/config/oidc-session-options.js.map +1 -1
  14. package/dist/config/redirect-origin.d.ts +12 -0
  15. package/dist/config/redirect-origin.d.ts.map +1 -0
  16. package/dist/config/redirect-origin.js +113 -0
  17. package/dist/config/redirect-origin.js.map +1 -0
  18. package/dist/errors.d.ts +9 -1
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/errors.js +15 -1
  21. package/dist/errors.js.map +1 -1
  22. package/dist/http/request-authority.d.ts +19 -0
  23. package/dist/http/request-authority.d.ts.map +1 -0
  24. package/dist/http/request-authority.js +71 -0
  25. package/dist/http/request-authority.js.map +1 -0
  26. package/dist/index.d.ts +6 -3
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +15 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/nest/oidc-session-auth.controller.d.ts.map +1 -1
  31. package/dist/nest/oidc-session-auth.controller.js +10 -1
  32. package/dist/nest/oidc-session-auth.controller.js.map +1 -1
  33. package/dist/nest/oidc-session-context.d.ts +2 -0
  34. package/dist/nest/oidc-session-context.d.ts.map +1 -1
  35. package/dist/nest/oidc-session-context.js.map +1 -1
  36. package/dist/nest/oidc-session.middleware.d.ts +3 -1
  37. package/dist/nest/oidc-session.middleware.d.ts.map +1 -1
  38. package/dist/nest/oidc-session.middleware.js +12 -1
  39. package/dist/nest/oidc-session.middleware.js.map +1 -1
  40. package/dist/nest/redirect-targets.d.ts +8 -0
  41. package/dist/nest/redirect-targets.d.ts.map +1 -0
  42. package/dist/nest/redirect-targets.js +45 -0
  43. package/dist/nest/redirect-targets.js.map +1 -0
  44. package/dist/oidc/oidc-client.d.ts +4 -1
  45. package/dist/oidc/oidc-client.d.ts.map +1 -1
  46. package/dist/oidc/oidc-client.js +17 -5
  47. package/dist/oidc/oidc-client.js.map +1 -1
  48. package/dist/session/session-service.d.ts +2 -1
  49. package/dist/session/session-service.d.ts.map +1 -1
  50. package/dist/session/session-service.js +10 -2
  51. package/dist/session/session-service.js.map +1 -1
  52. package/dist/session/session-store.d.ts +1 -0
  53. package/dist/session/session-store.d.ts.map +1 -1
  54. package/package.json +5 -5
package/README.md CHANGED
@@ -110,6 +110,32 @@ differently because they name different things.
110
110
  Both values go through the same URL builder as `state`, `nonce` and
111
111
  `redirect_uri`, so they are encoded rather than spliced.
112
112
 
113
+ ### One backend on several addresses
114
+
115
+ A fixed `OIDC_REDIRECT_URI` sends every sign-in back to one address. When the
116
+ same backend is served on several addresses — a production host and a preview
117
+ host, say — each must sign in and out on its own, because the session cookie is
118
+ host-only. Declare the allowed origins instead:
119
+
120
+ | Variable | Meaning |
121
+ |---|---|
122
+ | `OIDC_REDIRECT_ALLOWED_ORIGINS` | Comma-separated origins, e.g. `https://app.example.com,https://*-preview.example.com`. One `*` may open the first label only. |
123
+ | `OIDC_REDIRECT_PATH` | The callback path on that origin, e.g. `/auth/callback`. Required with the above. |
124
+ | `OIDC_POST_LOGOUT_REDIRECT_PATH` | Optional. Where end-session returns, on the same origin. |
125
+ | `OIDC_TRUSTED_PROXIES` | Optional. IPs or CIDRs whose `X-Forwarded-Host` is believed. Absent means the header is never read and the `Host` header decides. |
126
+
127
+ The two forms are exclusive, and the loader refuses both together or neither.
128
+
129
+ - The redirect URI is `<the request's origin><OIDC_REDIRECT_PATH>`. An origin
130
+ that is not on the list answers `400 OIDC_REDIRECT_ORIGIN_NOT_ALLOWED`, and
131
+ there is no default address to fall back to.
132
+ - The redirect URI is bound to the sign-in's pending state. A callback that
133
+ arrives on a different address answers `400 OIDC_LOGIN_ORIGIN_MISMATCH`, and
134
+ the code is never exchanged.
135
+ - The code exchange sends the bound value, so it always matches the value the
136
+ authorization request carried.
137
+ - Keep `SESSION_COOKIE_DOMAIN` unset, so each address keeps its own session.
138
+
113
139
  ## Peer requirements
114
140
 
115
141
  - `@nestjs/common` and `@nestjs/core` `^10 || ^11` — the framework this mounts into.
@@ -0,0 +1,4 @@
1
+ export declare class OidcSessionConfigError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ //# sourceMappingURL=oidc-session-config-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidc-session-config-error.d.ts","sourceRoot":"","sources":["../../src/config/oidc-session-config-error.ts"],"names":[],"mappings":"AAMA,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OidcSessionConfigError = void 0;
4
+ class OidcSessionConfigError extends Error {
5
+ constructor(message) {
6
+ super(`[oidc-session-nest] ${message}`);
7
+ this.name = 'OidcSessionConfigError';
8
+ }
9
+ }
10
+ exports.OidcSessionConfigError = OidcSessionConfigError;
11
+ //# sourceMappingURL=oidc-session-config-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidc-session-config-error.js","sourceRoot":"","sources":["../../src/config/oidc-session-config-error.ts"],"names":[],"mappings":";;;AAMA,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC"}
@@ -1,6 +1,10 @@
1
1
  import { type OidcSessionOptions } from './oidc-session-options';
2
2
  export type EnvReader = (name: string) => string | undefined;
3
3
  export declare const OIDC_SESSION_REQUIRED_ENV_VARS: readonly string[];
4
+ export declare const OIDC_SESSION_REDIRECT_ENV_VARS: {
5
+ readonly fixed: readonly ["OIDC_REDIRECT_URI", "OIDC_POST_LOGOUT_REDIRECT_URI"];
6
+ readonly perOrigin: readonly ["OIDC_REDIRECT_ALLOWED_ORIGINS", "OIDC_REDIRECT_PATH", "OIDC_POST_LOGOUT_REDIRECT_PATH", "OIDC_TRUSTED_PROXIES"];
7
+ };
4
8
  export declare const OIDC_SESSION_OPTIONAL_ENV_VARS: readonly string[];
5
9
  export declare function loadOidcSessionOptionsFromEnv(read: EnvReader): OidcSessionOptions;
6
10
  //# sourceMappingURL=oidc-session-env.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oidc-session-env.d.ts","sourceRoot":"","sources":["../../src/config/oidc-session-env.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAU7D,eAAO,MAAM,8BAA8B,EAAE,SAAS,MAAM,EAK3D,CAAC;AAOF,eAAO,MAAM,8BAA8B,EAAE,SAAS,MAAM,EAc3D,CAAC;AAoBF,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,SAAS,GACd,kBAAkB,CAiDpB"}
1
+ {"version":3,"file":"oidc-session-env.d.ts","sourceRoot":"","sources":["../../src/config/oidc-session-env.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,kBAAkB,EAExB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAU7D,eAAO,MAAM,8BAA8B,EAAE,SAAS,MAAM,EAI3D,CAAC;AAiBF,eAAO,MAAM,8BAA8B;;;CAQjC,CAAC;AAOX,eAAO,MAAM,8BAA8B,EAAE,SAAS,MAAM,EAa3D,CAAC;AAoBF,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,SAAS,GACd,kBAAkB,CA+CpB"}
@@ -1,17 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OIDC_SESSION_OPTIONAL_ENV_VARS = exports.OIDC_SESSION_REQUIRED_ENV_VARS = void 0;
3
+ exports.OIDC_SESSION_OPTIONAL_ENV_VARS = exports.OIDC_SESSION_REDIRECT_ENV_VARS = exports.OIDC_SESSION_REQUIRED_ENV_VARS = void 0;
4
4
  exports.loadOidcSessionOptionsFromEnv = loadOidcSessionOptionsFromEnv;
5
5
  const oidc_session_options_1 = require("./oidc-session-options");
6
6
  exports.OIDC_SESSION_REQUIRED_ENV_VARS = [
7
7
  'OIDC_ISSUER_URL',
8
8
  'OIDC_CLIENT_ID',
9
- 'OIDC_REDIRECT_URI',
10
9
  'SESSION_COOKIE_NAME',
11
10
  ];
11
+ exports.OIDC_SESSION_REDIRECT_ENV_VARS = {
12
+ fixed: ['OIDC_REDIRECT_URI', 'OIDC_POST_LOGOUT_REDIRECT_URI'],
13
+ perOrigin: [
14
+ 'OIDC_REDIRECT_ALLOWED_ORIGINS',
15
+ 'OIDC_REDIRECT_PATH',
16
+ 'OIDC_POST_LOGOUT_REDIRECT_PATH',
17
+ 'OIDC_TRUSTED_PROXIES',
18
+ ],
19
+ };
12
20
  exports.OIDC_SESSION_OPTIONAL_ENV_VARS = [
13
21
  'OIDC_CLIENT_SECRET',
14
- 'OIDC_POST_LOGOUT_REDIRECT_URI',
15
22
  'OIDC_SCOPE',
16
23
  'OIDC_KEYCLOAK_IDP_HINT',
17
24
  'SESSION_COOKIE_SECURE',
@@ -34,7 +41,6 @@ const DEFAULT_SAME_SITE = 'lax';
34
41
  const SAME_SITE_VALUES = ['lax', 'strict', 'none'];
35
42
  function loadOidcSessionOptionsFromEnv(read) {
36
43
  const clientSecret = optional(read, 'OIDC_CLIENT_SECRET');
37
- const postLogoutRedirectUri = optional(read, 'OIDC_POST_LOGOUT_REDIRECT_URI');
38
44
  const cookieDomain = optional(read, 'SESSION_COOKIE_DOMAIN');
39
45
  const keycloakIdpHint = optional(read, 'OIDC_KEYCLOAK_IDP_HINT');
40
46
  const options = {
@@ -42,8 +48,7 @@ function loadOidcSessionOptionsFromEnv(read) {
42
48
  issuerUrl: required(read, 'OIDC_ISSUER_URL'),
43
49
  clientId: required(read, 'OIDC_CLIENT_ID'),
44
50
  ...(clientSecret === undefined ? {} : { clientSecret }),
45
- redirectUri: required(read, 'OIDC_REDIRECT_URI'),
46
- ...(postLogoutRedirectUri === undefined ? {} : { postLogoutRedirectUri }),
51
+ ...readRedirect(read),
47
52
  scope: withRequiredScope(optional(read, 'OIDC_SCOPE') ?? oidc_session_options_1.REQUIRED_OIDC_SCOPE),
48
53
  ...(keycloakIdpHint === undefined ? {} : { keycloakIdpHint }),
49
54
  },
@@ -64,6 +69,56 @@ function loadOidcSessionOptionsFromEnv(read) {
64
69
  };
65
70
  return (0, oidc_session_options_1.assertOidcSessionOptions)(options);
66
71
  }
72
+ function readRedirect(read) {
73
+ const declared = (names) => names.filter((name) => optional(read, name) !== undefined);
74
+ const fixed = declared(exports.OIDC_SESSION_REDIRECT_ENV_VARS.fixed);
75
+ const perOrigin = declared(exports.OIDC_SESSION_REDIRECT_ENV_VARS.perOrigin);
76
+ if (fixed.length > 0 && perOrigin.length > 0) {
77
+ throw new oidc_session_options_1.OidcSessionConfigError(`${fixed.join(', ')} and ${perOrigin.join(', ')} are both set. Declare ` +
78
+ 'ONE redirect form: OIDC_REDIRECT_URI for a single address, or ' +
79
+ 'OIDC_REDIRECT_ALLOWED_ORIGINS for several.');
80
+ }
81
+ if (perOrigin.length === 0) {
82
+ const redirectUri = optional(read, 'OIDC_REDIRECT_URI');
83
+ if (redirectUri === undefined) {
84
+ throw new oidc_session_options_1.OidcSessionConfigError('OIDC_REDIRECT_URI (one address) or OIDC_REDIRECT_ALLOWED_ORIGINS ' +
85
+ '(several) is required and neither is set. It has no safe default: ' +
86
+ 'without it this application cannot complete a sign-in.');
87
+ }
88
+ const postLogoutRedirectUri = optional(read, 'OIDC_POST_LOGOUT_REDIRECT_URI');
89
+ return {
90
+ redirectUri,
91
+ ...(postLogoutRedirectUri === undefined ? {} : { postLogoutRedirectUri }),
92
+ };
93
+ }
94
+ const allowedOrigins = readList(read, 'OIDC_REDIRECT_ALLOWED_ORIGINS');
95
+ if (allowedOrigins === undefined) {
96
+ throw new oidc_session_options_1.OidcSessionConfigError(`${perOrigin.join(', ')} ${perOrigin.length === 1 ? 'is' : 'are'} set ` +
97
+ 'without OIDC_REDIRECT_ALLOWED_ORIGINS, which selects the per-address ' +
98
+ 'redirect and has no default.');
99
+ }
100
+ const postLogoutPath = optional(read, 'OIDC_POST_LOGOUT_REDIRECT_PATH');
101
+ const trustedProxies = readList(read, 'OIDC_TRUSTED_PROXIES');
102
+ return {
103
+ redirectFromRequestOrigin: {
104
+ allowedOrigins,
105
+ callbackPath: required(read, 'OIDC_REDIRECT_PATH'),
106
+ ...(postLogoutPath === undefined ? {} : { postLogoutPath }),
107
+ ...(trustedProxies === undefined ? {} : { trustedProxies }),
108
+ },
109
+ };
110
+ }
111
+ function readList(read, name) {
112
+ const raw = optional(read, name);
113
+ if (raw === undefined) {
114
+ return undefined;
115
+ }
116
+ const entries = raw.split(',').map((entry) => entry.trim());
117
+ if (entries.some((entry) => entry === '')) {
118
+ throw new oidc_session_options_1.OidcSessionConfigError(`${name} has an empty entry; got "${raw}". Separate entries with single commas.`);
119
+ }
120
+ return entries;
121
+ }
67
122
  function optional(read, name) {
68
123
  const raw = read(name);
69
124
  if (raw === undefined || raw.trim() === '') {
@@ -1 +1 @@
1
- {"version":3,"file":"oidc-session-env.js","source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B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC;IAClE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,6CAAsB,CAC9B,GAAG,IAAI,mBAAmB,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CACvE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,12 +1,20 @@
1
+ import { OidcSessionConfigError } from './oidc-session-config-error';
1
2
  export interface OidcProviderOptions {
2
3
  readonly issuerUrl: string;
3
4
  readonly clientId: string;
4
5
  readonly clientSecret?: string;
5
- readonly redirectUri: string;
6
+ readonly redirectUri?: string;
6
7
  readonly postLogoutRedirectUri?: string;
8
+ readonly redirectFromRequestOrigin?: RequestOriginRedirectOptions;
7
9
  readonly scope: string;
8
10
  readonly keycloakIdpHint?: string;
9
11
  }
12
+ export interface RequestOriginRedirectOptions {
13
+ readonly allowedOrigins: readonly string[];
14
+ readonly callbackPath: string;
15
+ readonly postLogoutPath?: string;
16
+ readonly trustedProxies?: readonly string[];
17
+ }
10
18
  export interface SessionCookieOptions {
11
19
  readonly name: string;
12
20
  readonly secure: boolean;
@@ -26,9 +34,7 @@ export interface OidcSessionOptions {
26
34
  readonly ttl: SessionTtlOptions;
27
35
  readonly keyPrefix: string;
28
36
  }
29
- export declare class OidcSessionConfigError extends Error {
30
- constructor(message: string);
31
- }
37
+ export { OidcSessionConfigError };
32
38
  export declare const REQUIRED_OIDC_SCOPE = "openid";
33
39
  export declare function assertOidcSessionOptions(options: OidcSessionOptions): OidcSessionOptions;
34
40
  //# sourceMappingURL=oidc-session-options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oidc-session-options.d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AAC,cAAc,EAAE,MAAM,CAAC;IAKhC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAMpC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAOpC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAGD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAMhC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAGlC,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAU5C,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,kBAAkB,GAC1B,kBAAkB,CAoEpB"}
@@ -2,38 +2,31 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.REQUIRED_OIDC_SCOPE = exports.OidcSessionConfigError = void 0;
4
4
  exports.assertOidcSessionOptions = assertOidcSessionOptions;
5
- class OidcSessionConfigError extends Error {
6
- constructor(message) {
7
- super(`[oidc-session-nest] ${message}`);
8
- this.name = 'OidcSessionConfigError';
9
- }
10
- }
11
- exports.OidcSessionConfigError = OidcSessionConfigError;
5
+ const oidc_session_config_error_1 = require("./oidc-session-config-error");
6
+ Object.defineProperty(exports, "OidcSessionConfigError", { enumerable: true, get: function () { return oidc_session_config_error_1.OidcSessionConfigError; } });
7
+ const redirect_origin_1 = require("./redirect-origin");
8
+ const request_authority_1 = require("../http/request-authority");
12
9
  exports.REQUIRED_OIDC_SCOPE = 'openid';
13
10
  function assertOidcSessionOptions(options) {
14
11
  const { oidc, cookie, ttl, keyPrefix } = options;
15
12
  for (const [name, value] of [
16
13
  ['issuerUrl', oidc.issuerUrl],
17
14
  ['clientId', oidc.clientId],
18
- ['redirectUri', oidc.redirectUri],
19
15
  ['cookie.name', cookie.name],
20
16
  ['keyPrefix', keyPrefix],
21
17
  ]) {
22
18
  if (typeof value !== 'string' || value.trim() === '') {
23
- throw new OidcSessionConfigError(`${name} must be a non-empty string.`);
19
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be a non-empty string.`);
24
20
  }
25
21
  }
26
22
  assertAbsoluteHttpUrl('issuerUrl', oidc.issuerUrl);
27
- assertAbsoluteHttpUrl('redirectUri', oidc.redirectUri);
28
- if (oidc.postLogoutRedirectUri !== undefined) {
29
- assertAbsoluteHttpUrl('postLogoutRedirectUri', oidc.postLogoutRedirectUri);
30
- }
23
+ assertRedirectStatement(oidc);
31
24
  if (!oidc.scope.split(/\s+/u).includes(exports.REQUIRED_OIDC_SCOPE)) {
32
- throw new OidcSessionConfigError(`scope must include "${exports.REQUIRED_OIDC_SCOPE}"; got "${oidc.scope}".`);
25
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`scope must include "${exports.REQUIRED_OIDC_SCOPE}"; got "${oidc.scope}".`);
33
26
  }
34
27
  if (oidc.keycloakIdpHint !== undefined &&
35
28
  (typeof oidc.keycloakIdpHint !== 'string' || oidc.keycloakIdpHint.trim() === '')) {
36
- throw new OidcSessionConfigError('keycloakIdpHint must be a non-empty string when set; omit it to let the ' +
29
+ throw new oidc_session_config_error_1.OidcSessionConfigError('keycloakIdpHint must be a non-empty string when set; omit it to let the ' +
37
30
  'realm show its own login page.');
38
31
  }
39
32
  for (const [name, value] of [
@@ -43,30 +36,66 @@ function assertOidcSessionOptions(options) {
43
36
  ['ttl.refreshWaitMs', ttl.refreshWaitMs],
44
37
  ]) {
45
38
  if (!Number.isFinite(value) || value <= 0) {
46
- throw new OidcSessionConfigError(`${name} must be a positive finite number; got ${String(value)}.`);
39
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be a positive finite number; got ${String(value)}.`);
47
40
  }
48
41
  }
49
42
  if (ttl.idleTtlSeconds > ttl.absoluteTtlSeconds) {
50
- throw new OidcSessionConfigError(`ttl.idleTtlSeconds (${ttl.idleTtlSeconds}) exceeds ttl.absoluteTtlSeconds ` +
43
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`ttl.idleTtlSeconds (${ttl.idleTtlSeconds}) exceeds ttl.absoluteTtlSeconds ` +
51
44
  `(${ttl.absoluteTtlSeconds}), so the idle window could never be reached. ` +
52
45
  'Lower the idle TTL or raise the absolute one.');
53
46
  }
54
47
  if (cookie.sameSite === 'none' && !cookie.secure) {
55
- throw new OidcSessionConfigError('cookie.sameSite "none" requires cookie.secure — browsers reject the pair, ' +
48
+ throw new oidc_session_config_error_1.OidcSessionConfigError('cookie.sameSite "none" requires cookie.secure — browsers reject the pair, ' +
56
49
  'so the session cookie would be silently dropped on every response.');
57
50
  }
58
51
  return options;
59
52
  }
53
+ function assertRedirectStatement(oidc) {
54
+ const fixed = oidc.redirectUri;
55
+ const perOrigin = oidc.redirectFromRequestOrigin;
56
+ if (fixed !== undefined && perOrigin !== undefined) {
57
+ throw new oidc_session_config_error_1.OidcSessionConfigError('redirectUri and redirectFromRequestOrigin are both set. State ONE: a ' +
58
+ 'fixed redirect URI for a single address, or an origin allowlist for ' +
59
+ 'several.');
60
+ }
61
+ if (fixed === undefined && perOrigin === undefined) {
62
+ throw new oidc_session_config_error_1.OidcSessionConfigError('neither redirectUri nor redirectFromRequestOrigin is set, so no sign-in ' +
63
+ 'could ever return to this application.');
64
+ }
65
+ if (fixed !== undefined) {
66
+ if (typeof fixed !== 'string' || fixed.trim() === '') {
67
+ throw new oidc_session_config_error_1.OidcSessionConfigError('redirectUri must be a non-empty string.');
68
+ }
69
+ assertAbsoluteHttpUrl('redirectUri', fixed);
70
+ if (oidc.postLogoutRedirectUri !== undefined) {
71
+ assertAbsoluteHttpUrl('postLogoutRedirectUri', oidc.postLogoutRedirectUri);
72
+ }
73
+ return;
74
+ }
75
+ if (perOrigin === undefined) {
76
+ return;
77
+ }
78
+ if (oidc.postLogoutRedirectUri !== undefined) {
79
+ throw new oidc_session_config_error_1.OidcSessionConfigError('postLogoutRedirectUri names ONE address, but redirectFromRequestOrigin ' +
80
+ 'serves several. State redirectFromRequestOrigin.postLogoutPath instead.');
81
+ }
82
+ (0, redirect_origin_1.parseRedirectOriginAllowlist)(perOrigin.allowedOrigins);
83
+ (0, redirect_origin_1.assertOriginRelativePath)('redirectFromRequestOrigin.callbackPath', perOrigin.callbackPath);
84
+ if (perOrigin.postLogoutPath !== undefined) {
85
+ (0, redirect_origin_1.assertOriginRelativePath)('redirectFromRequestOrigin.postLogoutPath', perOrigin.postLogoutPath);
86
+ }
87
+ (0, request_authority_1.parseTrustedProxies)(perOrigin.trustedProxies ?? []);
88
+ }
60
89
  function assertAbsoluteHttpUrl(name, value) {
61
90
  let parsed;
62
91
  try {
63
92
  parsed = new URL(value);
64
93
  }
65
94
  catch {
66
- throw new OidcSessionConfigError(`${name} must be an absolute URL; got "${value}".`);
95
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be an absolute URL; got "${value}".`);
67
96
  }
68
97
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
69
- throw new OidcSessionConfigError(`${name} must be http or https; got "${parsed.protocol}".`);
98
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be http or https; got "${parsed.protocol}".`);
70
99
  }
71
100
  }
72
101
  //# sourceMappingURL=oidc-session-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"oidc-session-options.js","sourceRoot":"","sources":["../../src/config/oidc-session-options.ts"],"names":[],"mappings":";;;AAyIA,4DA0EC;AA5FD,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC;AAGY,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAU5C,SAAgB,wBAAwB,CACtC,OAA2B;IAE3B,MAAM,EAAE,IAAI,EAAE,MAAM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S,CAAC,cAAc,CACzB,CAAC;IACJ,CAAC;IACD,IAAA,uCAAmB,EAAC,SAAS,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAY,EAAE,KAAa;IACxD,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,kDAAsB,CAAC,GAAG,IAAI,kCAAkC,KAAK,IAAI,CAAC,CAAC;IACvF,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAChE,MAAM,IAAI,kDAAsB,CAC9B,GAAG,IAAI,gCAAgC,MAAM,CAAC,QAAQ,IAAI,CAC3D,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface RedirectOriginPattern {
2
+ readonly source: string;
3
+ readonly scheme: 'http' | 'https';
4
+ readonly wildcard: boolean;
5
+ readonly hostRemainder: string;
6
+ readonly port: number | null;
7
+ }
8
+ export declare function parseRedirectOriginPattern(entry: string): RedirectOriginPattern;
9
+ export declare function parseRedirectOriginAllowlist(entries: readonly string[]): readonly RedirectOriginPattern[];
10
+ export declare function matchRedirectOrigin(patterns: readonly RedirectOriginPattern[], authority: string): string | null;
11
+ export declare function assertOriginRelativePath(name: string, value: string): void;
12
+ //# sourceMappingURL=redirect-origin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-origin.d.ts","sourceRoot":"","sources":["../../src/config/redirect-origin.ts"],"names":[],"mappings":"AAmCA,MAAM,WAAW,qBAAqB;IAEpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAElC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAoBD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,qBAAqB,CA8B/E;AAQD,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,SAAS,qBAAqB,EAAE,CAsBlC;AASD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,SAAS,qBAAqB,EAAE,EAC1C,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAwBf;AA+BD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAW1E"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseRedirectOriginPattern = parseRedirectOriginPattern;
4
+ exports.parseRedirectOriginAllowlist = parseRedirectOriginAllowlist;
5
+ exports.matchRedirectOrigin = matchRedirectOrigin;
6
+ exports.assertOriginRelativePath = assertOriginRelativePath;
7
+ const oidc_session_config_error_1 = require("./oidc-session-config-error");
8
+ const DEFAULT_PORT = {
9
+ http: 80,
10
+ https: 443,
11
+ };
12
+ const LABEL = '[a-z0-9](?:[a-z0-9-]*[a-z0-9])?';
13
+ const EXACT_HOST = new RegExp(`^${LABEL}(?:\\.${LABEL})*$`, 'u');
14
+ const WILDCARD_REMAINDER = new RegExp(`^[a-z0-9-]*(?:\\.${LABEL}){2,}$`, 'u');
15
+ const ENTRY = /^(https?):\/\/([^/:?#@\s]+)(?::(\d{1,5}))?\/?$/u;
16
+ const AUTHORITY = /^([a-z0-9.-]+)(?::(\d{1,5}))?$/u;
17
+ const WILDCARD_FILL = /^[a-z0-9-]+$/u;
18
+ function parseRedirectOriginPattern(entry) {
19
+ const trimmed = entry.trim();
20
+ const match = ENTRY.exec(trimmed.toLowerCase());
21
+ if (match === null) {
22
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`redirect origin "${entry}" is not an origin of the form ` +
23
+ '"https://host[:port]" — no path, query, fragment or credentials.');
24
+ }
25
+ const scheme = match[1];
26
+ const host = match[2] ?? '';
27
+ const port = parsePort(entry, match[3]);
28
+ if (host.startsWith('*')) {
29
+ const remainder = host.slice(1);
30
+ if (remainder.includes('*') || !WILDCARD_REMAINDER.test(remainder)) {
31
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`redirect origin "${entry}" has an unsupported wildcard. A single "*" ` +
32
+ 'may open the FIRST label only, and at least two labels must follow ' +
33
+ 'it (e.g. "https://*-preview.example.com").');
34
+ }
35
+ return { source: trimmed, scheme, wildcard: true, hostRemainder: remainder, port };
36
+ }
37
+ if (host.includes('*') || !EXACT_HOST.test(host)) {
38
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`redirect origin "${entry}" does not name a valid host.`);
39
+ }
40
+ return { source: trimmed, scheme, wildcard: false, hostRemainder: host, port };
41
+ }
42
+ function parseRedirectOriginAllowlist(entries) {
43
+ if (entries.length === 0) {
44
+ throw new oidc_session_config_error_1.OidcSessionConfigError('redirect origin allowlist is empty — no address could ever sign in.');
45
+ }
46
+ const patterns = entries.map(parseRedirectOriginPattern);
47
+ const seen = new Map();
48
+ for (const pattern of patterns) {
49
+ const key = `${pattern.wildcard ? '*' : ''}${pattern.hostRemainder}:${pattern.port ?? DEFAULT_PORT[pattern.scheme]}`;
50
+ const earlier = seen.get(key);
51
+ if (earlier !== undefined) {
52
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`redirect origins "${earlier}" and "${pattern.source}" name the same ` +
53
+ 'address; each address may appear once, under one scheme.');
54
+ }
55
+ seen.set(key, pattern.source);
56
+ }
57
+ return patterns;
58
+ }
59
+ function matchRedirectOrigin(patterns, authority) {
60
+ const parsed = AUTHORITY.exec(authority.trim().toLowerCase());
61
+ if (parsed === null) {
62
+ return null;
63
+ }
64
+ const host = stripTrailingDot(parsed[1] ?? '');
65
+ if (!EXACT_HOST.test(host)) {
66
+ return null;
67
+ }
68
+ const requestPort = parsed[2] === undefined ? null : Number(parsed[2]);
69
+ for (const pattern of patterns) {
70
+ const expectedPort = pattern.port ?? DEFAULT_PORT[pattern.scheme];
71
+ if ((requestPort ?? DEFAULT_PORT[pattern.scheme]) !== expectedPort) {
72
+ continue;
73
+ }
74
+ if (!hostMatches(pattern, host)) {
75
+ continue;
76
+ }
77
+ const portSuffix = expectedPort === DEFAULT_PORT[pattern.scheme] ? '' : `:${String(expectedPort)}`;
78
+ return `${pattern.scheme}://${host}${portSuffix}`;
79
+ }
80
+ return null;
81
+ }
82
+ function hostMatches(pattern, host) {
83
+ if (!pattern.wildcard) {
84
+ return host === pattern.hostRemainder;
85
+ }
86
+ if (!host.endsWith(pattern.hostRemainder)) {
87
+ return false;
88
+ }
89
+ const fill = host.slice(0, host.length - pattern.hostRemainder.length);
90
+ return WILDCARD_FILL.test(fill);
91
+ }
92
+ function stripTrailingDot(host) {
93
+ return host.endsWith('.') ? host.slice(0, -1) : host;
94
+ }
95
+ function parsePort(entry, raw) {
96
+ if (raw === undefined) {
97
+ return null;
98
+ }
99
+ const port = Number(raw);
100
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
101
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`redirect origin "${entry}" carries an invalid port "${raw}".`);
102
+ }
103
+ return port;
104
+ }
105
+ function assertOriginRelativePath(name, value) {
106
+ if (!value.startsWith('/') ||
107
+ value.startsWith('//') ||
108
+ /[?#\\\s]/u.test(value)) {
109
+ throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be an absolute path on the application's own origin ` +
110
+ `(e.g. "/auth/callback") with no query or fragment; got "${value}".`);
111
+ }
112
+ }
113
+ //# sourceMappingURL=redirect-origin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-origin.js","sourceRoot":"","sources":["../../src/config/redirect-origin.ts"],"names":[],"mappings":";;AAiEA,gEA8BC;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ACd,CAAC;AAGD,SAAgB,wBAAwB,CAAC,IAAY,EAAE,KAAa;IAClE,IACE,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QACtB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;QACtB,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EACvB,CAAC;QACD,MAAM,IAAI,kDAAsB,CAC9B,GAAG,IAAI,4DAA4D;YACjE,2DAA2D,KAAK,IAAI,CACvE,CAAC;IACJ,CAAC;AACH,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -5,7 +5,9 @@ export declare enum OidcSessionErrorCode {
5
5
  OidcCallbackRejected = "OIDC_CALLBACK_REJECTED",
6
6
  OidcLoginStateUnknown = "OIDC_LOGIN_STATE_UNKNOWN",
7
7
  OidcTokenEndpointFailed = "OIDC_TOKEN_ENDPOINT_FAILED",
8
- SessionRefreshContended = "SESSION_REFRESH_CONTENDED"
8
+ SessionRefreshContended = "SESSION_REFRESH_CONTENDED",
9
+ OidcRedirectOriginNotAllowed = "OIDC_REDIRECT_ORIGIN_NOT_ALLOWED",
10
+ OidcLoginOriginMismatch = "OIDC_LOGIN_ORIGIN_MISMATCH"
9
11
  }
10
12
  export interface OidcSessionErrorBody {
11
13
  readonly code: OidcSessionErrorCode;
@@ -34,4 +36,10 @@ export declare class OidcTokenEndpointFailedError extends OidcSessionError {
34
36
  export declare class SessionRefreshContendedError extends OidcSessionError {
35
37
  constructor(detail?: string);
36
38
  }
39
+ export declare class OidcRedirectOriginNotAllowedError extends OidcSessionError {
40
+ constructor(detail: string);
41
+ }
42
+ export declare class OidcLoginOriginMismatchError extends OidcSessionError {
43
+ constructor(detail?: string);
44
+ }
37
45
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAM3D,oBAA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BAAuB,+BAA+B;CACvD;AAGD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAGD,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;gBAGlC,IAAI,EAAE,oBAAoB,EAC1B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM;CAYjB;AAED,qBAAa,oBAAqB,SAAQ,gBAAgB;gBAC5C,MAAM,SAAgD;CAQnE;AAED,qBAAa,mBAAoB,SAAQ,gBAAgB;gBAC3C,MAAM,SAAsD;CAQzE;AAED,qBAAa,yBAA0B,SAAQ,gBAAgB;gBACjD,MAAM,EAAE,MAAM;CAQ3B;AAED,qBAAa,0BAA2B,SAAQ,gBAAgB;gBAE5D,MAAM,SAAgF;CASzF;AAED,qBAAa,4BAA6B,SAAQ,gBAAgB;gBACpD,MAAM,EAAE,MAAM;CAQ3B;AAED,qBAAa,4BAA6B,SAAQ,gBAAgB;gBAE9D,MAAM,SAA+D;CASxE;AAED,qBAAa,iCAAkC,SAAQ,gBAAgB;gBACzD,MAAM,EAAE,MAAM;CAQ3B;AAED,qBAAa,4BAA6B,SAAQ,gBAAgB;gBAE9D,MAAM,SAAiG;CAS1G"}
package/dist/errors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SessionRefreshContendedError = exports.OidcTokenEndpointFailedError = exports.OidcLoginStateUnknownError = exports.OidcCallbackRejectedError = exports.SessionExpiredError = exports.SessionRequiredError = exports.OidcSessionError = exports.OidcSessionErrorCode = void 0;
3
+ exports.OidcLoginOriginMismatchError = exports.OidcRedirectOriginNotAllowedError = exports.SessionRefreshContendedError = exports.OidcTokenEndpointFailedError = exports.OidcLoginStateUnknownError = exports.OidcCallbackRejectedError = exports.SessionExpiredError = exports.SessionRequiredError = exports.OidcSessionError = exports.OidcSessionErrorCode = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  var OidcSessionErrorCode;
6
6
  (function (OidcSessionErrorCode) {
@@ -10,6 +10,8 @@ var OidcSessionErrorCode;
10
10
  OidcSessionErrorCode["OidcLoginStateUnknown"] = "OIDC_LOGIN_STATE_UNKNOWN";
11
11
  OidcSessionErrorCode["OidcTokenEndpointFailed"] = "OIDC_TOKEN_ENDPOINT_FAILED";
12
12
  OidcSessionErrorCode["SessionRefreshContended"] = "SESSION_REFRESH_CONTENDED";
13
+ OidcSessionErrorCode["OidcRedirectOriginNotAllowed"] = "OIDC_REDIRECT_ORIGIN_NOT_ALLOWED";
14
+ OidcSessionErrorCode["OidcLoginOriginMismatch"] = "OIDC_LOGIN_ORIGIN_MISMATCH";
13
15
  })(OidcSessionErrorCode || (exports.OidcSessionErrorCode = OidcSessionErrorCode = {}));
14
16
  class OidcSessionError extends common_1.HttpException {
15
17
  code;
@@ -57,4 +59,16 @@ class SessionRefreshContendedError extends OidcSessionError {
57
59
  }
58
60
  }
59
61
  exports.SessionRefreshContendedError = SessionRefreshContendedError;
62
+ class OidcRedirectOriginNotAllowedError extends OidcSessionError {
63
+ constructor(detail) {
64
+ super(OidcSessionErrorCode.OidcRedirectOriginNotAllowed, common_1.HttpStatus.BAD_REQUEST, 'Address not approved for sign-in', detail);
65
+ }
66
+ }
67
+ exports.OidcRedirectOriginNotAllowedError = OidcRedirectOriginNotAllowedError;
68
+ class OidcLoginOriginMismatchError extends OidcSessionError {
69
+ constructor(detail = 'This sign-in was started on a different address. Start again on the address you mean to use.') {
70
+ super(OidcSessionErrorCode.OidcLoginOriginMismatch, common_1.HttpStatus.BAD_REQUEST, 'Sign-in finished on a different address', detail);
71
+ }
72
+ }
73
+ exports.OidcLoginOriginMismatchError = OidcLoginOriginMismatchError;
60
74
  //# sourceMapping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;CACF;AAXD,oEAWC;AAED,MAAa,iCAAkC,SAAQ,gBAAgB;IACrE,YAAY,MAAc;QACxB,KAAK,CACH,oBAAoB,CAAC,4BAA4B,EACjD,mBAAU,CAAC,WAAW,EACtB,kCAAkC,EAClC,MAAM,CACP,CAAC;IACJ,CAAC;CACF;AATD,8EASC;AAED,MAAa,4BAA6B,SAAQ,gBAAgB;IAChE,YACE,MAAM,GAAG,8FAA8F;QAEvG,KAAK,CACH,oBAAoB,CAAC,uBAAuB,EAC5C,mBAAU,CAAC,WAAW,EACtB,yCAAyC,EACzC,MAAM,CACP,CAAC;IACJ,CAAC;CACF;AAXD,oEAWC"}
@@ -0,0 +1,19 @@
1
+ import { BlockList } from 'node:net';
2
+ export interface AuthorityRequestLike {
3
+ headers: Record<string, string | string[] | undefined>;
4
+ socket?: {
5
+ remoteAddress?: string | undefined;
6
+ } | undefined;
7
+ }
8
+ export type RequestAuthority = {
9
+ readonly kind: 'resolved';
10
+ readonly authority: string;
11
+ } | {
12
+ readonly kind: 'unresolvable';
13
+ readonly reason: string;
14
+ };
15
+ export type TrustedProxySet = BlockList | null;
16
+ export declare function parseTrustedProxies(entries: readonly string[]): TrustedProxySet;
17
+ export declare function isTrustedPeer(trusted: TrustedProxySet, peer: string | undefined): boolean;
18
+ export declare function resolveRequestAuthority(req: AuthorityRequestLike, trusted: TrustedProxySet): RequestAuthority;
19
+ //# sourceMappingURL=request-authority.d.ts.map