@3sixty/api-auth-service 0.20.0-next.0 → 0.20.0-next.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/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/index.js +17 -0
- package/dist/es/index.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/ITenantOverrideProcessorConfig.js +4 -0
- package/dist/es/models/ITenantOverrideProcessorConfig.js.map +1 -0
- package/dist/es/models/ITenantOverrideProcessorConstructorOptions.js +2 -0
- package/dist/es/models/ITenantOverrideProcessorConstructorOptions.js.map +1 -0
- package/dist/es/processors/tenantOverrideProcessor.js +144 -0
- package/dist/es/processors/tenantOverrideProcessor.js.map +1 -0
- package/dist/es/restEntryPoints.js +13 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js +355 -0
- package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js.map +1 -0
- package/dist/es/schema.js +13 -0
- package/dist/es/schema.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/types/entities/authenticationAuditEntry.d.ts +49 -0
- package/dist/types/entities/authenticationRateEntry.d.ts +17 -0
- package/dist/types/index.d.ts +14 -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/ITenantOverrideProcessorConfig.d.ts +19 -0
- package/dist/types/models/ITenantOverrideProcessorConstructorOptions.d.ts +20 -0
- package/dist/types/processors/tenantOverrideProcessor.d.ts +48 -0
- package/dist/types/restEntryPoints.d.ts +5 -0
- package/dist/types/routes/entityStorageAuthenticationAuditRoutes.d.ts +54 -0
- package/dist/types/schema.d.ts +4 -0
- package/dist/types/services/entityStorageAuthenticationAuditService.d.ts +72 -0
- package/dist/types/services/entityStorageAuthenticationRateService.d.ts +60 -0
- package/docs/changelog.md +1633 -0
- package/docs/examples.md +137 -0
- package/docs/open-api/spec.json +911 -0
- package/docs/reference/classes/AuthenticationAuditEntry.md +101 -0
- package/docs/reference/classes/AuthenticationRateEntry.md +37 -0
- package/docs/reference/classes/EntityStorageAuthenticationAuditService.md +241 -0
- package/docs/reference/classes/EntityStorageAuthenticationRateService.md +227 -0
- package/docs/reference/classes/TenantOverrideProcessor.md +129 -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/generateRestRoutesAuthenticationAudit.md +25 -0
- package/docs/reference/functions/initSchema.md +9 -0
- package/docs/reference/index.md +33 -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/ITenantOverrideProcessorConfig.md +39 -0
- package/docs/reference/interfaces/ITenantOverrideProcessorConstructorOptions.md +39 -0
- package/docs/reference/variables/restEntryPoints.md +5 -0
- package/docs/reference/variables/tagsAuthenticationAudit.md +5 -0
- package/locales/en.json +22 -0
- package/package.json +63 -6
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IEntityStorageAuthenticationRateServiceConfig } from "./IEntityStorageAuthenticationRateServiceConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the EntityStorageAuthenticationRateService constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface IEntityStorageAuthenticationRateServiceConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The entity storage for authentication rate entries.
|
|
8
|
+
* @default authentication-rate-entry
|
|
9
|
+
*/
|
|
10
|
+
authenticationRateEntryStorageType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The task scheduler component type.
|
|
13
|
+
* @default task-scheduler
|
|
14
|
+
*/
|
|
15
|
+
taskSchedulerComponentType?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The platform component type, used to run the periodic cleanup per tenant.
|
|
18
|
+
* @default platform
|
|
19
|
+
*/
|
|
20
|
+
platformComponentType?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The configuration for the authentication rate service.
|
|
23
|
+
*/
|
|
24
|
+
config?: IEntityStorageAuthenticationRateServiceConfig;
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the TenantOverrideProcessor.
|
|
3
|
+
*/
|
|
4
|
+
export interface ITenantOverrideProcessorConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Include the stack with errors.
|
|
7
|
+
*/
|
|
8
|
+
includeErrorStack?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The role value that grants escalated privilege for cross-tenant access.
|
|
11
|
+
* @default global-admin
|
|
12
|
+
*/
|
|
13
|
+
escalatedPrivilegeRole?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The authorization model ID to use for REST requests.
|
|
16
|
+
* @default system
|
|
17
|
+
*/
|
|
18
|
+
authorizationModelId?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ITenantOverrideProcessorConfig } from "./ITenantOverrideProcessorConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the TenantOverrideProcessor constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITenantOverrideProcessorConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The tenant admin component type.
|
|
8
|
+
* @default tenant-admin
|
|
9
|
+
*/
|
|
10
|
+
tenantAdminComponentType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The authorization component type.
|
|
13
|
+
* @default authorization
|
|
14
|
+
*/
|
|
15
|
+
authorizationComponentType?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for the processor.
|
|
18
|
+
*/
|
|
19
|
+
config?: ITenantOverrideProcessorConfig;
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type IBaseRoute, type IBaseRouteProcessor, type IHttpResponse, type IHttpServerRequest } from "@3sixty/api-models";
|
|
2
|
+
import { type IContextIds } from "@3sixty/context";
|
|
3
|
+
import type { ITenantOverrideProcessorConstructorOptions } from "../models/ITenantOverrideProcessorConstructorOptions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Processes the overrideTenant query parameter for routes that allow tenant override.
|
|
6
|
+
* Requires the caller to hold the escalated privilege role. Runs after AuthHeaderProcessor so
|
|
7
|
+
* authentication is always resolved in the caller's own partition first.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TenantOverrideProcessor implements IBaseRouteProcessor {
|
|
10
|
+
/**
|
|
11
|
+
* The query parameter name used to supply the override tenant ID.
|
|
12
|
+
*/
|
|
13
|
+
static readonly OVERRIDE_TENANT_PARAM: string;
|
|
14
|
+
/**
|
|
15
|
+
* The model identifier that is reserved for system-only use.
|
|
16
|
+
*/
|
|
17
|
+
static readonly DEFAULT_AUTHORIZATION_MODEL_ID: string;
|
|
18
|
+
/**
|
|
19
|
+
* The role string required to perform a tenant override.
|
|
20
|
+
*/
|
|
21
|
+
static readonly DEFAULT_ESCALATED_PRIVILEGE_ROLE: string;
|
|
22
|
+
/**
|
|
23
|
+
* Runtime name for the class.
|
|
24
|
+
*/
|
|
25
|
+
static readonly CLASS_NAME: string;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new instance of TenantOverrideProcessor.
|
|
28
|
+
* @param options Options for the processor.
|
|
29
|
+
*/
|
|
30
|
+
constructor(options?: ITenantOverrideProcessorConstructorOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Returns the class name of the component.
|
|
33
|
+
* @returns The class name of the component.
|
|
34
|
+
*/
|
|
35
|
+
className(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Pre process the REST request for the specified route.
|
|
38
|
+
* @param request The incoming request.
|
|
39
|
+
* @param response The outgoing response.
|
|
40
|
+
* @param route The route to process.
|
|
41
|
+
* @param contextIds The context IDs of the request.
|
|
42
|
+
* @param processorState The state handed through the processors.
|
|
43
|
+
* @returns A promise that resolves when the tenant override has been applied or skipped.
|
|
44
|
+
*/
|
|
45
|
+
pre(request: IHttpServerRequest, response: IHttpResponse, route: IBaseRoute | undefined, contextIds: IContextIds, processorState: {
|
|
46
|
+
[id: string]: unknown;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { IAuditCreateRequest, IAuditGetRequest, IAuditGetResponse, IAuditQueryRequest, IAuditQueryResponse, IAuditRemoveRequest, IAuditUpdateRequest } from "@3sixty/api-auth-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,72 @@
|
|
|
1
|
+
import type { AuthAuditEvent, IAuthenticationAuditComponent, IAuthenticationAuditEntry } from "@3sixty/api-auth-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-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
|
+
}
|