@mimik/oauth-helper 1.4.5 → 1.9.6

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.
@@ -0,0 +1,314 @@
1
+ const NO_GENERIC = 'noGeneric';
2
+ const APPLICATION = 'application';
3
+ const IMPLICIT = 'implicit';
4
+ const SUB_ADMIN = 'subAdmin';
5
+ const ADMIN = 'admin';
6
+ const CLIENT = '@clients';
7
+ const API_KEY = 'api_key';
8
+ const HEADER = 'header';
9
+
10
+ const config = {
11
+ implImplicit: {
12
+ security: {
13
+ implicit: {
14
+ audience: 'http://implAudience',
15
+ issuer: 'http://localhost:9070/implIssuer/oauth/token',
16
+ key: 'implKey',
17
+ },
18
+ },
19
+ dependencies: {
20
+ mID: {
21
+ url: 'http://localhost:9070/mIDUrl',
22
+ },
23
+ },
24
+ },
25
+ implNoGeneric: {
26
+ security: {
27
+ server: {
28
+ audience: 'http://implServerAudience',
29
+ issuer: 'http://localhost:9070/implServerIssuer/oauth/token',
30
+ accessKey: 'implicitAccessKey',
31
+ },
32
+ generic: {
33
+ key: NO_GENERIC,
34
+ audience: NO_GENERIC,
35
+ },
36
+ },
37
+ dependencies: {
38
+ mID: {
39
+ url: 'http://localhost:9070/mIDUrl',
40
+ },
41
+ },
42
+ },
43
+ implGeneric: {
44
+ security: {
45
+ server: {
46
+ audience: 'http://implServerAudience',
47
+ issuer: 'http://localhost:9070/implServerIssuer/oauth/token',
48
+ accessKey: 'implAccessKey',
49
+ },
50
+ generic: {
51
+ audience: 'http://implGenericAudience',
52
+ key: 'implGenericKey',
53
+ },
54
+ },
55
+ dependencies: {
56
+ mID: {
57
+ url: 'http://localhost:9070/mIDUrl',
58
+ },
59
+ },
60
+ },
61
+ appNoGeneric: {
62
+ server: {
63
+ id: 'appServerId',
64
+ },
65
+ security: {
66
+ server: {
67
+ audience: 'http://appServerAudience.com',
68
+ issuer: 'http://localhost:9070/appNoGenericServerIssuer/oauth/token',
69
+ id: 'appServerId',
70
+ secret: 'appServerSecret',
71
+ accessKey: 'appnAccessKey',
72
+ },
73
+ generic: {
74
+ audience: NO_GENERIC,
75
+ key: NO_GENERIC,
76
+ },
77
+ admin: {
78
+ externalId: 'appAdminExternalId',
79
+ },
80
+ },
81
+ dependencies: {
82
+ test1: {
83
+ audience: 'http://appTest1DependenciesAudience.com',
84
+ },
85
+ test2: {
86
+ audience: 'http://appTest2DependenciesAudience.com',
87
+ },
88
+ mID: {
89
+ url: 'http://localhost:9070/mIDUrl',
90
+ },
91
+ },
92
+ },
93
+ appGeneric: {
94
+ server: {
95
+ id: 'appServerId',
96
+ },
97
+ security: {
98
+ server: {
99
+ audience: 'http://appServerAudience',
100
+ issuer: 'http://localhost:9070/appGenericServerIssuer/oauth/token',
101
+ id: 'appServerId',
102
+ secret: 'applServerSecret',
103
+ },
104
+ generic: {
105
+ audience: 'http://appGenericAudience',
106
+ key: 'appGenericKey',
107
+ },
108
+ admin: {
109
+ externalId: 'appAdminExternalId',
110
+ },
111
+ apiKeys: ['12345', '54321'],
112
+ },
113
+ dependencies: {
114
+ test1: {
115
+ audience: 'http://appTest1DependenciesAudience',
116
+ },
117
+ test2: {
118
+ audience: 'http://appTest2DependenciesAudience.com',
119
+ },
120
+ mID: {
121
+ url: 'http://localhost:9070/mIDUrl',
122
+ },
123
+ },
124
+ },
125
+ appUnknownIssuer: {
126
+ server: {
127
+ id: 'appServerId',
128
+ },
129
+ security: {
130
+ server: {
131
+ issuer: 'http://localhost:9070/unknown/oauth/token',
132
+ id: 'appServerId',
133
+ secret: 'appServerSecret',
134
+ },
135
+ generic: {
136
+ audience: 'http://appGenericAudience',
137
+ key: 'appGenericKey',
138
+ },
139
+ admin: {
140
+ externalId: 'appAdminExternalId',
141
+ },
142
+ },
143
+ dependencies: {
144
+ test1: {
145
+ audience: 'http://appTest1DependenciesAudience',
146
+ },
147
+ test2: {
148
+ audience: 'http://appTest2DependenciesAudience.com',
149
+ },
150
+ mID: {
151
+ url: 'http://localhost:9070/mIDUrl',
152
+ },
153
+ },
154
+ },
155
+ appExpiredToken: {
156
+ server: {
157
+ id: 'appServerId',
158
+ },
159
+ security: {
160
+ server: {
161
+ issuer: 'http://localhost:9070/appGenericServerIssuer/oauth/expiredToken',
162
+ id: 'appServerId',
163
+ secret: 'appServerSecret',
164
+ },
165
+ generic: {
166
+ audience: 'http://appGenericAudience',
167
+ key: 'appGenericKey',
168
+ },
169
+ admin: {
170
+ externalId: 'appAdminExternalId',
171
+ },
172
+ },
173
+ dependencies: {
174
+ test1: {
175
+ audience: 'http://appTest1DependenciesAudience',
176
+ },
177
+ test2: {
178
+ audience: 'http://appTest2DependenciesAudience.com',
179
+ },
180
+ mID: {
181
+ url: 'http://localhost:9070/mIDUrl',
182
+ },
183
+ },
184
+ },
185
+ appExpiredTokenAndFail: {
186
+ server: {
187
+ id: 'appServerId',
188
+ },
189
+ security: {
190
+ server: {
191
+ issuer: 'http://localhost:9070/appGenericServerIssuer/oauth/expiredTokenAndFail',
192
+ id: 'appServerId',
193
+ secret: 'appServerSecret',
194
+ },
195
+ generic: {
196
+ audience: 'http://appGenericAudience',
197
+ key: 'appGenericKey',
198
+ },
199
+ admin: {
200
+ externalId: 'appAdminExternalId',
201
+ },
202
+ },
203
+ dependencies: {
204
+ test1: {
205
+ audience: 'http://appTest1DependenciesAudience',
206
+ },
207
+ test2: {
208
+ audience: 'http://appTest2DependenciesAudience.com',
209
+ },
210
+ mID: {
211
+ url: 'http://localhost:9070/mIDUrl',
212
+ },
213
+ },
214
+ },
215
+ };
216
+ const scope = {
217
+ regular: 'test:1 test:2 test:3',
218
+ onBehalf: 'test:1 onBehalf:1',
219
+ scopes: ['test:1', 'test:2', 'test:3'],
220
+ otherScopes: ['test:4', 'test:5'],
221
+ onBehalfScopes: ['onBehalf:1', 'test:6'],
222
+ };
223
+ const cust = 'testCustomer';
224
+ const subType = 'testType';
225
+ const azp = 'applicationId';
226
+ const definition = {
227
+ implicit: {
228
+ flow: IMPLICIT,
229
+ },
230
+ application: {
231
+ flow: APPLICATION,
232
+ },
233
+ apiKey: {
234
+ name: API_KEY,
235
+ in: HEADER,
236
+ },
237
+ };
238
+ const payload = {
239
+ regular: {
240
+ scope: scope.regular,
241
+ subType,
242
+ azp,
243
+ cust,
244
+ },
245
+ noScope: {
246
+ subType,
247
+ cust,
248
+ },
249
+ onBehalf: {
250
+ scope: scope.onBehalf,
251
+ subType,
252
+ cust,
253
+ },
254
+ exchange: {
255
+ scope: scope.regular,
256
+ subType,
257
+ cust,
258
+ may_act: {
259
+ sub: 'managerId',
260
+ },
261
+ },
262
+ admin: {
263
+ scope: scope.regular,
264
+ subType: ADMIN,
265
+ cust,
266
+ },
267
+ adminNoScope: {
268
+ subType: ADMIN,
269
+ cust,
270
+ },
271
+ subAdmin: {
272
+ scope: scope.regular,
273
+ subType: SUB_ADMIN,
274
+ cust,
275
+ },
276
+ subAdminNoCustomer: {
277
+ scope: scope.regular,
278
+ subType: SUB_ADMIN,
279
+ },
280
+ };
281
+ const options = {
282
+ implImplicit: {
283
+ expiresIn: Date.now() + 100000,
284
+ audience: config.implImplicit.security.implicit.audience,
285
+ issuer: config.implImplicit.security.implicit.issuer,
286
+ subject: 'userId',
287
+ },
288
+ appGeneric: {
289
+ expiresIn: Date.now() + 100000,
290
+ audience: config.appGeneric.security.generic.audience,
291
+ issuer: config.appGeneric.security.server.issuer,
292
+ subject: `${config.appGeneric.server.id}${CLIENT}`,
293
+ },
294
+ adminApp: {
295
+ expiresIn: Date.now() + 100000,
296
+ audience: config.appGeneric.security.generic.audience,
297
+ issuer: config.appGeneric.security.server.issuer,
298
+ subject: `${config.appGeneric.security.admin.externalId}${CLIENT}`,
299
+ },
300
+ adminAppWrongId: {
301
+ expiresIn: Date.now() + 100000,
302
+ audience: config.appGeneric.security.generic.audience,
303
+ issuer: config.appGeneric.security.server.issuer,
304
+ subject: `wrongId${CLIENT}`,
305
+ },
306
+ };
307
+
308
+ module.exports = {
309
+ config,
310
+ payload,
311
+ options,
312
+ definition,
313
+ scope,
314
+ };
@@ -0,0 +1,19 @@
1
+ /* eslint no-process-env: "off" */
2
+
3
+ /**
4
+ * The following environment variables are set for the test:
5
+ *
6
+ * | Env variable name | Description | Default | Comments |
7
+ * | ----------------- | ----------- | ------- | -------- |
8
+ * | SUMO_LOGIC_ENDPOINT | endpoint to use to log on sumologic | null
9
+ * | SUMO_LOGIC_COLLECTOR_CODE | code to use to log on sumologic | null
10
+ * | NO_STACK | flag to have a stack associated with the log | yes
11
+ * | LOG_LEVEL | log level to log | error
12
+ * | CONSOLE_LEVEL | log level to diplay | debug
13
+ */
14
+
15
+ process.env.SUMO_LOGIC_ENDPOINT = null;
16
+ process.env.SUMO_LOGIC_COLLECTOR_CODE = null;
17
+ process.env.NO_STACK = 'yes';
18
+ process.env.LOG_LEVEL = 'error';
19
+ // process.env.CONSOLE_LEVEL = 'debug';