@hitchy/plugin-auth 0.3.0 → 0.3.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.
Files changed (35) hide show
  1. package/api/policy/authentication.js +81 -27
  2. package/api/service/auth/manager.js +36 -4
  3. package/api/service/authentication/passport.js +6 -5
  4. package/api/service/authentication/strategies.js +57 -34
  5. package/api/service/authorization/tree.js +8 -8
  6. package/coverage/index.html +45 -45
  7. package/coverage/plugin-auth/api/controller/index.html +1 -1
  8. package/coverage/plugin-auth/api/controller/user.js.html +53 -53
  9. package/coverage/plugin-auth/api/model/authorization/index.html +1 -1
  10. package/coverage/plugin-auth/api/model/authorization/rule.js.html +31 -31
  11. package/coverage/plugin-auth/api/model/index.html +1 -1
  12. package/coverage/plugin-auth/api/model/role.js.html +29 -29
  13. package/coverage/plugin-auth/api/model/user-to-role.js.html +21 -21
  14. package/coverage/plugin-auth/api/model/user.js.html +192 -192
  15. package/coverage/plugin-auth/api/policy/authentication.js.html +281 -119
  16. package/coverage/plugin-auth/api/policy/authorization.js.html +25 -25
  17. package/coverage/plugin-auth/api/policy/index.html +18 -18
  18. package/coverage/plugin-auth/api/policy/user.js.html +37 -37
  19. package/coverage/plugin-auth/api/service/auth/index.html +16 -16
  20. package/coverage/plugin-auth/api/service/auth/manager.js.html +293 -197
  21. package/coverage/plugin-auth/api/service/authentication/index.html +25 -25
  22. package/coverage/plugin-auth/api/service/authentication/passport.js.html +55 -52
  23. package/coverage/plugin-auth/api/service/authentication/strategies.js.html +204 -135
  24. package/coverage/plugin-auth/api/service/authorization/index.html +1 -1
  25. package/coverage/plugin-auth/api/service/authorization/node.js.html +136 -136
  26. package/coverage/plugin-auth/api/service/authorization/policy-generator.js.html +29 -29
  27. package/coverage/plugin-auth/api/service/authorization/tree.js.html +140 -140
  28. package/coverage/plugin-auth/config/auth.js.html +17 -17
  29. package/coverage/plugin-auth/config/index.html +1 -1
  30. package/coverage/plugin-auth/index.html +15 -15
  31. package/coverage/plugin-auth/index.js.html +94 -55
  32. package/coverage/tmp/coverage-16252-1648499208727-0.json +1 -0
  33. package/index.js +17 -4
  34. package/package.json +2 -2
  35. package/coverage/tmp/coverage-6744-1648396809135-0.json +0 -1
package/index.js CHANGED
@@ -3,6 +3,8 @@
3
3
  module.exports = function( options, plugins ) {
4
4
  const api = this;
5
5
 
6
+ const logWarning = api.log( "hitchy:session:warning" );
7
+
6
8
  const pluginApi = {
7
9
  configure() {
8
10
  const { strategies } = api.config.auth;
@@ -46,11 +48,22 @@ module.exports = function( options, plugins ) {
46
48
  },
47
49
 
48
50
  policies() {
49
- const { config: { auth: { prefix } } } = this;
51
+ const { config: { session, auth: { prefix } } } = this;
50
52
 
51
- const policies = {
52
- "/": "authentication.initialize",
53
- };
53
+ const policies = {};
54
+
55
+ if ( session.disable ) {
56
+ logWarning( "server-side sessions are disabled, thus passport isn't integrated for commonly handling all requests automatically" );
57
+
58
+ policies["/"] = [
59
+ "authentication.handleBasicAuth",
60
+ ];
61
+ } else {
62
+ policies["/"] = [
63
+ "authentication.injectPassport",
64
+ "authentication.handleBasicAuth",
65
+ ];
66
+ }
54
67
 
55
68
  return prefix === false ? policies : {
56
69
  ...policies,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitchy/plugin-auth",
3
- "version": "0.3.0",
3
+ "version": "0.3.3",
4
4
  "description": "user authentication and authorization for Hitchy",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@hitchy/plugin-cookies": "^0.1.6",
43
43
  "@hitchy/plugin-odem": "^0.5.10",
44
- "@hitchy/plugin-session": "^0.1.8",
44
+ "@hitchy/plugin-session": "^0.1.10",
45
45
  "passport": "^0.5.2",
46
46
  "passport-local": "^1.0.0"
47
47
  }