@3sixty/api-auth-entity-storage-service 0.0.0-stage → 0.20.0-next.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/LICENSE +201 -0
- package/README.md +24 -2
- package/dist/es/entities/authenticationAuditEntry.js +121 -0
- package/dist/es/entities/authenticationAuditEntry.js.map +1 -0
- package/dist/es/entities/authenticationRateEntry.js +37 -0
- package/dist/es/entities/authenticationRateEntry.js.map +1 -0
- package/dist/es/entities/authenticationUser.js +69 -0
- package/dist/es/entities/authenticationUser.js.map +1 -0
- package/dist/es/index.js +29 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IAuthHeaderProcessorConfig.js +4 -0
- package/dist/es/models/IAuthHeaderProcessorConfig.js.map +1 -0
- package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js +2 -0
- package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js.map +1 -0
- package/dist/es/models/IAuthTokenContext.js +4 -0
- package/dist/es/models/IAuthTokenContext.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationAdminServiceConfig.js +4 -0
- package/dist/es/models/IEntityStorageAuthenticationAdminServiceConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js +2 -0
- package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationAuditServiceConfig.js +4 -0
- package/dist/es/models/IEntityStorageAuthenticationAuditServiceConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js +2 -0
- package/dist/es/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationRateServiceConfig.js +2 -0
- package/dist/es/models/IEntityStorageAuthenticationRateServiceConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationRateServiceConstructorOptions.js +2 -0
- package/dist/es/models/IEntityStorageAuthenticationRateServiceConstructorOptions.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js +2 -0
- package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js +2 -0
- package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js.map +1 -0
- package/dist/es/processors/authHeaderProcessor.js +277 -0
- package/dist/es/processors/authHeaderProcessor.js.map +1 -0
- package/dist/es/restEntryPoints.js +27 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/es/routes/entityStorageAuthenticationAdminRoutes.js +367 -0
- package/dist/es/routes/entityStorageAuthenticationAdminRoutes.js.map +1 -0
- package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js +343 -0
- package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js.map +1 -0
- package/dist/es/routes/entityStorageAuthenticationRoutes.js +247 -0
- package/dist/es/routes/entityStorageAuthenticationRoutes.js.map +1 -0
- package/dist/es/schema.js +15 -0
- package/dist/es/schema.js.map +1 -0
- package/dist/es/services/entityStorageAuthenticationAdminService.js +323 -0
- package/dist/es/services/entityStorageAuthenticationAdminService.js.map +1 -0
- package/dist/es/services/entityStorageAuthenticationAuditService.js +240 -0
- package/dist/es/services/entityStorageAuthenticationAuditService.js.map +1 -0
- package/dist/es/services/entityStorageAuthenticationRateService.js +213 -0
- package/dist/es/services/entityStorageAuthenticationRateService.js.map +1 -0
- package/dist/es/services/entityStorageAuthenticationService.js +326 -0
- package/dist/es/services/entityStorageAuthenticationService.js.map +1 -0
- package/dist/es/utils/passwordHelper.js +58 -0
- package/dist/es/utils/passwordHelper.js.map +1 -0
- package/dist/es/utils/tokenHelper.js +142 -0
- package/dist/es/utils/tokenHelper.js.map +1 -0
- package/dist/types/entities/authenticationAuditEntry.d.ts +49 -0
- package/dist/types/entities/authenticationRateEntry.d.ts +17 -0
- package/dist/types/entities/authenticationUser.d.ts +33 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/models/IAuthHeaderProcessorConfig.d.ts +39 -0
- package/dist/types/models/IAuthHeaderProcessorConstructorOptions.d.ts +25 -0
- package/dist/types/models/IAuthTokenContext.d.ts +34 -0
- package/dist/types/models/IEntityStorageAuthenticationAdminServiceConfig.d.ts +14 -0
- package/dist/types/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.d.ts +20 -0
- package/dist/types/models/IEntityStorageAuthenticationAuditServiceConfig.d.ts +9 -0
- package/dist/types/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.d.ts +15 -0
- package/dist/types/models/IEntityStorageAuthenticationRateServiceConfig.d.ts +10 -0
- package/dist/types/models/IEntityStorageAuthenticationRateServiceConstructorOptions.d.ts +25 -0
- package/dist/types/models/IEntityStorageAuthenticationServiceConfig.d.ts +36 -0
- package/dist/types/models/IEntityStorageAuthenticationServiceConstructorOptions.d.ts +35 -0
- package/dist/types/processors/authHeaderProcessor.d.ts +57 -0
- package/dist/types/restEntryPoints.d.ts +5 -0
- package/dist/types/routes/entityStorageAuthenticationAdminRoutes.d.ts +62 -0
- package/dist/types/routes/entityStorageAuthenticationAuditRoutes.d.ts +54 -0
- package/dist/types/routes/entityStorageAuthenticationRoutes.d.ts +45 -0
- package/dist/types/schema.d.ts +4 -0
- package/dist/types/services/entityStorageAuthenticationAdminService.d.ts +65 -0
- package/dist/types/services/entityStorageAuthenticationAuditService.d.ts +72 -0
- package/dist/types/services/entityStorageAuthenticationRateService.d.ts +60 -0
- package/dist/types/services/entityStorageAuthenticationService.d.ts +65 -0
- package/dist/types/utils/passwordHelper.d.ts +24 -0
- package/dist/types/utils/tokenHelper.d.ts +60 -0
- package/docs/changelog.md +0 -0
- package/docs/examples.md +178 -0
- package/docs/open-api/spec.json +2122 -0
- package/docs/reference/classes/AuthHeaderProcessor.md +193 -0
- package/docs/reference/classes/AuthenticationAuditEntry.md +101 -0
- package/docs/reference/classes/AuthenticationRateEntry.md +37 -0
- package/docs/reference/classes/AuthenticationUser.md +69 -0
- package/docs/reference/classes/EntityStorageAuthenticationAdminService.md +229 -0
- package/docs/reference/classes/EntityStorageAuthenticationAuditService.md +241 -0
- package/docs/reference/classes/EntityStorageAuthenticationRateService.md +227 -0
- package/docs/reference/classes/EntityStorageAuthenticationService.md +221 -0
- package/docs/reference/classes/PasswordHelper.md +74 -0
- package/docs/reference/classes/TokenHelper.md +205 -0
- package/docs/reference/functions/authenticationAdminCreateUser.md +37 -0
- package/docs/reference/functions/authenticationAdminGetUser.md +31 -0
- package/docs/reference/functions/authenticationAdminGetUserByIdentity.md +31 -0
- package/docs/reference/functions/authenticationAdminRemoveUser.md +31 -0
- package/docs/reference/functions/authenticationAdminUpdateUser.md +31 -0
- package/docs/reference/functions/authenticationAdminUpdateUserPassword.md +31 -0
- package/docs/reference/functions/authenticationAuditCreate.md +37 -0
- package/docs/reference/functions/authenticationAuditGet.md +31 -0
- package/docs/reference/functions/authenticationAuditQuery.md +31 -0
- package/docs/reference/functions/authenticationAuditRemove.md +31 -0
- package/docs/reference/functions/authenticationAuditUpdate.md +31 -0
- package/docs/reference/functions/authenticationLogin.md +31 -0
- package/docs/reference/functions/authenticationLogout.md +31 -0
- package/docs/reference/functions/authenticationRefreshToken.md +31 -0
- package/docs/reference/functions/authenticationUpdatePassword.md +31 -0
- package/docs/reference/functions/generateRestRoutesAuthentication.md +25 -0
- package/docs/reference/functions/generateRestRoutesAuthenticationAdmin.md +25 -0
- package/docs/reference/functions/generateRestRoutesAuthenticationAudit.md +25 -0
- package/docs/reference/functions/initSchema.md +9 -0
- package/docs/reference/index.md +57 -0
- package/docs/reference/interfaces/IAuthHeaderProcessorConfig.md +86 -0
- package/docs/reference/interfaces/IAuthHeaderProcessorConstructorOptions.md +53 -0
- package/docs/reference/interfaces/IAuthTokenContext.md +60 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConfig.md +25 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConstructorOptions.md +39 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationAuditServiceConfig.md +11 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationAuditServiceConstructorOptions.md +25 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationRateServiceConfig.md +17 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationRateServiceConstructorOptions.md +53 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConfig.md +87 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConstructorOptions.md +81 -0
- package/docs/reference/variables/restEntryPoints.md +5 -0
- package/docs/reference/variables/tagsAuthentication.md +5 -0
- package/docs/reference/variables/tagsAuthenticationAdmin.md +5 -0
- package/docs/reference/variables/tagsAuthenticationAudit.md +5 -0
- package/locales/en.json +52 -0
- package/package.json +64 -5
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IAuthenticationRateActionConfig } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the entity storage authentication service.
|
|
4
|
+
*/
|
|
5
|
+
export interface IEntityStorageAuthenticationServiceConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The name of the key to retrieve from the vault for signing JWT.
|
|
8
|
+
* @default auth-signing
|
|
9
|
+
*/
|
|
10
|
+
signingKeyName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The default time to live for the JWT.
|
|
13
|
+
* @default 60
|
|
14
|
+
*/
|
|
15
|
+
defaultTtlMinutes?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The minimum password length for new password validation.
|
|
18
|
+
* @default 8
|
|
19
|
+
*/
|
|
20
|
+
minPasswordLength?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Optional override for login failure rate limit.
|
|
23
|
+
* @default { maxAttempts: 5, windowMinutes: 15 }
|
|
24
|
+
*/
|
|
25
|
+
loginRateLimit?: IAuthenticationRateActionConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Optional override for password change rate limit.
|
|
28
|
+
* @default { maxAttempts: 5, windowMinutes: 15 }
|
|
29
|
+
*/
|
|
30
|
+
passwordChangeRateLimit?: IAuthenticationRateActionConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Optional override for token refresh rate limit.
|
|
33
|
+
* @default { maxAttempts: 30, windowMinutes: 60 }
|
|
34
|
+
*/
|
|
35
|
+
tokenRefreshRateLimit?: IAuthenticationRateActionConfig;
|
|
36
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { IEntityStorageAuthenticationServiceConfig } from "./IEntityStorageAuthenticationServiceConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the EntityStorageAuthenticationService constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface IEntityStorageAuthenticationServiceConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The entity storage for the users.
|
|
8
|
+
* @default authentication-user
|
|
9
|
+
*/
|
|
10
|
+
userEntityStorageType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The vault for the private keys.
|
|
13
|
+
* @default vault
|
|
14
|
+
*/
|
|
15
|
+
vaultConnectorType?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The audit service.
|
|
18
|
+
* @default authentication-audit
|
|
19
|
+
*/
|
|
20
|
+
authenticationAuditServiceType?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The rate service.
|
|
23
|
+
* @default authentication-rate
|
|
24
|
+
*/
|
|
25
|
+
authenticationRateServiceType?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The component to retrieve tenant information.
|
|
28
|
+
* @default tenant-admin
|
|
29
|
+
*/
|
|
30
|
+
tenantAdminComponentType?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The configuration for the authentication.
|
|
33
|
+
*/
|
|
34
|
+
config?: IEntityStorageAuthenticationServiceConfig;
|
|
35
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type IBaseRoute, type IBaseRouteProcessor, type IHttpResponse, type IHttpServerRequest } from "@3sixty/api-models";
|
|
2
|
+
import { type IContextIds } from "@3sixty/context";
|
|
3
|
+
import type { IAuthHeaderProcessorConstructorOptions } from "../models/IAuthHeaderProcessorConstructorOptions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Handle a JWT token in the authorization header or cookies and validate it to populate request context identity.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AuthHeaderProcessor implements IBaseRouteProcessor {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime name for the class.
|
|
10
|
+
*/
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new instance of AuthHeaderProcessor.
|
|
14
|
+
* @param options Options for the processor.
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: IAuthHeaderProcessorConstructorOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
22
|
+
/**
|
|
23
|
+
* The service needs to be started when the application is initialized.
|
|
24
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
25
|
+
* @returns A promise that resolves when the node identity and organization ID have been cached.
|
|
26
|
+
*/
|
|
27
|
+
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Stop the processor and release the token cache.
|
|
30
|
+
* @returns A promise that resolves when the processor has stopped.
|
|
31
|
+
*/
|
|
32
|
+
stop(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Pre process the REST request for the specified route.
|
|
35
|
+
* @param request The incoming request.
|
|
36
|
+
* @param response The outgoing response.
|
|
37
|
+
* @param route The route to process.
|
|
38
|
+
* @param contextIds The context IDs of the request.
|
|
39
|
+
* @param processorState The state handed through the processors.
|
|
40
|
+
* @returns A promise that resolves when the JWT has been verified and the context populated, or an error response set.
|
|
41
|
+
*/
|
|
42
|
+
pre(request: IHttpServerRequest, response: IHttpResponse, route: IBaseRoute | undefined, contextIds: IContextIds, processorState: {
|
|
43
|
+
[id: string]: unknown;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Post process the REST request for the specified route.
|
|
47
|
+
* @param request The incoming request.
|
|
48
|
+
* @param response The outgoing response.
|
|
49
|
+
* @param route The route to process.
|
|
50
|
+
* @param contextIds The context IDs of the request.
|
|
51
|
+
* @param processorState The state handed through the processors.
|
|
52
|
+
* @returns A promise that resolves when the Set-Cookie header has been applied to the response if required.
|
|
53
|
+
*/
|
|
54
|
+
post(request: IHttpServerRequest, response: IHttpResponse, route: IBaseRoute | undefined, contextIds: IContextIds, processorState: {
|
|
55
|
+
[id: string]: unknown;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { IAdminUserCreateRequest, IAdminUserGetByIdentityRequest, IAdminUserGetRequest, IAdminUserGetResponse, IAdminUserRemoveRequest, IAdminUserUpdatePasswordRequest, IAdminUserUpdateRequest } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
import { type ICreatedResponse, type IHttpRequestContext, type INoContentResponse, type IRestRoute, type ITag } from "@3sixty/api-models";
|
|
3
|
+
/**
|
|
4
|
+
* The tag to associate with the routes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const tagsAuthenticationAdmin: ITag[];
|
|
7
|
+
/**
|
|
8
|
+
* The REST routes for authentication admin.
|
|
9
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
10
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
11
|
+
* @returns The generated routes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateRestRoutesAuthenticationAdmin(baseRouteName: string, componentName: string): IRestRoute[];
|
|
14
|
+
/**
|
|
15
|
+
* Create a new user.
|
|
16
|
+
* @param httpRequestContext The request context for the API.
|
|
17
|
+
* @param componentName The name of the component to use in the routes.
|
|
18
|
+
* @param request The request.
|
|
19
|
+
* @param baseRouteName The base route name to use for the location header.
|
|
20
|
+
* @returns The response object with additional http response properties.
|
|
21
|
+
*/
|
|
22
|
+
export declare function authenticationAdminCreateUser(httpRequestContext: IHttpRequestContext, componentName: string, request: IAdminUserCreateRequest, baseRouteName: string): Promise<ICreatedResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Update an existing user.
|
|
25
|
+
* @param httpRequestContext The request context for the API.
|
|
26
|
+
* @param componentName The name of the component to use in the routes.
|
|
27
|
+
* @param request The request.
|
|
28
|
+
* @returns The response object with additional http response properties.
|
|
29
|
+
*/
|
|
30
|
+
export declare function authenticationAdminUpdateUser(httpRequestContext: IHttpRequestContext, componentName: string, request: IAdminUserUpdateRequest): Promise<INoContentResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Update an existing user password.
|
|
33
|
+
* @param httpRequestContext The request context for the API.
|
|
34
|
+
* @param componentName The name of the component to use in the routes.
|
|
35
|
+
* @param request The request.
|
|
36
|
+
* @returns The response object with additional http response properties.
|
|
37
|
+
*/
|
|
38
|
+
export declare function authenticationAdminUpdateUserPassword(httpRequestContext: IHttpRequestContext, componentName: string, request: IAdminUserUpdatePasswordRequest): Promise<INoContentResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Get an existing user.
|
|
41
|
+
* @param httpRequestContext The request context for the API.
|
|
42
|
+
* @param componentName The name of the component to use in the routes.
|
|
43
|
+
* @param request The request.
|
|
44
|
+
* @returns The response object with additional http response properties.
|
|
45
|
+
*/
|
|
46
|
+
export declare function authenticationAdminGetUser(httpRequestContext: IHttpRequestContext, componentName: string, request: IAdminUserGetRequest): Promise<IAdminUserGetResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Get an existing user by identity.
|
|
49
|
+
* @param httpRequestContext The request context for the API.
|
|
50
|
+
* @param componentName The name of the component to use in the routes.
|
|
51
|
+
* @param request The request.
|
|
52
|
+
* @returns The response object with additional http response properties.
|
|
53
|
+
*/
|
|
54
|
+
export declare function authenticationAdminGetUserByIdentity(httpRequestContext: IHttpRequestContext, componentName: string, request: IAdminUserGetByIdentityRequest): Promise<IAdminUserGetResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Remove an existing user.
|
|
57
|
+
* @param httpRequestContext The request context for the API.
|
|
58
|
+
* @param componentName The name of the component to use in the routes.
|
|
59
|
+
* @param request The request.
|
|
60
|
+
* @returns The response object with additional http response properties.
|
|
61
|
+
*/
|
|
62
|
+
export declare function authenticationAdminRemoveUser(httpRequestContext: IHttpRequestContext, componentName: string, request: IAdminUserRemoveRequest): Promise<INoContentResponse>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { IAuditCreateRequest, IAuditGetRequest, IAuditGetResponse, IAuditQueryRequest, IAuditQueryResponse, IAuditRemoveRequest, IAuditUpdateRequest } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
import { type ICreatedResponse, type IHttpRequestContext, type INoContentResponse, type IRestRoute, type ITag } from "@3sixty/api-models";
|
|
3
|
+
/**
|
|
4
|
+
* The tag to associate with the routes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const tagsAuthenticationAudit: ITag[];
|
|
7
|
+
/**
|
|
8
|
+
* The REST routes for authentication audit.
|
|
9
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
10
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
11
|
+
* @returns The generated routes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateRestRoutesAuthenticationAudit(baseRouteName: string, componentName: string): IRestRoute[];
|
|
14
|
+
/**
|
|
15
|
+
* Create an authentication audit entry.
|
|
16
|
+
* @param httpRequestContext The request context for the API.
|
|
17
|
+
* @param componentName The name of the component to use in the routes.
|
|
18
|
+
* @param request The request.
|
|
19
|
+
* @param baseRouteName The base route name to use for the location header.
|
|
20
|
+
* @returns The response object with additional http response properties.
|
|
21
|
+
*/
|
|
22
|
+
export declare function authenticationAuditCreate(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditCreateRequest, baseRouteName: string): Promise<ICreatedResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Get an authentication audit entry.
|
|
25
|
+
* @param httpRequestContext The request context for the API.
|
|
26
|
+
* @param componentName The name of the component to use in the routes.
|
|
27
|
+
* @param request The request.
|
|
28
|
+
* @returns The response object with additional http response properties.
|
|
29
|
+
*/
|
|
30
|
+
export declare function authenticationAuditGet(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditGetRequest): Promise<IAuditGetResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Update an authentication audit entry.
|
|
33
|
+
* @param httpRequestContext The request context for the API.
|
|
34
|
+
* @param componentName The name of the component to use in the routes.
|
|
35
|
+
* @param request The request.
|
|
36
|
+
* @returns The response object with additional http response properties.
|
|
37
|
+
*/
|
|
38
|
+
export declare function authenticationAuditUpdate(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditUpdateRequest): Promise<INoContentResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Remove an authentication audit entry.
|
|
41
|
+
* @param httpRequestContext The request context for the API.
|
|
42
|
+
* @param componentName The name of the component to use in the routes.
|
|
43
|
+
* @param request The request.
|
|
44
|
+
* @returns The response object with additional http response properties.
|
|
45
|
+
*/
|
|
46
|
+
export declare function authenticationAuditRemove(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditRemoveRequest): Promise<INoContentResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Query authentication audit entries.
|
|
49
|
+
* @param httpRequestContext The request context for the API.
|
|
50
|
+
* @param componentName The name of the component to use in the routes.
|
|
51
|
+
* @param request The request.
|
|
52
|
+
* @returns The response object with additional http response properties.
|
|
53
|
+
*/
|
|
54
|
+
export declare function authenticationAuditQuery(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditQueryRequest): Promise<IAuditQueryResponse>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ILoginRequest, ILoginResponse, ILogoutRequest, IRefreshTokenRequest, IRefreshTokenResponse, IUpdatePasswordRequest } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
import type { IHttpRequestContext, INoContentResponse, IRestRoute, IRestRouteResponseOptions, ITag } from "@3sixty/api-models";
|
|
3
|
+
/**
|
|
4
|
+
* The tag to associate with the routes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const tagsAuthentication: ITag[];
|
|
7
|
+
/**
|
|
8
|
+
* The REST routes for authentication.
|
|
9
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
10
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
11
|
+
* @returns The generated routes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateRestRoutesAuthentication(baseRouteName: string, componentName: string): IRestRoute[];
|
|
14
|
+
/**
|
|
15
|
+
* Login to the server.
|
|
16
|
+
* @param httpRequestContext The request context for the API.
|
|
17
|
+
* @param componentName The name of the component to use in the routes.
|
|
18
|
+
* @param request The request.
|
|
19
|
+
* @returns The response object with additional http response properties.
|
|
20
|
+
*/
|
|
21
|
+
export declare function authenticationLogin(httpRequestContext: IHttpRequestContext, componentName: string, request: ILoginRequest): Promise<ILoginResponse & IRestRouteResponseOptions>;
|
|
22
|
+
/**
|
|
23
|
+
* Logout from the server.
|
|
24
|
+
* @param httpRequestContext The request context for the API.
|
|
25
|
+
* @param componentName The name of the component to use in the routes.
|
|
26
|
+
* @param request The request.
|
|
27
|
+
* @returns The response object with additional http response properties.
|
|
28
|
+
*/
|
|
29
|
+
export declare function authenticationLogout(httpRequestContext: IHttpRequestContext, componentName: string, request: ILogoutRequest): Promise<INoContentResponse & IRestRouteResponseOptions>;
|
|
30
|
+
/**
|
|
31
|
+
* Refresh the login token.
|
|
32
|
+
* @param httpRequestContext The request context for the API.
|
|
33
|
+
* @param componentName The name of the component to use in the routes.
|
|
34
|
+
* @param request The request.
|
|
35
|
+
* @returns The response object with additional http response properties.
|
|
36
|
+
*/
|
|
37
|
+
export declare function authenticationRefreshToken(httpRequestContext: IHttpRequestContext, componentName: string, request: IRefreshTokenRequest): Promise<IRefreshTokenResponse & IRestRouteResponseOptions>;
|
|
38
|
+
/**
|
|
39
|
+
* Update the user's password.
|
|
40
|
+
* @param httpRequestContext The request context for the API.
|
|
41
|
+
* @param componentName The name of the component to use in the routes.
|
|
42
|
+
* @param request The request.
|
|
43
|
+
* @returns The response object with additional http response properties.
|
|
44
|
+
*/
|
|
45
|
+
export declare function authenticationUpdatePassword(httpRequestContext: IHttpRequestContext, componentName: string, request: IUpdatePasswordRequest): Promise<INoContentResponse>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { IAuthenticationAdminComponent, IAuthenticationUser } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
import type { IEntityStorageAuthenticationAdminServiceConstructorOptions } from "../models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the authentication component using entity storage.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EntityStorageAuthenticationAdminService implements IAuthenticationAdminComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* The scope value that grants permission to assign privileged roles.
|
|
13
|
+
*/
|
|
14
|
+
static readonly DEFAULT_ESCALATED_PRIVILEGE_SCOPE: string;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new instance of EntityStorageAuthentication.
|
|
17
|
+
* @param options The dependencies for the identity connector.
|
|
18
|
+
*/
|
|
19
|
+
constructor(options?: IEntityStorageAuthenticationAdminServiceConstructorOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Returns the class name of the component.
|
|
22
|
+
* @returns The class name of the component.
|
|
23
|
+
*/
|
|
24
|
+
className(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Create a login for the user.
|
|
27
|
+
* @param user The user to create.
|
|
28
|
+
* @returns A promise that resolves when the user account has been created and the audit entry recorded.
|
|
29
|
+
*/
|
|
30
|
+
create(user: IAuthenticationUser & {
|
|
31
|
+
password: string;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Update a login for the user.
|
|
35
|
+
* @param user The user to update.
|
|
36
|
+
* @returns A promise that resolves when the user account has been updated and the audit entry recorded.
|
|
37
|
+
*/
|
|
38
|
+
update(user: Partial<IAuthenticationUser>): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Get a user by email.
|
|
41
|
+
* @param email The email address of the user to get.
|
|
42
|
+
* @returns The user details.
|
|
43
|
+
*/
|
|
44
|
+
get(email: string): Promise<IAuthenticationUser>;
|
|
45
|
+
/**
|
|
46
|
+
* Get a user by identity.
|
|
47
|
+
* @param identity The identity of the user to get.
|
|
48
|
+
* @returns The user details.
|
|
49
|
+
*/
|
|
50
|
+
getByIdentity(identity: string): Promise<IAuthenticationUser>;
|
|
51
|
+
/**
|
|
52
|
+
* Remove the current user.
|
|
53
|
+
* @param email The email address of the user to remove.
|
|
54
|
+
* @returns A promise that resolves when the user account has been removed and the audit entry recorded.
|
|
55
|
+
*/
|
|
56
|
+
remove(email: string): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Update the user's password.
|
|
59
|
+
* @param email The email address of the user to update.
|
|
60
|
+
* @param newPassword The new password for the user.
|
|
61
|
+
* @param currentPassword The current password, optional, if supplied will check against existing.
|
|
62
|
+
* @returns A promise that resolves when the password has been updated.
|
|
63
|
+
*/
|
|
64
|
+
updatePassword(email: string, newPassword: string, currentPassword?: string): Promise<void>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { AuthAuditEvent, IAuthenticationAuditComponent, IAuthenticationAuditEntry } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
import type { IEntityStorageAuthenticationAuditServiceConstructorOptions } from "../models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the authentication audit component using entity storage.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EntityStorageAuthenticationAuditService implements IAuthenticationAuditComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new instance of EntityStorageAuthenticationAuditService.
|
|
13
|
+
* @param options The dependencies for the identity connector.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options?: IEntityStorageAuthenticationAuditServiceConstructorOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Returns the class name of the component.
|
|
18
|
+
* @returns The class name of the component.
|
|
19
|
+
*/
|
|
20
|
+
className(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new audit entry.
|
|
23
|
+
* @param entry The audit entry to be logged.
|
|
24
|
+
* @returns The unique identifier of the created audit entry.
|
|
25
|
+
*/
|
|
26
|
+
create(entry: Omit<IAuthenticationAuditEntry, "id" | "dateCreated">): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Get an audit entry by id.
|
|
29
|
+
* @param id The unique identifier of the audit entry.
|
|
30
|
+
* @returns The audit entry.
|
|
31
|
+
*/
|
|
32
|
+
get(id: string): Promise<IAuthenticationAuditEntry>;
|
|
33
|
+
/**
|
|
34
|
+
* Update an audit entry.
|
|
35
|
+
* @param id The unique identifier of the audit entry to update.
|
|
36
|
+
* @param entry The fields to update on the audit entry.
|
|
37
|
+
* @returns A promise that resolves when the audit entry has been updated.
|
|
38
|
+
*/
|
|
39
|
+
update(id: string, entry: Partial<Omit<IAuthenticationAuditEntry, "id" | "dateCreated">>): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Remove an audit entry.
|
|
42
|
+
* @param id The unique identifier of the audit entry to remove.
|
|
43
|
+
* @returns A promise that resolves when the audit entry has been removed.
|
|
44
|
+
*/
|
|
45
|
+
remove(id: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Query the audit entries.
|
|
48
|
+
* @param options The query options.
|
|
49
|
+
* @param options.actorId The actor identifier to filter the audit entries, optional.
|
|
50
|
+
* @param options.organizationId The organization identifier to filter the audit entries, optional.
|
|
51
|
+
* @param options.tenantId The tenant identifier to filter the audit entries, optional.
|
|
52
|
+
* @param options.nodeId The node identifier to filter the audit entries, optional.
|
|
53
|
+
* @param options.event The audit event to filter the audit entries, optional.
|
|
54
|
+
* @param options.startDate The start date to filter the audit entries, optional.
|
|
55
|
+
* @param options.endDate The end date to filter the audit entries, optional.
|
|
56
|
+
* @param cursor The cursor for pagination.
|
|
57
|
+
* @param limit The maximum number of entries to return.
|
|
58
|
+
* @returns The audit entries.
|
|
59
|
+
*/
|
|
60
|
+
query(options?: {
|
|
61
|
+
actorId?: string;
|
|
62
|
+
organizationId?: string;
|
|
63
|
+
tenantId?: string;
|
|
64
|
+
nodeId?: string;
|
|
65
|
+
event?: AuthAuditEvent | string;
|
|
66
|
+
startDate?: string;
|
|
67
|
+
endDate?: string;
|
|
68
|
+
}, cursor?: string, limit?: number): Promise<{
|
|
69
|
+
entries: IAuthenticationAuditEntry[];
|
|
70
|
+
cursor?: string;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { IAuthenticationRateActionConfig, IAuthenticationRateComponent } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
import type { IEntityStorageAuthenticationRateServiceConstructorOptions } from "../models/IEntityStorageAuthenticationRateServiceConstructorOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the authentication rate component using entity storage.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EntityStorageAuthenticationRateService implements IAuthenticationRateComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new instance of EntityStorageAuthenticationRateService.
|
|
13
|
+
* @param options The constructor options.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options?: IEntityStorageAuthenticationRateServiceConstructorOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Register or update rate-limit configuration for an action.
|
|
18
|
+
* @param action The action name.
|
|
19
|
+
* @param config The action configuration.
|
|
20
|
+
* @returns A promise that resolves when the action configuration has been stored.
|
|
21
|
+
*/
|
|
22
|
+
registerAction(action: string, config: IAuthenticationRateActionConfig): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Unregister rate-limit configuration for an action.
|
|
25
|
+
* @param action The action name.
|
|
26
|
+
* @returns A promise that resolves when the action configuration has been removed.
|
|
27
|
+
*/
|
|
28
|
+
unregisterAction(action: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the class name of the component.
|
|
31
|
+
* @returns The class name of the component.
|
|
32
|
+
*/
|
|
33
|
+
className(): string;
|
|
34
|
+
/**
|
|
35
|
+
* The service needs to be started when the application is initialized.
|
|
36
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
37
|
+
* @returns A promise that resolves when the periodic cleanup task has been registered.
|
|
38
|
+
*/
|
|
39
|
+
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* The component needs to be stopped when the node is closed.
|
|
42
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
43
|
+
* @returns A promise that resolves when the periodic cleanup task has been removed.
|
|
44
|
+
*/
|
|
45
|
+
stop(nodeLoggingComponentType?: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Check the authentication rate for a given action and identifier.
|
|
48
|
+
* @param action The action to be checked.
|
|
49
|
+
* @param identifier The identifier to be checked.
|
|
50
|
+
* @returns The rate entry id.
|
|
51
|
+
*/
|
|
52
|
+
check(action: string, identifier: string): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Clear the authentication rate entry for the given action and identifier.
|
|
55
|
+
* @param action The action to clear.
|
|
56
|
+
* @param identifier The identifier to clear.
|
|
57
|
+
* @returns A promise that resolves when the rate entry has been removed.
|
|
58
|
+
*/
|
|
59
|
+
clear(action: string, identifier: string): Promise<void>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { IAuthenticationComponent } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
import type { IEntityStorageAuthenticationServiceConstructorOptions } from "../models/IEntityStorageAuthenticationServiceConstructorOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of the authentication component using entity storage.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EntityStorageAuthenticationService implements IAuthenticationComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new instance of EntityStorageAuthentication.
|
|
13
|
+
* @param options The dependencies for the identity connector.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options?: IEntityStorageAuthenticationServiceConstructorOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Returns the class name of the component.
|
|
18
|
+
* @returns The class name of the component.
|
|
19
|
+
*/
|
|
20
|
+
className(): string;
|
|
21
|
+
/**
|
|
22
|
+
* The service needs to be started when the application is initialized.
|
|
23
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
24
|
+
* @returns A promise that resolves when rate-limit actions have been registered and the node identity cached.
|
|
25
|
+
*/
|
|
26
|
+
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* The component needs to be stopped when the node is closed.
|
|
29
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
30
|
+
* @returns A promise that resolves when all rate-limit actions have been unregistered.
|
|
31
|
+
*/
|
|
32
|
+
stop(nodeLoggingComponentType?: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Perform a login for the user.
|
|
35
|
+
* @param email The email address for the user.
|
|
36
|
+
* @param password The password for the user.
|
|
37
|
+
* @returns The authentication token for the user, if it uses a mechanism with public access.
|
|
38
|
+
*/
|
|
39
|
+
login(email: string, password: string): Promise<{
|
|
40
|
+
token?: string;
|
|
41
|
+
expiry: number;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Logout the current user.
|
|
45
|
+
* @param token The token to logout, if it uses a mechanism with public access.
|
|
46
|
+
* @returns A promise that resolves when the logout audit entry has been recorded.
|
|
47
|
+
*/
|
|
48
|
+
logout(token?: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Refresh the token.
|
|
51
|
+
* @param token The token to refresh, if it uses a mechanism with public access.
|
|
52
|
+
* @returns The refreshed token, if it uses a mechanism with public access.
|
|
53
|
+
*/
|
|
54
|
+
refresh(token?: string): Promise<{
|
|
55
|
+
token?: string;
|
|
56
|
+
expiry: number;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Update the user's password.
|
|
60
|
+
* @param currentPassword The current password for the user.
|
|
61
|
+
* @param newPassword The new password for the user.
|
|
62
|
+
* @returns A promise that resolves when the password has been updated and the rate limit cleared.
|
|
63
|
+
*/
|
|
64
|
+
updatePassword(currentPassword: string, newPassword: string): Promise<void>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IAuthenticationAuditComponent } from "@3sixty/api-auth-entity-storage-models";
|
|
2
|
+
import type { IEntityStorageConnector } from "@3sixty/entity-storage-models";
|
|
3
|
+
import type { AuthenticationUser } from "../entities/authenticationUser.js";
|
|
4
|
+
/**
|
|
5
|
+
* Helper class for password operations.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PasswordHelper {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime name for the class.
|
|
10
|
+
*/
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* Update the password for a user.
|
|
14
|
+
* Validates password strength, verifies the current password if provided, then hashes and stores the new password and raises an audit event.
|
|
15
|
+
* @param userEntityStorage The entity storage for users.
|
|
16
|
+
* @param authenticationAuditService The optional audit service.
|
|
17
|
+
* @param user The user whose password is being updated.
|
|
18
|
+
* @param newPassword The new password to set.
|
|
19
|
+
* @param currentPassword The current password to verify against, if supplied.
|
|
20
|
+
* @param minPasswordLength Optional minimum password length for validation.
|
|
21
|
+
* @returns A promise that resolves when the new password has been stored and the audit entry recorded.
|
|
22
|
+
*/
|
|
23
|
+
static updatePassword(userEntityStorage: IEntityStorageConnector<AuthenticationUser>, authenticationAuditService: IAuthenticationAuditComponent | undefined, user: AuthenticationUser, newPassword: string, currentPassword?: string, minPasswordLength?: number): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type IVaultConnector } from "@3sixty/vault-models";
|
|
2
|
+
import { type IHttpHeaders, type IJwtHeader, type IJwtPayload } from "@3sixty/web";
|
|
3
|
+
/**
|
|
4
|
+
* Helper class for token operations.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TokenHelper {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new token.
|
|
13
|
+
* @param vaultConnector The vault connector.
|
|
14
|
+
* @param nodeId The node identifier, embedded as the JWT issuer claim.
|
|
15
|
+
* @param signingKeyName The signing key name, embedded as the JWT key identifier.
|
|
16
|
+
* @param userIdentity The subject for the token.
|
|
17
|
+
* @param organizationIdentity The organization for the token.
|
|
18
|
+
* @param tenantId The tenant id for the token.
|
|
19
|
+
* @param ttlMinutes The time to live for the token in minutes.
|
|
20
|
+
* @param scope The scopes for the token.
|
|
21
|
+
* @param passwordVersion The user's current password version counter, embedded in the token so that a password change invalidates existing tokens.
|
|
22
|
+
* @returns The new token and its expiry date.
|
|
23
|
+
*/
|
|
24
|
+
static createToken(vaultConnector: IVaultConnector, nodeId: string, signingKeyName: string, userIdentity: string, organizationIdentity: string | undefined, tenantId: string | undefined, ttlMinutes: number, scope?: string, passwordVersion?: number): Promise<{
|
|
25
|
+
token: string;
|
|
26
|
+
expiry: number;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Verify the token.
|
|
30
|
+
* @param vaultConnector The vault connector.
|
|
31
|
+
* @param nodeId The node identifier, expected to match the JWT issuer claim.
|
|
32
|
+
* @param signingKeyName The signing key name, expected to match the JWT key identifier.
|
|
33
|
+
* @param token The token to verify.
|
|
34
|
+
* @param requiredScopes The required scopes.
|
|
35
|
+
* @param verifyUser A function to verify the user identity and organization. The password version counter embedded in the token (pver claim) is passed so callers can detect if the password has changed since the token was issued.
|
|
36
|
+
* @returns The verified details.
|
|
37
|
+
* @throws UnauthorizedError if the token is missing, invalid or expired.
|
|
38
|
+
*/
|
|
39
|
+
static verify(vaultConnector: IVaultConnector, nodeId: string, signingKeyName: string, token: string | undefined, requiredScopes?: string[], verifyUser?: (sub: string, org: string, tid: string | undefined, passwordVersion: number | undefined) => Promise<string[]>): Promise<{
|
|
40
|
+
header: IJwtHeader;
|
|
41
|
+
payload: IJwtPayload;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Verify that a token carries all of the required scopes.
|
|
45
|
+
* @param scope The comma separated scopes from the token.
|
|
46
|
+
* @param requiredScopes The scopes the caller must hold.
|
|
47
|
+
* @throws UnauthorizedError if any of the required scopes is missing.
|
|
48
|
+
*/
|
|
49
|
+
static verifyScopes(scope: string | undefined, requiredScopes?: string[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* Extract the auth token from the headers, either from the authorization header or the cookie header.
|
|
52
|
+
* @param headers The headers to extract the token from.
|
|
53
|
+
* @param cookieName The name of the cookie to extract the token from.
|
|
54
|
+
* @returns The token if found.
|
|
55
|
+
*/
|
|
56
|
+
static extractTokenFromHeaders(headers?: IHttpHeaders, cookieName?: string): {
|
|
57
|
+
token: string;
|
|
58
|
+
location: "authorization" | "cookie";
|
|
59
|
+
} | undefined;
|
|
60
|
+
}
|
|
File without changes
|