@semapps/auth 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- package/mixins/auth.js +8 -4
- package/mixins/auth.sso.js +4 -3
- package/package.json +6 -6
- package/services/auth.local.js +11 -9
package/mixins/auth.js
CHANGED
@@ -23,17 +23,19 @@ const AuthMixin = {
|
|
23
23
|
async created() {
|
24
24
|
const { jwtPath, reservedUsernames, accountsDataset, podProvider } = this.settings;
|
25
25
|
|
26
|
-
this.broker.createService(
|
26
|
+
this.broker.createService({
|
27
|
+
mixins: [AuthJWTService],
|
27
28
|
settings: { jwtPath }
|
28
29
|
});
|
29
30
|
|
30
|
-
this.broker.createService(
|
31
|
+
this.broker.createService({
|
32
|
+
mixins: [AuthAccountService],
|
31
33
|
settings: { reservedUsernames },
|
32
34
|
adapter: new TripleStoreAdapter({ type: 'AuthAccount', dataset: accountsDataset })
|
33
35
|
});
|
34
36
|
|
35
37
|
if (podProvider) {
|
36
|
-
this.broker.createService(CapabilitiesService,
|
38
|
+
this.broker.createService({ mixins: [CapabilitiesService], settings: { path: this.settings.capabilitiesPath } });
|
37
39
|
}
|
38
40
|
},
|
39
41
|
async started() {
|
@@ -51,7 +53,9 @@ const AuthMixin = {
|
|
51
53
|
|
52
54
|
this.passport.use(this.passportId, this.strategy);
|
53
55
|
|
54
|
-
|
56
|
+
const { pathname: basePath } = new URL(this.settings.baseUrl);
|
57
|
+
|
58
|
+
for (const route of this.getApiRoutes(basePath)) {
|
55
59
|
await this.broker.call('api.addRoute', { route });
|
56
60
|
}
|
57
61
|
},
|
package/mixins/auth.sso.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
const path = require('path');
|
1
2
|
const session = require('express-session');
|
2
3
|
const AuthMixin = require('./auth');
|
3
4
|
const saveRedirectUrl = require('../middlewares/saveRedirectUrl');
|
@@ -65,11 +66,11 @@ const AuthSSOMixin = {
|
|
65
66
|
}
|
66
67
|
},
|
67
68
|
methods: {
|
68
|
-
getApiRoutes() {
|
69
|
+
getApiRoutes(basePath) {
|
69
70
|
const sessionMiddleware = session({ secret: this.settings.sessionSecret, maxAge: null });
|
70
71
|
return [
|
71
72
|
{
|
72
|
-
path: '/auth',
|
73
|
+
path: path.join(basePath, '/auth'),
|
73
74
|
name: 'auth',
|
74
75
|
use: [sessionMiddleware, this.passport.initialize(), this.passport.session()],
|
75
76
|
aliases: {
|
@@ -77,7 +78,7 @@ const AuthSSOMixin = {
|
|
77
78
|
}
|
78
79
|
},
|
79
80
|
{
|
80
|
-
path: '/auth/logout',
|
81
|
+
path: path.join(basePath, '/auth/logout'),
|
81
82
|
name: 'auth-logout',
|
82
83
|
use: [sessionMiddleware, this.passport.initialize(), this.passport.session()],
|
83
84
|
aliases: {
|
package/package.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@semapps/auth",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.1",
|
4
4
|
"description": "Authentification module for SemApps",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "Virtual Assembly",
|
7
7
|
"dependencies": {
|
8
|
-
"@semapps/ldp": "0.8.
|
9
|
-
"@semapps/middlewares": "0.8.
|
10
|
-
"@semapps/mime-types": "0.8.
|
11
|
-
"@semapps/triplestore": "0.8.
|
8
|
+
"@semapps/ldp": "0.8.1",
|
9
|
+
"@semapps/middlewares": "0.8.1",
|
10
|
+
"@semapps/mime-types": "0.8.1",
|
11
|
+
"@semapps/triplestore": "0.8.1",
|
12
12
|
"bcrypt": "^5.0.1",
|
13
13
|
"express-session": "^1.17.0",
|
14
14
|
"jsonwebtoken": "^8.5.1",
|
@@ -29,5 +29,5 @@
|
|
29
29
|
"engines": {
|
30
30
|
"node": ">=14"
|
31
31
|
},
|
32
|
-
"gitHead": "
|
32
|
+
"gitHead": "c056166a50822060e229c20efd2eb6ee666fc743"
|
33
33
|
}
|
package/services/auth.local.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
const path = require('path');
|
1
2
|
const { Strategy } = require('passport-local');
|
2
3
|
const AuthMixin = require('../mixins/auth');
|
3
4
|
const sendToken = require('../middlewares/sendToken');
|
@@ -35,7 +36,8 @@ const AuthLocalService = {
|
|
35
36
|
this.passportId = 'local';
|
36
37
|
|
37
38
|
if (mail !== false) {
|
38
|
-
|
39
|
+
this.broker.createService({
|
40
|
+
mixins: [AuthMailService],
|
39
41
|
settings: {
|
40
42
|
...mail
|
41
43
|
}
|
@@ -152,9 +154,9 @@ const AuthLocalService = {
|
|
152
154
|
}
|
153
155
|
);
|
154
156
|
},
|
155
|
-
getApiRoutes() {
|
157
|
+
getApiRoutes(basePath) {
|
156
158
|
const loginRoute = {
|
157
|
-
path: '/auth/login',
|
159
|
+
path: path.join(basePath, '/auth/login'),
|
158
160
|
name: 'auth-login',
|
159
161
|
use: [this.passport.initialize()],
|
160
162
|
aliases: {
|
@@ -163,7 +165,7 @@ const AuthLocalService = {
|
|
163
165
|
};
|
164
166
|
|
165
167
|
const logoutRoute = {
|
166
|
-
path: '/auth/logout',
|
168
|
+
path: path.join(basePath, '/auth/logout'),
|
167
169
|
name: 'auth-logout',
|
168
170
|
aliases: {
|
169
171
|
'GET /': 'auth.logout'
|
@@ -171,7 +173,7 @@ const AuthLocalService = {
|
|
171
173
|
};
|
172
174
|
|
173
175
|
const signupRoute = {
|
174
|
-
path: '/auth/signup',
|
176
|
+
path: path.join(basePath, '/auth/signup'),
|
175
177
|
name: 'auth-signup',
|
176
178
|
aliases: {
|
177
179
|
'POST /': 'auth.signup'
|
@@ -179,7 +181,7 @@ const AuthLocalService = {
|
|
179
181
|
};
|
180
182
|
|
181
183
|
const formRoute = {
|
182
|
-
path: '/auth',
|
184
|
+
path: path.join(basePath, '/auth'),
|
183
185
|
name: 'auth',
|
184
186
|
aliases: {
|
185
187
|
'GET /': 'auth.redirectToForm'
|
@@ -187,14 +189,14 @@ const AuthLocalService = {
|
|
187
189
|
};
|
188
190
|
|
189
191
|
const resetPasswordRoute = {
|
190
|
-
path: '/auth/reset_password',
|
192
|
+
path: path.join(basePath, '/auth/reset_password'),
|
191
193
|
name: 'auth-reset-password',
|
192
194
|
aliases: {
|
193
195
|
'POST /': 'auth.resetPassword'
|
194
196
|
}
|
195
197
|
};
|
196
198
|
const setNewPasswordRoute = {
|
197
|
-
path: '/auth/new_password',
|
199
|
+
path: path.join(basePath, '/auth/new_password'),
|
198
200
|
name: 'auth-new-password',
|
199
201
|
aliases: {
|
200
202
|
'POST /': 'auth.setNewPassword'
|
@@ -202,7 +204,7 @@ const AuthLocalService = {
|
|
202
204
|
};
|
203
205
|
|
204
206
|
const accountSettingsRoute = {
|
205
|
-
path: '/auth/account',
|
207
|
+
path: path.join(basePath, '/auth/account'),
|
206
208
|
name: 'auth-account',
|
207
209
|
aliases: {
|
208
210
|
'GET /': 'auth.account.findSettingsByWebId',
|