@hitchy/plugin-auth 0.6.1 → 0.6.3
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.
|
@@ -47,6 +47,24 @@ export default function() { // eslint-disable-line jsdoc/require-jsdoc
|
|
|
47
47
|
} );
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Destroys session of current request if its associated user has not
|
|
52
|
+
* been found.
|
|
53
|
+
*
|
|
54
|
+
* @param {Error} error description of error encountered on dispatching request
|
|
55
|
+
* @param {Hitchy.Core.IncomingMessage} req request descriptor
|
|
56
|
+
* @param {Hitchy.Core.ServerResponse} res response manager
|
|
57
|
+
* @param {Hitchy.Core.ContinuationHandler} next callback to be invoked once the handler is done
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
static async dropSessionOfUnknownUser( error, req, res, next ) {
|
|
61
|
+
if ( req.session && error instanceof service.NoSuchUserError ) {
|
|
62
|
+
await req.session.$destroy( res );
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
next( error );
|
|
66
|
+
}
|
|
67
|
+
|
|
50
68
|
/**
|
|
51
69
|
* Discovers HTTP basic authentication header and processes it
|
|
52
70
|
* accordingly based local user database.
|
|
@@ -30,12 +30,10 @@ export default function() { // eslint-disable-line jsdoc/require-jsdoc
|
|
|
30
30
|
const user = new User( uuid );
|
|
31
31
|
|
|
32
32
|
user.$exists
|
|
33
|
-
.then(
|
|
33
|
+
.then( exists => {
|
|
34
34
|
if ( exists ) return user.load();
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw new Error( "missing user with selected UUID" );
|
|
36
|
+
throw new api.service.NoSuchUserError( "missing user with selected UUID" );
|
|
39
37
|
} )
|
|
40
38
|
.then( () => AuthManager.listRolesOfUser( user ) )
|
|
41
39
|
.then( roles => {
|
package/index.js
CHANGED
|
@@ -63,6 +63,10 @@ export default function( options, plugins ) { // eslint-disable-line jsdoc/requi
|
|
|
63
63
|
"authentication.injectPassport",
|
|
64
64
|
"authentication.handleBasicAuth",
|
|
65
65
|
];
|
|
66
|
+
|
|
67
|
+
policies["@error /"] = [
|
|
68
|
+
"authentication.dropSessionOfUnknownUser",
|
|
69
|
+
];
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
return prefix === false ? policies : {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitchy/plugin-auth",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "user authentication and authorization for Hitchy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -26,25 +26,25 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://auth.hitchy.org",
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@hitchy/core": "1.
|
|
30
|
-
"@hitchy/plugin-cookies": "0.1.
|
|
31
|
-
"@hitchy/plugin-odem": "0.
|
|
32
|
-
"@hitchy/plugin-session": "1.
|
|
29
|
+
"@hitchy/core": "^1.5.5",
|
|
30
|
+
"@hitchy/plugin-cookies": "^0.1.9",
|
|
31
|
+
"@hitchy/plugin-odem": "^0.14.0",
|
|
32
|
+
"@hitchy/plugin-session": "^1.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@hitchy/core": "^1.
|
|
36
|
-
"@hitchy/server-dev-tools": "^0.9.
|
|
35
|
+
"@hitchy/core": "^1.5.5",
|
|
36
|
+
"@hitchy/server-dev-tools": "^0.9.5",
|
|
37
37
|
"@hitchy/types": "^0.1.3",
|
|
38
38
|
"c8": "^10.1.3",
|
|
39
|
-
"eslint": "^9.
|
|
39
|
+
"eslint": "^9.39.2",
|
|
40
40
|
"eslint-config-cepharum": "^2.0.2",
|
|
41
|
-
"mermaid": "^11.
|
|
42
|
-
"mocha": "^11.7.
|
|
41
|
+
"mermaid": "^11.12.2",
|
|
42
|
+
"mocha": "^11.7.5",
|
|
43
43
|
"openid-client": "^5.7.1",
|
|
44
44
|
"passport-saml": "^3.2.4",
|
|
45
45
|
"should": "^13.2.3",
|
|
46
46
|
"should-http": "^0.1.1",
|
|
47
|
-
"vitepress": "^1.6.
|
|
47
|
+
"vitepress": "^1.6.4",
|
|
48
48
|
"vitepress-plugin-mermaid": "^2.0.17"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|