lemonldap-ng-handler 0.9.6 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.1
4
+
5
+ - handler: **security** — rules are matched against a canonical request URI
6
+ (port of `Lemonldap::NG::Handler::Main::canonicalUri()`): decoded until stable
7
+ (`%2f`, `%252f`), duplicate slashes removed, query string kept. This completes
8
+ the CVE-2020-24660 fix (see
9
+ [GHSA-74vj-gq94-gp9r](https://github.com/LemonLDAPNG/lemonldap-ng.js/security/advisories/GHSA-74vj-gq94-gp9r))
10
+ - handler: **security** — a raw or decoded `.`/`..` segment is refused (400) and
11
+ rules are matched case-insensitively (`(?-i:...)` opts out): Node.js routers
12
+ do not normalize dot segments and may ignore case
13
+ - handler: **security** — a rule is tried on path and query, then on the path
14
+ alone (`^/admin$` applies to `/admin?x=1`); a decoded `%3f` stays encoded
15
+ - handler: **security** — the `Host` header is validated (400) and normalized
16
+ (port, IPv6 brackets, trailing dot, case) to resolve the virtual host,
17
+ maintenance mode and HTTPS; configuration keys are normalized the same way
18
+ - handler: redirections use the requested URI, and the portal `url` parameter is
19
+ its base64; the URI is escaped in logs
20
+ - safelib: `hostname()` normalizes the Host header like the handler
21
+ - handler: `normalize-url` is dropped, the obsolete Jest tests are replaced by
22
+ Vitest tests
23
+
24
+ ## 0.10.0
25
+
26
+ - All packages: ship `.d.mts` declarations and declare per-condition
27
+ `types` in the `exports` map, so that TypeScript resolves the types of
28
+ ESM imports under `node16`, `nodenext` and `bundler` module resolution
29
+ instead of failing with TS7016 (#64)
30
+ - All packages: bump to 0.10.0, internal dependencies now require `^0.10.0`
31
+ - handler: complete the OAuth2 handler port
32
+ (`Lemonldap::NG::Handler::Lib::OAuth2`). A Bearer token now designates an
33
+ access token session, which is followed to the user (or offline) session it
34
+ was issued for, instead of being used directly as a user session id. Token
35
+ attributes (`_scope`, `_clientId`, `_clientConfKey`, `_oidc_grant_type`,
36
+ `_audiences`, `_accessToken`) are exposed to rules and headers,
37
+ unauthenticated requests get a `401` with a `WWW-Authenticate: Bearer`
38
+ challenge (RFC 6750) instead of a redirection to the portal, the
39
+ `Authorization` header is hidden from the protected application, and
40
+ `unlog`/`delSession` also purge the OIDC session caches so that a revoked
41
+ token stops being honoured at once. `oidcStorage`, `oidcStorageOptions` and
42
+ `oidcRPMetaDataOptions` are read from the configuration and applied again on
43
+ every reload
44
+ - handler: **breaking** — a user session id is no longer accepted as a Bearer
45
+ token, and a session id not shaped like one (`/^[A-Za-z0-9_-]+$/`) is refused
46
+ before reaching the storage. Deployments using a custom session id generator
47
+ producing other characters must adapt it
48
+ - handler: `fetchId()` may now return a promise, and `retrieveSession()`
49
+ receives the request as an optional second argument
50
+ - jwt: `getAccessTokenSessionId()` only returns a `jti` claim that is a
51
+ non-empty string, as its signature promises
52
+
3
53
  ## 0.9.6
4
54
 
5
55
  - Update re2 to 1.26.1
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Canonical form of an URI, as web servers do before routing requests to
3
+ * applications: the path is percent-decoded and normalized (duplicate slashes
4
+ * removed). The query string is left untouched since some rules contain GET
5
+ * parameters.
6
+ *
7
+ * This is a port of Lemonldap::NG::Handler::Main::canonicalUri(), with
8
+ * intentional differences for Node.js:
9
+ *
10
+ * - the path is decoded until it is stable, because an application or its
11
+ * framework may decode it more than once ("%252f");
12
+ * - a path containing "." or ".." segments, in its raw or decoded form, is
13
+ * rejected: Node.js routers (Express, Fastify, ...) do not normalize dot
14
+ * segments, so removing them here would make the handler decide on a path
15
+ * the application does not serve ("/admin/..%2Fpublic" would be seen as
16
+ * "/public" by the handler but routed under "/admin" by Express).
17
+ *
18
+ * Location rules must be matched against the path the protected application
19
+ * will serve, otherwise they can be bypassed with an encoded URL: the
20
+ * canonicalization used for CVE-2020-24660 did not decode "%2f", so a deny
21
+ * rule on "/admin/secret" missed "/admin%2fsecret".
22
+ */
23
+ /**
24
+ * Raised when the request URI can not be matched safely against location rules.
25
+ */
26
+ export declare class InvalidUriError extends Error {
27
+ readonly uri: string;
28
+ constructor(uri: string);
29
+ }
30
+ /**
31
+ * Request URI as sent by the client, restricted to its path and query: it
32
+ * identifies the resource for redirections, unlike the canonical URI that is
33
+ * only meant to be matched against rules.
34
+ */
35
+ export declare function rawRequestUri(uri?: string | null): string;
36
+ /**
37
+ * @param uri URI to canonicalize
38
+ * @returns canonical URI
39
+ * @throws InvalidUriError if the URI can not be matched safely
40
+ */
41
+ export declare function canonicalUri(uri?: string | null): string;
42
+ export default canonicalUri;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Canonical form of an URI, as web servers do before routing requests to
3
+ * applications: the path is percent-decoded and normalized (duplicate slashes
4
+ * removed). The query string is left untouched since some rules contain GET
5
+ * parameters.
6
+ *
7
+ * This is a port of Lemonldap::NG::Handler::Main::canonicalUri(), with
8
+ * intentional differences for Node.js:
9
+ *
10
+ * - the path is decoded until it is stable, because an application or its
11
+ * framework may decode it more than once ("%252f");
12
+ * - a path containing "." or ".." segments, in its raw or decoded form, is
13
+ * rejected: Node.js routers (Express, Fastify, ...) do not normalize dot
14
+ * segments, so removing them here would make the handler decide on a path
15
+ * the application does not serve ("/admin/..%2Fpublic" would be seen as
16
+ * "/public" by the handler but routed under "/admin" by Express).
17
+ *
18
+ * Location rules must be matched against the path the protected application
19
+ * will serve, otherwise they can be bypassed with an encoded URL: the
20
+ * canonicalization used for CVE-2020-24660 did not decode "%2f", so a deny
21
+ * rule on "/admin/secret" missed "/admin%2fsecret".
22
+ */
23
+ /**
24
+ * Raised when the request URI can not be matched safely against location rules.
25
+ */
26
+ export declare class InvalidUriError extends Error {
27
+ readonly uri: string;
28
+ constructor(uri: string);
29
+ }
30
+ /**
31
+ * Request URI as sent by the client, restricted to its path and query: it
32
+ * identifies the resource for redirections, unlike the canonical URI that is
33
+ * only meant to be matched against rules.
34
+ */
35
+ export declare function rawRequestUri(uri?: string | null): string;
36
+ /**
37
+ * @param uri URI to canonicalize
38
+ * @returns canonical URI
39
+ * @throws InvalidUriError if the URI can not be matched safely
40
+ */
41
+ export declare function canonicalUri(uri?: string | null): string;
42
+ export default canonicalUri;
package/lib/cda.d.mts ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * CDA (Cross-Domain Authentication) utilities for LemonLDAP::NG
3
+ * Port of Lemonldap::NG::Handler::Main::CDA
4
+ *
5
+ * CDA allows authentication to be shared across different domains
6
+ * by using encrypted cookies or URL parameters.
7
+ */
8
+ import Crypto from "@lemonldap-ng/crypto";
9
+ /**
10
+ * CDA cookie value structure
11
+ */
12
+ export interface CDAValue {
13
+ sessionId: string;
14
+ timestamp: number;
15
+ domain?: string;
16
+ }
17
+ /**
18
+ * Create a CDA cookie value
19
+ * @param cipher - Crypto instance for encryption
20
+ * @param sessionId - Session ID to encode
21
+ * @param timestamp - Optional timestamp (defaults to now)
22
+ * @returns Encrypted CDA cookie value
23
+ */
24
+ export declare function createCDACookie(cipher: Crypto, sessionId: string, timestamp?: number): string;
25
+ /**
26
+ * Parse and validate a CDA cookie value
27
+ * @param cipher - Crypto instance for decryption
28
+ * @param cookieValue - Encrypted cookie value
29
+ * @param maxAge - Maximum age in seconds (default: 120)
30
+ * @returns Parsed CDA value or null if invalid
31
+ */
32
+ export declare function parseCDACookie(cipher: Crypto, cookieValue: string, maxAge?: number): CDAValue | null;
33
+ /**
34
+ * Generate CDA URL parameter
35
+ * @param cipher - Crypto instance
36
+ * @param sessionId - Session ID
37
+ * @param url - Target URL
38
+ * @returns URL with CDA parameter
39
+ */
40
+ export declare function appendCDAParam(cipher: Crypto, sessionId: string, url: string): string;
41
+ /**
42
+ * Extract CDA value from URL
43
+ * @param url - URL potentially containing CDA parameter
44
+ * @returns CDA parameter value or null
45
+ */
46
+ export declare function extractCDAFromUrl(url: string): string | null;
47
+ /**
48
+ * Build Set-Cookie header for CDA
49
+ * @param cookieName - Cookie name
50
+ * @param value - Cookie value
51
+ * @param domain - Cookie domain
52
+ * @param expiration - Expiration in seconds (0 for session cookie)
53
+ * @param secure - Whether to set Secure flag
54
+ * @param httpOnly - Whether to set HttpOnly flag
55
+ * @returns Cookie header string
56
+ */
57
+ export declare function buildCDACookieHeader(cookieName: string, value: string, domain: string, expiration?: number, secure?: boolean, httpOnly?: boolean): string;
58
+ /**
59
+ * Delete CDA cookie header
60
+ * @param cookieName - Cookie name
61
+ * @param domain - Cookie domain
62
+ * @returns Cookie header string that expires the cookie
63
+ */
64
+ export declare function deleteCDACookieHeader(cookieName: string, domain: string): string;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * AuthBasic Handler for LemonLDAP::NG
3
+ * Port of Lemonldap::NG::Handler::Lib::AuthBasic
4
+ *
5
+ * This handler supports HTTP Basic Authentication by:
6
+ * 1. Computing a deterministic session ID from credentials
7
+ * 2. Checking if session exists
8
+ * 3. If not, asking the portal to create it via REST API
9
+ * 4. Sending WWW-Authenticate challenge when needed
10
+ */
11
+ import express from "express";
12
+ import http from "http";
13
+ import { LLNG_Session } from "@lemonldap-ng/types";
14
+ import LemonldapNGHandler from "./handlerMain.mjs";
15
+ declare class LemonldapNGHandlerAuthBasic extends LemonldapNGHandler {
16
+ private pendingAuth;
17
+ /**
18
+ * Override fetchId to compute session ID from Basic Auth credentials
19
+ * Session ID = sha256(base64_creds + pepper)
20
+ * pepper = int(time / timeout) + keyH (changes daily)
21
+ * @param req - HTTP request
22
+ */
23
+ fetchId(req: express.Request | http.IncomingMessage): string;
24
+ /**
25
+ * Override retrieveSession to create session via portal if needed
26
+ * @param id - Session ID
27
+ */
28
+ retrieveSession(id: string): Promise<LLNG_Session>;
29
+ /**
30
+ * Create session via portal REST API
31
+ * POST to portal/sessions/global/{id}?auth
32
+ * @param id - Session ID to create
33
+ * @param username - Username from Basic auth
34
+ * @param password - Password from Basic auth
35
+ * @param xff - X-Forwarded-For header value
36
+ * @returns true if session created successfully
37
+ */
38
+ private createSession;
39
+ /**
40
+ * Hide Authorization header from protected application
41
+ * Called after successful authentication
42
+ * @param req - HTTP request
43
+ */
44
+ hideCookie(req: express.Request | http.IncomingMessage): void;
45
+ /**
46
+ * Override goToPortal to send Basic challenge instead of redirect
47
+ * @param res - HTTP response
48
+ * @param uri - Original URI
49
+ * @param args - Additional arguments
50
+ */
51
+ goToPortal(res: http.ServerResponse, uri: string, args?: string): void;
52
+ }
53
+ export default LemonldapNGHandlerAuthBasic;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * CDA (Cross-Domain Authentication) Handler for LemonLDAP::NG
3
+ * Port of Lemonldap::NG::Handler::Main with CDA support
4
+ *
5
+ * This handler enables cross-domain authentication by:
6
+ * 1. Checking for CDA cookies/parameters on incoming requests
7
+ * 2. Setting CDA cookies when users authenticate
8
+ * 3. Propagating authentication across configured domains
9
+ */
10
+ import express from "express";
11
+ import http from "http";
12
+ import LemonldapNGHandler from "./handlerMain.mjs";
13
+ declare class LemonldapNGHandlerCDA extends LemonldapNGHandler {
14
+ /**
15
+ * Override fetchId to check for CDA cookie/parameter first
16
+ * @param req - HTTP request
17
+ */
18
+ fetchId(req: express.Request | http.IncomingMessage): string;
19
+ /**
20
+ * Get CDA cookie value from request
21
+ * @param req - HTTP request
22
+ * @param cookieName - Cookie name to look for
23
+ */
24
+ private getCDACookie;
25
+ /**
26
+ * Set CDA cookie on response (placeholder for middleware integration)
27
+ *
28
+ * TODO: Implement full CDA cookie setting mechanism. Options include:
29
+ * 1. Store the value in req.llngCdaInfo and set in sendHeaders via response
30
+ * 2. Use express middleware to intercept and set the cookie
31
+ * 3. Pass response object through the call chain
32
+ *
33
+ * Currently a no-op as we don't have access to the response object here.
34
+ *
35
+ * @param _req - HTTP request (unused)
36
+ * @param _sessionId - Session ID to set (unused)
37
+ */
38
+ private setCDACookie;
39
+ /**
40
+ * Override sendHeaders to also set CDA cookie
41
+ * @param req - HTTP request
42
+ * @param session - User session
43
+ */
44
+ sendHeaders(req: express.Request | http.IncomingMessage, session: import("@lemonldap-ng/types").LLNG_Session): void;
45
+ /**
46
+ * Get domain for CDA cookie
47
+ * @param req - HTTP request
48
+ */
49
+ private getCDACookieDomain;
50
+ /**
51
+ * Override goToPortal to include CDA parameter
52
+ * @param res - HTTP response
53
+ * @param uri - Original URI
54
+ * @param args - Additional arguments
55
+ */
56
+ goToPortal(res: http.ServerResponse, uri: string, args?: string): void;
57
+ }
58
+ export default LemonldapNGHandlerCDA;
@@ -0,0 +1,21 @@
1
+ import { LLNG_Session } from "@lemonldap-ng/types";
2
+ import { Handler_Args } from "./init.mjs";
3
+ import LemonldapNGHandler from "./handlerMain.mjs";
4
+ import express from "express";
5
+ import http from "http";
6
+ type Vhost_Config = {
7
+ prot: string;
8
+ host: string;
9
+ path: string;
10
+ port: string;
11
+ headers?: {
12
+ [k: string]: string;
13
+ };
14
+ lb?: boolean;
15
+ };
16
+ declare class LemonldapNGHandlerDevOps extends LemonldapNGHandler {
17
+ constructor(args: Handler_Args);
18
+ grant(req: express.Request | http.IncomingMessage, uri: string, session: LLNG_Session): Promise<boolean>;
19
+ loadVhostConfig(req: express.Request | http.IncomingMessage, vhost: string, lvOpts: Vhost_Config): Promise<boolean>;
20
+ }
21
+ export default LemonldapNGHandlerDevOps;
@@ -0,0 +1,9 @@
1
+ import { Request } from "express";
2
+ import { ParamsDictionary } from "express-serve-static-core";
3
+ import { IncomingMessage } from "http";
4
+ import { ParsedQs } from "qs";
5
+ import LemonldapNGHandlerDevOps from "./handlerDevOps.mjs";
6
+ declare class LemonldapNGHandlerDevOpsST extends LemonldapNGHandlerDevOps {
7
+ fetchId(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>> | IncomingMessage): string;
8
+ }
9
+ export default LemonldapNGHandlerDevOpsST;
@@ -0,0 +1,37 @@
1
+ import { LLNG_Session } from "@lemonldap-ng/types";
2
+ import HandlerInit from "./init.mjs";
3
+ import express from "express";
4
+ import http from "http";
5
+ export type FastCGI_Opts = {
6
+ mode: string | undefined;
7
+ port: number | undefined;
8
+ ip: string | undefined;
9
+ };
10
+ declare class LemonldapNGHandler extends HandlerInit {
11
+ protected lastSessionId: string | null;
12
+ private lastSessionData;
13
+ private lastSessionTime;
14
+ init(): Promise<boolean>;
15
+ /**
16
+ * run(), the access control function
17
+ */
18
+ run(req: express.Request | http.IncomingMessage, res: http.ServerResponse, next: Function): any;
19
+ selfUri(vhost: string, uri: string, host?: string): string;
20
+ nginxServer(fcgiOpt: FastCGI_Opts): void;
21
+ setError(res: http.ServerResponse, uri: string, code: number, txt: string): void;
22
+ isUnprotected(req: express.Request | http.IncomingMessage, uri: string): number | false;
23
+ resolveAlias(req: express.Request | http.IncomingMessage): string;
24
+ fetchId(req: express.Request | http.IncomingMessage): string | Promise<string>;
25
+ retrieveSession(id: string, _req?: express.Request | http.IncomingMessage): Promise<LLNG_Session>;
26
+ /**
27
+ * Local unlog - clear session from all local caches
28
+ * @param sessionId - Optional session ID to clear (uses last cached if not provided)
29
+ */
30
+ localUnlog(sessionId?: string): Promise<void>;
31
+ grant(req: express.Request | http.IncomingMessage, uri: string, session: LLNG_Session): Promise<boolean>;
32
+ sendHeaders(req: express.Request | http.IncomingMessage, session: LLNG_Session): void;
33
+ hideCookie(req: express.Request | http.IncomingMessage): void;
34
+ forbidden(req: express.Request | http.IncomingMessage, res: http.ServerResponse, session: LLNG_Session): void;
35
+ goToPortal(res: http.ServerResponse, uri: string, args?: string): void;
36
+ }
37
+ export default LemonldapNGHandler;
@@ -8,7 +8,7 @@ export type FastCGI_Opts = {
8
8
  ip: string | undefined;
9
9
  };
10
10
  declare class LemonldapNGHandler extends HandlerInit {
11
- private lastSessionId;
11
+ protected lastSessionId: string | null;
12
12
  private lastSessionData;
13
13
  private lastSessionTime;
14
14
  init(): Promise<boolean>;
@@ -16,13 +16,13 @@ declare class LemonldapNGHandler extends HandlerInit {
16
16
  * run(), the access control function
17
17
  */
18
18
  run(req: express.Request | http.IncomingMessage, res: http.ServerResponse, next: Function): any;
19
- selfUri(vhost: string, uri: string): string;
19
+ selfUri(vhost: string, uri: string, host?: string): string;
20
20
  nginxServer(fcgiOpt: FastCGI_Opts): void;
21
21
  setError(res: http.ServerResponse, uri: string, code: number, txt: string): void;
22
22
  isUnprotected(req: express.Request | http.IncomingMessage, uri: string): number | false;
23
23
  resolveAlias(req: express.Request | http.IncomingMessage): string;
24
- fetchId(req: express.Request | http.IncomingMessage): string;
25
- retrieveSession(id: string): Promise<LLNG_Session>;
24
+ fetchId(req: express.Request | http.IncomingMessage): string | Promise<string>;
25
+ retrieveSession(id: string, _req?: express.Request | http.IncomingMessage): Promise<LLNG_Session>;
26
26
  /**
27
27
  * Local unlog - clear session from all local caches
28
28
  * @param sessionId - Optional session ID to clear (uses last cached if not provided)
@@ -0,0 +1,140 @@
1
+ /**
2
+ * OAuth2/OIDC Handler for LemonLDAP::NG
3
+ * Port of Lemonldap::NG::Handler::Lib::OAuth2
4
+ *
5
+ * A Bearer access token is an *opaque credential*: the token itself (or the
6
+ * `jti` claim of its JWT serialization) is the identifier of an access token
7
+ * session created by the Portal. This handler therefore:
8
+ *
9
+ * 1. resolves the access token session in the OIDC session storage,
10
+ * 2. follows it to the user session (or offline session) it was issued for,
11
+ * 3. exposes the token attributes (scope, client, audiences, grant type) as
12
+ * session attributes so that rules and headers can use them.
13
+ *
14
+ * Nothing but the session identifier is ever read from the token: the trust
15
+ * anchor is the session store, not the token payload.
16
+ */
17
+ import express from "express";
18
+ import http from "http";
19
+ import LemonldapNGHandler from "./handlerMain.mjs";
20
+ import { LLNG_Session } from "@lemonldap-ng/types";
21
+ declare class LemonldapNGHandlerOAuth2 extends LemonldapNGHandler {
22
+ private oidcSessionAcc;
23
+ private ownOidcSessionAcc;
24
+ private state;
25
+ /**
26
+ * Override reload() - and not init() - to set up the OIDC session storage.
27
+ *
28
+ * init() runs once, while reload() runs again on every configuration change
29
+ * announced by the message broker, and it rebuilds the main session
30
+ * accessor. The OIDC accessor must follow: else the handler would keep
31
+ * querying the previous storage (with its own cache), localUnlog() would
32
+ * only purge the new one, and a modified oidcStorage would never be applied.
33
+ */
34
+ reload(): Promise<boolean>;
35
+ /**
36
+ * (Re)build the accessor used for access token and offline sessions
37
+ *
38
+ * The new accessor is only installed once it is known to be usable: a
39
+ * reload announcing a broken oidcStorage must leave the handler running on
40
+ * its previous storage rather than answering 401 to every token, and must
41
+ * not leak the accessor it failed to replace (its node-persist timers would
42
+ * keep the process alive).
43
+ */
44
+ private initOidcSessionStorage;
45
+ /**
46
+ * Override localUnlog to purge the OIDC caches too
47
+ *
48
+ * When the Portal revokes an access token, it broadcasts an unlog/delSession
49
+ * message holding the id of the deleted session. With a dedicated
50
+ * oidcStorage, that session lives in the OIDC accessor, whose caches
51
+ * Main::localUnlog() does not know about: the revoked token would keep
52
+ * authenticating until the cache entry expires.
53
+ * @param sessionId - Session ID to clear (uses last cached if not provided)
54
+ */
55
+ localUnlog(sessionId?: string): Promise<void>;
56
+ /**
57
+ * Override run to bind the per-request state to both req and res: fetchId()
58
+ * and retrieveSession() only see the request, goToPortal() only sees the
59
+ * response.
60
+ */
61
+ run(req: express.Request | http.IncomingMessage, res: http.ServerResponse, next: Function): any;
62
+ /**
63
+ * Override fetchId to resolve an OAuth2 Bearer token into a session id
64
+ *
65
+ * Contrary to the cookie case, the value carried by the request is *not* the
66
+ * user session id: it identifies an access token session, which in turn
67
+ * references the user session (or an offline session).
68
+ * @param req - HTTP request
69
+ */
70
+ fetchId(req: express.Request | http.IncomingMessage): Promise<string>;
71
+ /**
72
+ * Override retrieveSession to handle offline sessions and to expose the
73
+ * access token attributes to rules and headers
74
+ * @param id - Session ID, prefixed by "O-" for offline sessions
75
+ * @param req - HTTP request, when available
76
+ */
77
+ retrieveSession(id: string, req?: express.Request | http.IncomingMessage): Promise<LLNG_Session>;
78
+ /**
79
+ * Hide the access token from the protected application
80
+ * @param req - HTTP request
81
+ */
82
+ hideCookie(req: express.Request | http.IncomingMessage): void;
83
+ /**
84
+ * A resource server never redirects: answer with a 401 and the challenge
85
+ * described in RFC 6750 section 3
86
+ * @param res - HTTP response
87
+ * @param _uri - Original URI (unused)
88
+ * @param _args - Additional arguments (unused)
89
+ */
90
+ goToPortal(res: http.ServerResponse, _uri: string, _args?: string): void;
91
+ /**
92
+ * Close the dedicated OIDC session storage, if any
93
+ */
94
+ stopEventLoop(): Promise<void>;
95
+ /**
96
+ * Get a session from the OIDC storage and check that it is not expired
97
+ *
98
+ * Note: the session backends do not tell an unknown session apart from an
99
+ * unreachable storage, so both end up as "notFound" here, exactly as in the
100
+ * Perl handler and as in the cookie path of Handler::Main. A storage outage
101
+ * is therefore reported to the client as an invalid token. Fixing this
102
+ * requires a "not found" signal in every @lemonldap-ng/session-* backend.
103
+ * @param id - Access token, offline or OIDC session id
104
+ */
105
+ private getOIDCInfos;
106
+ /**
107
+ * Collect the access token session fields exposed to rules and headers
108
+ * @param accessToken - Bearer token, as received
109
+ * @param infos - Access token session
110
+ */
111
+ private tokenAttributes;
112
+ /**
113
+ * Build a copy of the session enriched with the access token attributes.
114
+ * A copy is mandatory: the session object may be shared with the session
115
+ * caches.
116
+ */
117
+ private withTokenAttributes;
118
+ /**
119
+ * Check that a value may be handed over to the session storage
120
+ *
121
+ * Applied both to the id carried by the token and to the ids read from the
122
+ * access token session: the latter are written by the Portal, but they end
123
+ * up in a LDAP DN or in an URL just the same.
124
+ * @param id - Candidate session id
125
+ */
126
+ private isSessionId;
127
+ /**
128
+ * Get (or create) the state attached to a request or a response
129
+ */
130
+ private stateFor;
131
+ /**
132
+ * Reject the request with an "invalid_token" OAuth2 error
133
+ */
134
+ private invalidToken;
135
+ /**
136
+ * Use the LLNG cookie when the Bearer token can not be resolved
137
+ */
138
+ private fallbackToCookie;
139
+ }
140
+ export default LemonldapNGHandlerOAuth2;