@xemahq/oidc-session-nest 1.0.1 → 1.2.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.
- package/README.md +53 -0
- package/dist/config/oidc-session-config-error.d.ts +4 -0
- package/dist/config/oidc-session-config-error.d.ts.map +1 -0
- package/dist/config/oidc-session-config-error.js +11 -0
- package/dist/config/oidc-session-config-error.js.map +1 -0
- package/dist/config/oidc-session-env.d.ts +4 -0
- package/dist/config/oidc-session-env.d.ts.map +1 -1
- package/dist/config/oidc-session-env.js +64 -6
- package/dist/config/oidc-session-env.js.map +1 -1
- package/dist/config/oidc-session-options.d.ts +11 -4
- package/dist/config/oidc-session-options.d.ts.map +1 -1
- package/dist/config/oidc-session-options.js +63 -20
- package/dist/config/oidc-session-options.js.map +1 -1
- package/dist/config/redirect-origin.d.ts +12 -0
- package/dist/config/redirect-origin.d.ts.map +1 -0
- package/dist/config/redirect-origin.js +113 -0
- package/dist/config/redirect-origin.js.map +1 -0
- package/dist/errors.d.ts +9 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -1
- package/dist/errors.js.map +1 -1
- package/dist/http/request-authority.d.ts +19 -0
- package/dist/http/request-authority.d.ts.map +1 -0
- package/dist/http/request-authority.js +71 -0
- package/dist/http/request-authority.js.map +1 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/nest/navigation-refusal.d.ts +4 -0
- package/dist/nest/navigation-refusal.d.ts.map +1 -0
- package/dist/nest/navigation-refusal.js +10 -0
- package/dist/nest/navigation-refusal.js.map +1 -0
- package/dist/nest/oidc-session-auth.controller.d.ts +4 -0
- package/dist/nest/oidc-session-auth.controller.d.ts.map +1 -1
- package/dist/nest/oidc-session-auth.controller.js +53 -11
- package/dist/nest/oidc-session-auth.controller.js.map +1 -1
- package/dist/nest/oidc-session-context.d.ts +2 -0
- package/dist/nest/oidc-session-context.d.ts.map +1 -1
- package/dist/nest/oidc-session-context.js.map +1 -1
- package/dist/nest/oidc-session.middleware.d.ts +3 -1
- package/dist/nest/oidc-session.middleware.d.ts.map +1 -1
- package/dist/nest/oidc-session.middleware.js +12 -1
- package/dist/nest/oidc-session.middleware.js.map +1 -1
- package/dist/nest/redirect-targets.d.ts +8 -0
- package/dist/nest/redirect-targets.d.ts.map +1 -0
- package/dist/nest/redirect-targets.js +45 -0
- package/dist/nest/redirect-targets.js.map +1 -0
- package/dist/oidc/oidc-client.d.ts +4 -1
- package/dist/oidc/oidc-client.d.ts.map +1 -1
- package/dist/oidc/oidc-client.js +17 -5
- package/dist/oidc/oidc-client.js.map +1 -1
- package/dist/session/session-service.d.ts +2 -1
- package/dist/session/session-service.d.ts.map +1 -1
- package/dist/session/session-service.js +10 -2
- package/dist/session/session-service.js.map +1 -1
- package/dist/session/session-store.d.ts +1 -0
- package/dist/session/session-store.d.ts.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -110,6 +110,59 @@ 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
|
+
|
|
139
|
+
### Sign-in errors on the application's own page
|
|
140
|
+
|
|
141
|
+
`GET /auth/login` and `GET /auth/callback` are browser navigations, not
|
|
142
|
+
fetches. By default a refusal there is a JSON `400`, which the browser shows as
|
|
143
|
+
raw JSON on a backend address.
|
|
144
|
+
|
|
145
|
+
Set `OIDC_NAVIGATION_ERROR_PATH` (or `navigationErrorPath`) to a path on the
|
|
146
|
+
application's own origin, and every refusal on those two routes becomes a
|
|
147
|
+
redirect to it with the error code:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
302 Location: /sign-in?error=OIDC_LOGIN_ORIGIN_MISMATCH
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- The `Location` is always relative, so it cannot redirect anywhere else and
|
|
154
|
+
needs no allowlist. The value must start with a single `/` and carry no query
|
|
155
|
+
or fragment. Anything else fails at boot.
|
|
156
|
+
- The parameter is always `error`, and it carries only the code. The detail
|
|
157
|
+
text stays in the server log, where each refusal is logged with its code.
|
|
158
|
+
- The codes a sign-in page can receive are `OIDC_REDIRECT_ORIGIN_NOT_ALLOWED`,
|
|
159
|
+
`OIDC_LOGIN_ORIGIN_MISMATCH`, `OIDC_LOGIN_STATE_UNKNOWN`,
|
|
160
|
+
`OIDC_CALLBACK_REJECTED` and `OIDC_TOKEN_ENDPOINT_FAILED`.
|
|
161
|
+
- With the variable unset, the two routes keep answering JSON. There is no
|
|
162
|
+
default path, because a page that does not read `?error=` would hide the
|
|
163
|
+
refusal.
|
|
164
|
+
- `POST /auth/logout` is a fetch and always answers JSON.
|
|
165
|
+
|
|
113
166
|
## Peer requirements
|
|
114
167
|
|
|
115
168
|
- `@nestjs/common` and `@nestjs/core` `^10 || ^11` — the framework this mounts into.
|
|
@@ -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,
|
|
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,EAc3D,CAAC;AAoBF,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,SAAS,GACd,kBAAkB,CAmDpB"}
|
|
@@ -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',
|
|
@@ -23,6 +30,7 @@ exports.OIDC_SESSION_OPTIONAL_ENV_VARS = [
|
|
|
23
30
|
'SESSION_REFRESH_LEAD_SECONDS',
|
|
24
31
|
'SESSION_REFRESH_WAIT_MS',
|
|
25
32
|
'SESSION_KEY_PREFIX',
|
|
33
|
+
'OIDC_NAVIGATION_ERROR_PATH',
|
|
26
34
|
];
|
|
27
35
|
const DEFAULT_IDLE_TTL_SECONDS = 8 * 60 * 60;
|
|
28
36
|
const DEFAULT_ABSOLUTE_TTL_SECONDS = 24 * 60 * 60;
|
|
@@ -34,16 +42,15 @@ const DEFAULT_SAME_SITE = 'lax';
|
|
|
34
42
|
const SAME_SITE_VALUES = ['lax', 'strict', 'none'];
|
|
35
43
|
function loadOidcSessionOptionsFromEnv(read) {
|
|
36
44
|
const clientSecret = optional(read, 'OIDC_CLIENT_SECRET');
|
|
37
|
-
const postLogoutRedirectUri = optional(read, 'OIDC_POST_LOGOUT_REDIRECT_URI');
|
|
38
45
|
const cookieDomain = optional(read, 'SESSION_COOKIE_DOMAIN');
|
|
39
46
|
const keycloakIdpHint = optional(read, 'OIDC_KEYCLOAK_IDP_HINT');
|
|
47
|
+
const navigationErrorPath = optional(read, 'OIDC_NAVIGATION_ERROR_PATH');
|
|
40
48
|
const options = {
|
|
41
49
|
oidc: {
|
|
42
50
|
issuerUrl: required(read, 'OIDC_ISSUER_URL'),
|
|
43
51
|
clientId: required(read, 'OIDC_CLIENT_ID'),
|
|
44
52
|
...(clientSecret === undefined ? {} : { clientSecret }),
|
|
45
|
-
|
|
46
|
-
...(postLogoutRedirectUri === undefined ? {} : { postLogoutRedirectUri }),
|
|
53
|
+
...readRedirect(read),
|
|
47
54
|
scope: withRequiredScope(optional(read, 'OIDC_SCOPE') ?? oidc_session_options_1.REQUIRED_OIDC_SCOPE),
|
|
48
55
|
...(keycloakIdpHint === undefined ? {} : { keycloakIdpHint }),
|
|
49
56
|
},
|
|
@@ -61,9 +68,60 @@ function loadOidcSessionOptionsFromEnv(read) {
|
|
|
61
68
|
refreshWaitMs: readPositiveNumber(read, 'SESSION_REFRESH_WAIT_MS', DEFAULT_REFRESH_WAIT_MS),
|
|
62
69
|
},
|
|
63
70
|
keyPrefix: optional(read, 'SESSION_KEY_PREFIX') ?? DEFAULT_KEY_PREFIX,
|
|
71
|
+
...(navigationErrorPath === undefined ? {} : { navigationErrorPath }),
|
|
64
72
|
};
|
|
65
73
|
return (0, oidc_session_options_1.assertOidcSessionOptions)(options);
|
|
66
74
|
}
|
|
75
|
+
function readRedirect(read) {
|
|
76
|
+
const declared = (names) => names.filter((name) => optional(read, name) !== undefined);
|
|
77
|
+
const fixed = declared(exports.OIDC_SESSION_REDIRECT_ENV_VARS.fixed);
|
|
78
|
+
const perOrigin = declared(exports.OIDC_SESSION_REDIRECT_ENV_VARS.perOrigin);
|
|
79
|
+
if (fixed.length > 0 && perOrigin.length > 0) {
|
|
80
|
+
throw new oidc_session_options_1.OidcSessionConfigError(`${fixed.join(', ')} and ${perOrigin.join(', ')} are both set. Declare ` +
|
|
81
|
+
'ONE redirect form: OIDC_REDIRECT_URI for a single address, or ' +
|
|
82
|
+
'OIDC_REDIRECT_ALLOWED_ORIGINS for several.');
|
|
83
|
+
}
|
|
84
|
+
if (perOrigin.length === 0) {
|
|
85
|
+
const redirectUri = optional(read, 'OIDC_REDIRECT_URI');
|
|
86
|
+
if (redirectUri === undefined) {
|
|
87
|
+
throw new oidc_session_options_1.OidcSessionConfigError('OIDC_REDIRECT_URI (one address) or OIDC_REDIRECT_ALLOWED_ORIGINS ' +
|
|
88
|
+
'(several) is required and neither is set. It has no safe default: ' +
|
|
89
|
+
'without it this application cannot complete a sign-in.');
|
|
90
|
+
}
|
|
91
|
+
const postLogoutRedirectUri = optional(read, 'OIDC_POST_LOGOUT_REDIRECT_URI');
|
|
92
|
+
return {
|
|
93
|
+
redirectUri,
|
|
94
|
+
...(postLogoutRedirectUri === undefined ? {} : { postLogoutRedirectUri }),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const allowedOrigins = readList(read, 'OIDC_REDIRECT_ALLOWED_ORIGINS');
|
|
98
|
+
if (allowedOrigins === undefined) {
|
|
99
|
+
throw new oidc_session_options_1.OidcSessionConfigError(`${perOrigin.join(', ')} ${perOrigin.length === 1 ? 'is' : 'are'} set ` +
|
|
100
|
+
'without OIDC_REDIRECT_ALLOWED_ORIGINS, which selects the per-address ' +
|
|
101
|
+
'redirect and has no default.');
|
|
102
|
+
}
|
|
103
|
+
const postLogoutPath = optional(read, 'OIDC_POST_LOGOUT_REDIRECT_PATH');
|
|
104
|
+
const trustedProxies = readList(read, 'OIDC_TRUSTED_PROXIES');
|
|
105
|
+
return {
|
|
106
|
+
redirectFromRequestOrigin: {
|
|
107
|
+
allowedOrigins,
|
|
108
|
+
callbackPath: required(read, 'OIDC_REDIRECT_PATH'),
|
|
109
|
+
...(postLogoutPath === undefined ? {} : { postLogoutPath }),
|
|
110
|
+
...(trustedProxies === undefined ? {} : { trustedProxies }),
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function readList(read, name) {
|
|
115
|
+
const raw = optional(read, name);
|
|
116
|
+
if (raw === undefined) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const entries = raw.split(',').map((entry) => entry.trim());
|
|
120
|
+
if (entries.some((entry) => entry === '')) {
|
|
121
|
+
throw new oidc_session_options_1.OidcSessionConfigError(`${name} has an empty entry; got "${raw}". Separate entries with single commas.`);
|
|
122
|
+
}
|
|
123
|
+
return entries;
|
|
124
|
+
}
|
|
67
125
|
function optional(read, name) {
|
|
68
126
|
const raw = read(name);
|
|
69
127
|
if (raw === undefined || raw.trim() === '') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-session-env.js","sourceRoot":"","sources":["../../src/config/oidc-session-env.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"oidc-session-env.js","sourceRoot":"","sources":["../../src/config/oidc-session-env.ts"],"names":[],"mappings":";;;AAsGA,sEAqDC;AA9ID,iEAMgC;AAanB,QAAA,8BAA8B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AAK,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
|
|
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;
|
|
@@ -25,10 +33,9 @@ export interface OidcSessionOptions {
|
|
|
25
33
|
readonly cookie: SessionCookieOptions;
|
|
26
34
|
readonly ttl: SessionTtlOptions;
|
|
27
35
|
readonly keyPrefix: string;
|
|
36
|
+
readonly navigationErrorPath?: string;
|
|
28
37
|
}
|
|
29
|
-
export
|
|
30
|
-
constructor(message: string);
|
|
31
|
-
}
|
|
38
|
+
export { OidcSessionConfigError };
|
|
32
39
|
export declare const REQUIRED_OIDC_SCOPE = "openid";
|
|
33
40
|
export declare function assertOidcSessionOptions(options: OidcSessionOptions): OidcSessionOptions;
|
|
34
41
|
//# sourceMappingURL=oidc-session-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-session-options.d.ts","sourceRoot":"","sources":["../../src/config/oidc-session-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oidc-session-options.d.ts","sourceRoot":"","sources":["../../src/config/oidc-session-options.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AASrE,MAAM,WAAW,mBAAmB;IAQlC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAM1B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAQ/B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAK9B,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAOxC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,4BAA4B,CAAC;IAKlE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAavB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAgBD,MAAM,WAAW,4BAA4B;IAE3C,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAE3C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAM9B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IASjC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAGD,MAAM,WAAW,oBAAoB;IAEnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAMtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAOtB,QAAQ,CAAC,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC9C;AAGD,MAAM,WAAW,iBAAiB;IAMhC,QAAQ,CAAC,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;IAkB3B,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACvC;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAGlC,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAU5C,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,kBAAkB,GAC1B,kBAAkB,CAwEpB"}
|
|
@@ -2,40 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.REQUIRED_OIDC_SCOPE = exports.OidcSessionConfigError = void 0;
|
|
4
4
|
exports.assertOidcSessionOptions = assertOidcSessionOptions;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 cookie_1 = require("../http/cookie");
|
|
9
|
+
const request_authority_1 = require("../http/request-authority");
|
|
12
10
|
exports.REQUIRED_OIDC_SCOPE = 'openid';
|
|
13
11
|
function assertOidcSessionOptions(options) {
|
|
14
12
|
const { oidc, cookie, ttl, keyPrefix } = options;
|
|
15
13
|
for (const [name, value] of [
|
|
16
14
|
['issuerUrl', oidc.issuerUrl],
|
|
17
15
|
['clientId', oidc.clientId],
|
|
18
|
-
['redirectUri', oidc.redirectUri],
|
|
19
16
|
['cookie.name', cookie.name],
|
|
20
17
|
['keyPrefix', keyPrefix],
|
|
21
18
|
]) {
|
|
22
19
|
if (typeof value !== 'string' || value.trim() === '') {
|
|
23
|
-
throw new OidcSessionConfigError(`${name} must be a non-empty string.`);
|
|
20
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be a non-empty string.`);
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
assertAbsoluteHttpUrl('issuerUrl', oidc.issuerUrl);
|
|
27
|
-
|
|
28
|
-
if (oidc.postLogoutRedirectUri !== undefined) {
|
|
29
|
-
assertAbsoluteHttpUrl('postLogoutRedirectUri', oidc.postLogoutRedirectUri);
|
|
30
|
-
}
|
|
24
|
+
assertRedirectStatement(oidc);
|
|
31
25
|
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}".`);
|
|
26
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError(`scope must include "${exports.REQUIRED_OIDC_SCOPE}"; got "${oidc.scope}".`);
|
|
33
27
|
}
|
|
34
28
|
if (oidc.keycloakIdpHint !== undefined &&
|
|
35
29
|
(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 ' +
|
|
30
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError('keycloakIdpHint must be a non-empty string when set; omit it to let the ' +
|
|
37
31
|
'realm show its own login page.');
|
|
38
32
|
}
|
|
33
|
+
if (options.navigationErrorPath !== undefined) {
|
|
34
|
+
assertNavigationErrorPath(options.navigationErrorPath);
|
|
35
|
+
}
|
|
39
36
|
for (const [name, value] of [
|
|
40
37
|
['ttl.idleTtlSeconds', ttl.idleTtlSeconds],
|
|
41
38
|
['ttl.absoluteTtlSeconds', ttl.absoluteTtlSeconds],
|
|
@@ -43,30 +40,76 @@ function assertOidcSessionOptions(options) {
|
|
|
43
40
|
['ttl.refreshWaitMs', ttl.refreshWaitMs],
|
|
44
41
|
]) {
|
|
45
42
|
if (!Number.isFinite(value) || value <= 0) {
|
|
46
|
-
throw new OidcSessionConfigError(`${name} must be a positive finite number; got ${String(value)}.`);
|
|
43
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be a positive finite number; got ${String(value)}.`);
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
46
|
if (ttl.idleTtlSeconds > ttl.absoluteTtlSeconds) {
|
|
50
|
-
throw new OidcSessionConfigError(`ttl.idleTtlSeconds (${ttl.idleTtlSeconds}) exceeds ttl.absoluteTtlSeconds ` +
|
|
47
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError(`ttl.idleTtlSeconds (${ttl.idleTtlSeconds}) exceeds ttl.absoluteTtlSeconds ` +
|
|
51
48
|
`(${ttl.absoluteTtlSeconds}), so the idle window could never be reached. ` +
|
|
52
49
|
'Lower the idle TTL or raise the absolute one.');
|
|
53
50
|
}
|
|
54
51
|
if (cookie.sameSite === 'none' && !cookie.secure) {
|
|
55
|
-
throw new OidcSessionConfigError('cookie.sameSite "none" requires cookie.secure — browsers reject the pair, ' +
|
|
52
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError('cookie.sameSite "none" requires cookie.secure — browsers reject the pair, ' +
|
|
56
53
|
'so the session cookie would be silently dropped on every response.');
|
|
57
54
|
}
|
|
58
55
|
return options;
|
|
59
56
|
}
|
|
57
|
+
function assertRedirectStatement(oidc) {
|
|
58
|
+
const fixed = oidc.redirectUri;
|
|
59
|
+
const perOrigin = oidc.redirectFromRequestOrigin;
|
|
60
|
+
if (fixed !== undefined && perOrigin !== undefined) {
|
|
61
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError('redirectUri and redirectFromRequestOrigin are both set. State ONE: a ' +
|
|
62
|
+
'fixed redirect URI for a single address, or an origin allowlist for ' +
|
|
63
|
+
'several.');
|
|
64
|
+
}
|
|
65
|
+
if (fixed === undefined && perOrigin === undefined) {
|
|
66
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError('neither redirectUri nor redirectFromRequestOrigin is set, so no sign-in ' +
|
|
67
|
+
'could ever return to this application.');
|
|
68
|
+
}
|
|
69
|
+
if (fixed !== undefined) {
|
|
70
|
+
if (typeof fixed !== 'string' || fixed.trim() === '') {
|
|
71
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError('redirectUri must be a non-empty string.');
|
|
72
|
+
}
|
|
73
|
+
assertAbsoluteHttpUrl('redirectUri', fixed);
|
|
74
|
+
if (oidc.postLogoutRedirectUri !== undefined) {
|
|
75
|
+
assertAbsoluteHttpUrl('postLogoutRedirectUri', oidc.postLogoutRedirectUri);
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (perOrigin === undefined) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (oidc.postLogoutRedirectUri !== undefined) {
|
|
83
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError('postLogoutRedirectUri names ONE address, but redirectFromRequestOrigin ' +
|
|
84
|
+
'serves several. State redirectFromRequestOrigin.postLogoutPath instead.');
|
|
85
|
+
}
|
|
86
|
+
(0, redirect_origin_1.parseRedirectOriginAllowlist)(perOrigin.allowedOrigins);
|
|
87
|
+
(0, redirect_origin_1.assertOriginRelativePath)('redirectFromRequestOrigin.callbackPath', perOrigin.callbackPath);
|
|
88
|
+
if (perOrigin.postLogoutPath !== undefined) {
|
|
89
|
+
(0, redirect_origin_1.assertOriginRelativePath)('redirectFromRequestOrigin.postLogoutPath', perOrigin.postLogoutPath);
|
|
90
|
+
}
|
|
91
|
+
(0, request_authority_1.parseTrustedProxies)(perOrigin.trustedProxies ?? []);
|
|
92
|
+
}
|
|
93
|
+
function assertNavigationErrorPath(value) {
|
|
94
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
95
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError('navigationErrorPath must be a non-empty path when set; omit it to keep ' +
|
|
96
|
+
'JSON refusals on the navigation routes.');
|
|
97
|
+
}
|
|
98
|
+
(0, redirect_origin_1.assertOriginRelativePath)('navigationErrorPath', value);
|
|
99
|
+
if ((0, cookie_1.containsControlCharacter)(value)) {
|
|
100
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError('navigationErrorPath contains a control character.');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
60
103
|
function assertAbsoluteHttpUrl(name, value) {
|
|
61
104
|
let parsed;
|
|
62
105
|
try {
|
|
63
106
|
parsed = new URL(value);
|
|
64
107
|
}
|
|
65
108
|
catch {
|
|
66
|
-
throw new OidcSessionConfigError(`${name} must be an absolute URL; got "${value}".`);
|
|
109
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be an absolute URL; got "${value}".`);
|
|
67
110
|
}
|
|
68
111
|
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
69
|
-
throw new OidcSessionConfigError(`${name} must be http or https; got "${parsed.protocol}".`);
|
|
112
|
+
throw new oidc_session_config_error_1.OidcSessionConfigError(`${name} must be http or https; got "${parsed.protocol}".`);
|
|
70
113
|
}
|
|
71
114
|
}
|
|
72
115
|
//# 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":";;;
|
|
1
|
+
{"version":3,"file":"oidc-session-options.js","sourceRoot":"","sources":["../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AAc,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAOD,SAAS,yBAAyB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,MAAM,IAAI,kDAAsB,CAC9B,yEAAyE;YACvE,yCAAyC,CAC5C,CAAC;IACJ,CAAC;IACD,IAAA,0CAAwB,EAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IACvD,IAAI,IAAA,iCAAwB,EAAC,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,kDAAsB,CAC9B,mDAAmD,CACpD,CAAC;IACJ,CAAC;AACH,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"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,CAAC;IACD,OAAO,IAAI,CAAC;AACd,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
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -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,oBAAY,oBAAoB;IAE9B,eAAe,qBAAqB;IAOpC,cAAc,oBAAoB;IAElC,oBAAoB,2BAA2B;IAM/C,qBAAqB,6BAA6B;IAMlD,uBAAuB,+BAA+B;IAMtD,uBAAuB,8BAA8B;
|
|
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,oBAAY,oBAAoB;IAE9B,eAAe,qBAAqB;IAOpC,cAAc,oBAAoB;IAElC,oBAAoB,2BAA2B;IAM/C,qBAAqB,6BAA6B;IAMlD,uBAAuB,+BAA+B;IAMtD,uBAAuB,8BAA8B;IASrD,4BAA4B,qCAAqC;IAOjE,uBAAuB,+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,SAA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