@universis/janitor 1.6.3 → 1.9.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 +3 -3
- package/dist/index.d.ts +213 -7
- package/dist/index.esm.js +896 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +909 -9
- package/dist/index.js.map +1 -1
- package/package.json +40 -20
- package/src/HttpBearerStategy.js +134 -0
- package/src/HttpBearerStrategy.d.ts +4 -0
- package/src/RedisClientStore.js +1 -1
- package/src/ScopeAccessConfiguration.d.ts +23 -1
- package/src/ScopeAccessConfiguration.js +38 -8
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/.gitlab-ci.yml +0 -29
- package/dist/OAuth2ClientService.d.ts +0 -98
- package/dist/OAuth2ClientService.js +0 -251
- package/dist/OAuth2ClientService.js.map +0 -1
- package/dist/RateLimitService.d.ts +0 -4
- package/dist/RateLimitService.js +0 -102
- package/dist/RateLimitService.js.map +0 -1
- package/dist/RedisClientStore.d.ts +0 -5
- package/dist/RedisClientStore.js +0 -122
- package/dist/RedisClientStore.js.map +0 -1
- package/dist/RemoteAddressValidator.d.ts +0 -10
- package/dist/RemoteAddressValidator.js +0 -89
- package/dist/RemoteAddressValidator.js.map +0 -1
- package/dist/ScopeAccessConfiguration.d.ts +0 -65
- package/dist/ScopeAccessConfiguration.js +0 -160
- package/dist/ScopeAccessConfiguration.js.map +0 -1
- package/dist/SpeedLimitService.d.ts +0 -4
- package/dist/SpeedLimitService.js +0 -113
- package/dist/SpeedLimitService.js.map +0 -1
- package/dist/polyfills.js +0 -11
- package/dist/polyfills.js.map +0 -1
- package/dist/validateScope.d.ts +0 -2
- package/dist/validateScope.js +0 -23
- package/dist/validateScope.js.map +0 -1
- package/src/polyfills.js +0 -10
package/README.md
CHANGED
|
@@ -232,15 +232,15 @@ Speed limit headers will be available only if the request is made from the same
|
|
|
232
232
|
|
|
233
233
|
## ScopeAccessConfiguration
|
|
234
234
|
|
|
235
|
-
`ScopeAccessConfiguration` is a configurable application
|
|
235
|
+
`ScopeAccessConfiguration` is a configurable application configuration strategy for limiting access to service endpoints based on user scopes.
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
Enable scope access configuration using `EnableScopeAccessConfiguration` service:
|
|
238
238
|
|
|
239
239
|
```json
|
|
240
240
|
{
|
|
241
241
|
"services": [
|
|
242
242
|
{
|
|
243
|
-
"serviceType": "@universis/janitor#
|
|
243
|
+
"serviceType": "@universis/janitor#EnableScopeAccessConfiguration"
|
|
244
244
|
}
|
|
245
245
|
]
|
|
246
246
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,213 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ApplicationService, ConfigurationStrategy, ConfigurationBase, ApplicationBase } from '@themost/common';
|
|
2
|
+
import RedisStore from 'rate-limit-redis';
|
|
3
|
+
import { Handler, Request as Request$1 } from 'express';
|
|
4
|
+
import { DataContext } from '@themost/data';
|
|
5
|
+
|
|
6
|
+
declare class RateLimitService extends ApplicationService {
|
|
7
|
+
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare class SpeedLimitService extends ApplicationService {
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare class RedisClientStore extends RedisStore {
|
|
15
|
+
constructor(app: ApplicationService);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @license
|
|
20
|
+
* Universis Project Version 1.0
|
|
21
|
+
* Copyright (c) 2018, Universis Project All rights reserved
|
|
22
|
+
*
|
|
23
|
+
* Use of this source code is governed by an LGPL 3.0 license that can be
|
|
24
|
+
* found in the LICENSE file at https://universis.io/license
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
declare class ScopeString {
|
|
29
|
+
constructor(str: string);
|
|
30
|
+
split(): string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare interface UniversisConfigurationSection {
|
|
34
|
+
universis: {
|
|
35
|
+
[k: string]: any;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare interface ScopeAccessConfigurationSection {
|
|
40
|
+
janitor: {
|
|
41
|
+
scopeAccess: {
|
|
42
|
+
imports: string[]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Declares a configuration element for managing scope-based permissions on server resources
|
|
49
|
+
*/
|
|
50
|
+
declare interface ScopeAccessConfigurationElement {
|
|
51
|
+
/**
|
|
52
|
+
* Gets or sets an array of strings that holds an array of scopes e.g. students or students:read or students,teachers etc
|
|
53
|
+
*/
|
|
54
|
+
scope: string[],
|
|
55
|
+
/**
|
|
56
|
+
* Gets or sets a string which represents the regular expression that is going to be used for validating endpoint
|
|
57
|
+
*/
|
|
58
|
+
resource: string;
|
|
59
|
+
/**
|
|
60
|
+
* Gets or sets an array of strings which represents the access levels for the given scopes e.g. READ or READ,WRITE etc
|
|
61
|
+
*/
|
|
62
|
+
access: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Gets or sets a string which represents a short description for this item
|
|
65
|
+
*/
|
|
66
|
+
description?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare class ScopeAccessConfiguration extends ConfigurationStrategy {
|
|
70
|
+
|
|
71
|
+
constructor(configuration: ConfigurationBase);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets an array of scope access configuration elements
|
|
75
|
+
*/
|
|
76
|
+
public elements: ScopeAccessConfigurationElement[];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Verifies the given request and returns a promise that resolves with a scope access configuration element
|
|
80
|
+
*/
|
|
81
|
+
verify(req: Request): Promise<ScopeAccessConfigurationElement>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare class DefaultScopeAccessConfiguration extends ScopeAccessConfiguration {
|
|
85
|
+
|
|
86
|
+
constructor(configuration: ConfigurationBase);
|
|
87
|
+
/**
|
|
88
|
+
* Gets an array of scope access configuration elements
|
|
89
|
+
*/
|
|
90
|
+
public elements: ScopeAccessConfigurationElement[];
|
|
91
|
+
/**
|
|
92
|
+
* Verifies the given request and returns a promise that resolves with a scope access configuration element
|
|
93
|
+
*/
|
|
94
|
+
verify(req: Request): Promise<ScopeAccessConfigurationElement>;
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare class EnableScopeAccessConfiguration extends ApplicationService {
|
|
99
|
+
constructor(app: ApplicationBase);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare class ExtendScopeAccessConfiguration extends ApplicationService {
|
|
103
|
+
constructor(app: ApplicationBase);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare function validateScope(): Handler;
|
|
107
|
+
|
|
108
|
+
declare interface OAuth2MethodOptions {
|
|
109
|
+
access_token: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare interface OAuth2AuthorizeUser {
|
|
113
|
+
client_id?: string;
|
|
114
|
+
client_secret?: string;
|
|
115
|
+
username: string;
|
|
116
|
+
password: string;
|
|
117
|
+
grant_type: string;
|
|
118
|
+
scope?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare interface OAuth2ServiceSettings {
|
|
122
|
+
unattendedExecutionAccount?: string;
|
|
123
|
+
client_id: string;
|
|
124
|
+
client_secret?: string;
|
|
125
|
+
server_uri: string;
|
|
126
|
+
userinfo_uri?: string;
|
|
127
|
+
introspect_uri?: string;
|
|
128
|
+
admin_uri?: string;
|
|
129
|
+
well_known_configuration_uri?: string;
|
|
130
|
+
adminAccount: {
|
|
131
|
+
username: string;
|
|
132
|
+
password: string;
|
|
133
|
+
client_id: string;
|
|
134
|
+
client_secret?: string;
|
|
135
|
+
scope?: string;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare interface OAuth2UserProfile {
|
|
140
|
+
sub: string;
|
|
141
|
+
name: string;
|
|
142
|
+
preferred_username: string;
|
|
143
|
+
given_name: string;
|
|
144
|
+
family_name: string;
|
|
145
|
+
email: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare interface GenericUser {
|
|
149
|
+
id?: any;
|
|
150
|
+
additionalType?: string;
|
|
151
|
+
alternateName?: string;
|
|
152
|
+
description?: string;
|
|
153
|
+
givenName?: string;
|
|
154
|
+
familyName?: string;
|
|
155
|
+
image?: string;
|
|
156
|
+
name?: string;
|
|
157
|
+
url?: string;
|
|
158
|
+
dateCreated?: Date;
|
|
159
|
+
dateModified?: Date;
|
|
160
|
+
createdBy?: any;
|
|
161
|
+
modifiedBy?: any;
|
|
162
|
+
lockoutTime?: Date;
|
|
163
|
+
logonCount?: number;
|
|
164
|
+
enabled?: boolean;
|
|
165
|
+
lastLogon?: Date;
|
|
166
|
+
userCredentials?: {
|
|
167
|
+
userPassword?: string;
|
|
168
|
+
userActivated?: boolean;
|
|
169
|
+
temporary?: boolean;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare interface OAuth2User {
|
|
174
|
+
id?: any;
|
|
175
|
+
username?: string;
|
|
176
|
+
email?: string;
|
|
177
|
+
enabled?: boolean;
|
|
178
|
+
emailVerified?: boolean;
|
|
179
|
+
firstName?: string;
|
|
180
|
+
lastName?: string;
|
|
181
|
+
credentials?: {
|
|
182
|
+
algorithm?: string,
|
|
183
|
+
temporary?: boolean,
|
|
184
|
+
type?: string,
|
|
185
|
+
value?: string
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class OAuth2ClientService extends ApplicationService {
|
|
190
|
+
get settings(): OAuth2ServiceSettings;
|
|
191
|
+
constructor(app: ApplicationBase)
|
|
192
|
+
getUserInfo(context: DataContext, token: string): Promise<OAuth2UserProfile>;
|
|
193
|
+
getTokenInfo(context: DataContext, token: string): Promise<any>;
|
|
194
|
+
getContextTokenInfo(context: DataContext): Promise<any>;
|
|
195
|
+
authorize(authorizeUser: OAuth2AuthorizeUser): Promise<{ access_token?: string, refresh_token?: string}>;
|
|
196
|
+
getUser(username: string, options: OAuth2MethodOptions): Promise<any>;
|
|
197
|
+
getUserById(user_id: any, options: OAuth2MethodOptions): Promise<any>;
|
|
198
|
+
getUserByEmail(email: string, options: OAuth2MethodOptions): Promise<any>;
|
|
199
|
+
updateUser(user: GenericUser | any, options: OAuth2MethodOptions): Promise<any>;
|
|
200
|
+
createUser(user: GenericUser | any, options: OAuth2MethodOptions): Promise<any>;
|
|
201
|
+
deleteUser(user: { id: any }, options: OAuth2MethodOptions): Promise<any>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare class RemoteAddressValidator extends ApplicationService {
|
|
205
|
+
|
|
206
|
+
constructor(app: ApplicationService);
|
|
207
|
+
validateRemoteAddress(request: Request$1): Promise<boolean>;
|
|
208
|
+
getRemoteAddress(request: Request$1): string;
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { DefaultScopeAccessConfiguration, EnableScopeAccessConfiguration, ExtendScopeAccessConfiguration, OAuth2ClientService, RateLimitService, RedisClientStore, RemoteAddressValidator, ScopeAccessConfiguration, ScopeString, SpeedLimitService, validateScope };
|
|
213
|
+
export type { GenericUser, OAuth2AuthorizeUser, OAuth2MethodOptions, OAuth2ServiceSettings, OAuth2User, OAuth2UserProfile, ScopeAccessConfigurationElement, ScopeAccessConfigurationSection, UniversisConfigurationSection };
|