@hitchy/plugin-auth 0.4.3 → 0.4.5
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.
|
@@ -103,8 +103,8 @@ module.exports = function() {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* Generates local strategy authenticating user based on
|
|
107
|
-
*
|
|
106
|
+
* Generates local strategy authenticating user based on user model
|
|
107
|
+
* managed in local document-oriented database.
|
|
108
108
|
*
|
|
109
109
|
* @returns {Strategy} generated strategy for use with passport.js
|
|
110
110
|
*/
|
|
@@ -24,11 +24,7 @@ module.exports = function() {
|
|
|
24
24
|
throw new Error( "missing resources to test" );
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const userInfo = await service.AuthManager.asUser( user );
|
|
27
|
+
const userInfo = user ? await service.AuthManager.asUser( user ).catch( () => undefined ) : undefined;
|
|
32
28
|
|
|
33
29
|
const resources = Array.isArray( resource ) ? resource : [resource];
|
|
34
30
|
|
|
@@ -41,7 +37,7 @@ module.exports = function() {
|
|
|
41
37
|
const { current: tree } = service.AuthorizationTree;
|
|
42
38
|
|
|
43
39
|
for ( const current of resources ) {
|
|
44
|
-
const isAuthorized = tree.isAuthorized( current, userInfo, roleNames.length > 0 ? roleNames : undefined );
|
|
40
|
+
const isAuthorized = tree.isAuthorized( current, userInfo?.name, roleNames.length > 0 ? roleNames : undefined );
|
|
45
41
|
|
|
46
42
|
if ( Boolean( isAuthorized ) !== Boolean( checkAll ) ) {
|
|
47
43
|
// either: may access current one + does not require access on all => return true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitchy/plugin-auth",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "user authentication and authorization for Hitchy",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"homepage": "https://auth.hitchy.org",
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@hitchy/core": "0.8.x",
|
|
26
|
-
"@hitchy/plugin-odem": "0.
|
|
26
|
+
"@hitchy/plugin-odem": "0.9.x",
|
|
27
27
|
"@hitchy/plugin-cookies": "0.1.x",
|
|
28
28
|
"@hitchy/plugin-session": "0.4.x"
|
|
29
29
|
},
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"c8": "^10.1.2",
|
|
34
34
|
"eslint": "^8.57.0",
|
|
35
35
|
"eslint-config-cepharum": "^1.0.14",
|
|
36
|
-
"eslint-plugin-promise": "^6.
|
|
37
|
-
"mocha": "^10.
|
|
36
|
+
"eslint-plugin-promise": "^6.6.0",
|
|
37
|
+
"mocha": "^10.7.3",
|
|
38
38
|
"openid-client": "^5.6.5",
|
|
39
39
|
"passport-saml": "^3.2.4",
|
|
40
40
|
"should": "^13.2.3",
|
|
41
41
|
"should-http": "^0.1.1",
|
|
42
|
-
"vitepress": "^1.3.
|
|
42
|
+
"vitepress": "^1.3.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"passport": "^0.7.0",
|