@semapps/auth 0.4.0-alpha.32 → 0.4.0-alpha.35
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/mixins/auth.js +1 -1
- package/package.json +5 -4
- package/services/account.js +6 -6
- package/services/auth.oidc.js +8 -4
package/mixins/auth.js
CHANGED
package/package.json
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "@semapps/auth",
|
3
|
-
"version": "0.4.0-alpha.
|
3
|
+
"version": "0.4.0-alpha.35",
|
4
4
|
"description": "Authentification module for SemApps",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "Virtual Assembly",
|
7
7
|
"dependencies": {
|
8
|
-
"@semapps/mime-types": "0.4.0-alpha.
|
9
|
-
"@semapps/triplestore": "0.4.0-alpha.
|
8
|
+
"@semapps/mime-types": "0.4.0-alpha.35",
|
9
|
+
"@semapps/triplestore": "0.4.0-alpha.35",
|
10
10
|
"bcrypt": "^5.0.1",
|
11
11
|
"express-session": "^1.17.0",
|
12
12
|
"jsonwebtoken": "^8.5.1",
|
13
13
|
"moleculer": "^0.14.17",
|
14
14
|
"moleculer-db": "^0.8.16",
|
15
|
+
"moleculer-mail": "^1.2.5",
|
15
16
|
"moleculer-web": "^0.10.0-beta1",
|
16
17
|
"node-sass": "^7.0.1",
|
17
18
|
"openid-client": "^4.7.4",
|
@@ -24,5 +25,5 @@
|
|
24
25
|
"publishConfig": {
|
25
26
|
"access": "public"
|
26
27
|
},
|
27
|
-
"gitHead": "
|
28
|
+
"gitHead": "495acfcae77f77273e2ef4dc1cc1192fb82e3cd0"
|
28
29
|
}
|
package/services/account.js
CHANGED
@@ -9,7 +9,7 @@ module.exports = {
|
|
9
9
|
adapter: new TripleStoreAdapter({ type: 'AuthAccount', dataset: 'settings' }),
|
10
10
|
settings: {
|
11
11
|
idField: '@id',
|
12
|
-
reservedUsernames: []
|
12
|
+
reservedUsernames: ['relay']
|
13
13
|
},
|
14
14
|
dependencies: ['triplestore'],
|
15
15
|
actions: {
|
@@ -19,14 +19,14 @@ module.exports = {
|
|
19
19
|
|
20
20
|
email = email && email.toLowerCase();
|
21
21
|
|
22
|
-
const emailExists = await ctx.call('auth.account.emailExists', { email });
|
22
|
+
const emailExists = !email ? false : await ctx.call('auth.account.emailExists', { email });
|
23
23
|
if (emailExists) {
|
24
24
|
throw new Error('email.already.exists');
|
25
25
|
}
|
26
26
|
|
27
27
|
if (username) {
|
28
|
-
await this.isValidUsername(ctx, username);
|
29
|
-
} else {
|
28
|
+
if (!ctx.meta.isSystemCall) await this.isValidUsername(ctx, username);
|
29
|
+
} else if (email) {
|
30
30
|
// If username is not provided, find an username based on the email
|
31
31
|
const usernameFromEmail = email.split('@')[0].toLowerCase();
|
32
32
|
let usernameValid = false,
|
@@ -40,7 +40,7 @@ module.exports = {
|
|
40
40
|
}
|
41
41
|
i++;
|
42
42
|
} while (!usernameValid);
|
43
|
-
}
|
43
|
+
} else throw new Error('you must provide at least a username or an email address');
|
44
44
|
|
45
45
|
return await this._create(ctx, {
|
46
46
|
...rest,
|
@@ -187,7 +187,7 @@ module.exports = {
|
|
187
187
|
throw new Error('username.already.exists');
|
188
188
|
}
|
189
189
|
|
190
|
-
// Ensure
|
190
|
+
// Ensure username doesn't already exist
|
191
191
|
const usernameExists = await ctx.call('auth.account.usernameExists', { username });
|
192
192
|
if (usernameExists) {
|
193
193
|
throw new Error('username.already.exists');
|
package/services/auth.oidc.js
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
const urlJoin = require('url-join');
|
2
|
-
const { Issuer, Strategy } = require('openid-client');
|
2
|
+
const { Issuer, Strategy, custom } = require('openid-client');
|
3
|
+
custom.setHttpOptionsDefaults({
|
4
|
+
timeout: 10000
|
5
|
+
});
|
3
6
|
const AuthSSOMixin = require('../mixins/auth.sso');
|
4
7
|
|
5
8
|
const AuthOIDCService = {
|
@@ -21,11 +24,12 @@ const AuthOIDCService = {
|
|
21
24
|
},
|
22
25
|
async created() {
|
23
26
|
this.passportId = 'oidc';
|
24
|
-
this.issuer = await Issuer.discover(this.settings.issuer);
|
25
27
|
},
|
26
28
|
methods: {
|
27
|
-
getStrategy() {
|
28
|
-
const
|
29
|
+
async getStrategy() {
|
30
|
+
const issuer = await Issuer.discover(this.settings.issuer);
|
31
|
+
|
32
|
+
const client = new issuer.Client({
|
29
33
|
client_id: this.settings.clientId,
|
30
34
|
client_secret: this.settings.clientSecret,
|
31
35
|
redirect_uri: urlJoin(this.settings.baseUrl, 'auth'),
|