@spinajs/rbac-http 1.2.145 → 1.2.152
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/lib/{rbac-http/src/augumentation.d.ts → augumentation.d.ts} +0 -0
- package/lib/{rbac-http/src/augumentation.js → augumentation.js} +0 -0
- package/lib/augumentation.js.map +1 -0
- package/lib/config/rbac-http.js +1 -3
- package/lib/config/rbac-http.js.map +1 -1
- package/lib/dto/login-dto.d.ts +1 -0
- package/lib/dto/login-dto.js +8 -1
- package/lib/dto/login-dto.js.map +1 -1
- package/lib/dto/password-dto.d.ts +1 -0
- package/lib/dto/password-dto.js +8 -1
- package/lib/dto/password-dto.js.map +1 -1
- package/lib/dto/user-dto.d.ts +2 -1
- package/lib/dto/user-dto.js +8 -1
- package/lib/dto/user-dto.js.map +1 -1
- package/lib/middlewares.d.ts +9 -4
- package/lib/middlewares.js +55 -35
- package/lib/middlewares.js.map +1 -1
- package/lib/policies.d.ts +3 -4
- package/lib/policies.js +4 -4
- package/lib/policies.js.map +1 -1
- package/package.json +3 -3
- package/lib/http/src/interfaces.d.ts +0 -443
- package/lib/http/src/interfaces.js +0 -222
- package/lib/http/src/interfaces.js.map +0 -1
- package/lib/rbac-http/src/augumentation.js.map +0 -1
- package/lib/rbac-http/src/config/rbac-http.d.ts +0 -1
- package/lib/rbac-http/src/config/rbac-http.js +0 -21
- package/lib/rbac-http/src/config/rbac-http.js.map +0 -1
- package/lib/rbac-http/src/controllers/LoginController.d.ts +0 -12
- package/lib/rbac-http/src/controllers/LoginController.js +0 -91
- package/lib/rbac-http/src/controllers/LoginController.js.map +0 -1
- package/lib/rbac-http/src/controllers/UsersController.d.ts +0 -17
- package/lib/rbac-http/src/controllers/UsersController.js +0 -199
- package/lib/rbac-http/src/controllers/UsersController.js.map +0 -1
- package/lib/rbac-http/src/decorators.d.ts +0 -18
- package/lib/rbac-http/src/decorators.js +0 -80
- package/lib/rbac-http/src/decorators.js.map +0 -1
- package/lib/rbac-http/src/dto/login-dto.d.ts +0 -21
- package/lib/rbac-http/src/dto/login-dto.js +0 -34
- package/lib/rbac-http/src/dto/login-dto.js.map +0 -1
- package/lib/rbac-http/src/dto/password-dto.d.ts +0 -23
- package/lib/rbac-http/src/dto/password-dto.js +0 -34
- package/lib/rbac-http/src/dto/password-dto.js.map +0 -1
- package/lib/rbac-http/src/dto/user-dto.d.ts +0 -43
- package/lib/rbac-http/src/dto/user-dto.js +0 -38
- package/lib/rbac-http/src/dto/user-dto.js.map +0 -1
- package/lib/rbac-http/src/index.d.ts +0 -8
- package/lib/rbac-http/src/index.js +0 -25
- package/lib/rbac-http/src/index.js.map +0 -1
- package/lib/rbac-http/src/interfaces.d.ts +0 -23
- package/lib/rbac-http/src/interfaces.js +0 -3
- package/lib/rbac-http/src/interfaces.js.map +0 -1
- package/lib/rbac-http/src/middlewares.d.ts +0 -11
- package/lib/rbac-http/src/middlewares.js +0 -85
- package/lib/rbac-http/src/middlewares.js.map +0 -1
- package/lib/rbac-http/src/policies.d.ts +0 -13
- package/lib/rbac-http/src/policies.js +0 -57
- package/lib/rbac-http/src/policies.js.map +0 -1
- package/lib/rbac-http/src/route-args.d.ts +0 -9
- package/lib/rbac-http/src/route-args.js +0 -24
- package/lib/rbac-http/src/route-args.js.map +0 -1
- package/lib/rbac-http/src/transformers.d.ts +0 -11
- package/lib/rbac-http/src/transformers.js +0 -34
- package/lib/rbac-http/src/transformers.js.map +0 -1
- package/lib/rbac-http.js +0 -7
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augumentation.js","sourceRoot":"","sources":["../src/augumentation.ts"],"names":[],"mappings":";;AAAA,yBAAuB"}
|
package/lib/config/rbac-http.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const middlewares_1 = require("../middlewares");
|
|
4
3
|
const path_1 = require("path");
|
|
5
4
|
function dir(path) {
|
|
6
5
|
return (0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(__dirname, path)));
|
|
@@ -15,8 +14,7 @@ module.exports = {
|
|
|
15
14
|
},
|
|
16
15
|
http: {
|
|
17
16
|
middlewares: [
|
|
18
|
-
|
|
19
|
-
(0, middlewares_1.UserFromSession)(),
|
|
17
|
+
// add global user from session middleware
|
|
20
18
|
],
|
|
21
19
|
},
|
|
22
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rbac-http.js","sourceRoot":"","sources":["../../src/config/rbac-http.ts"],"names":[],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"rbac-http.js","sourceRoot":"","sources":["../../src/config/rbac-http.ts"],"names":[],"mappings":";;AAAA,+BAAgD;AAEhD,SAAS,GAAG,CAAC,IAAY;IACvB,OAAO,IAAA,cAAO,EAAC,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AACD,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,WAAW,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;YACtC,OAAO,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC9B,KAAK,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;SAC3B;KACF;IACD,IAAI,EAAE;QACJ,WAAW,EAAE;QACX,0CAA0C;SAC3C;KACF;CACF,CAAC"}
|
package/lib/dto/login-dto.d.ts
CHANGED
package/lib/dto/login-dto.js
CHANGED
|
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.LoginDto = exports.LoginDtoSchema = void 0;
|
|
10
13
|
const validation_1 = require("@spinajs/validation");
|
|
@@ -19,9 +22,13 @@ exports.LoginDtoSchema = {
|
|
|
19
22
|
required: ['Login', 'Password'],
|
|
20
23
|
};
|
|
21
24
|
let LoginDto = class LoginDto {
|
|
25
|
+
constructor(data) {
|
|
26
|
+
Object.assign(this, data);
|
|
27
|
+
}
|
|
22
28
|
};
|
|
23
29
|
LoginDto = __decorate([
|
|
24
|
-
(0, validation_1.Schema)(exports.LoginDtoSchema)
|
|
30
|
+
(0, validation_1.Schema)(exports.LoginDtoSchema),
|
|
31
|
+
__metadata("design:paramtypes", [Object])
|
|
25
32
|
], LoginDto);
|
|
26
33
|
exports.LoginDto = LoginDto;
|
|
27
34
|
//# sourceMappingURL=login-dto.js.map
|
package/lib/dto/login-dto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-dto.js","sourceRoot":"","sources":["../../src/dto/login-dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login-dto.js","sourceRoot":"","sources":["../../src/dto/login-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAEhC,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,gBAAgB;IACvB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;QACxC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;KAC5C;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;CAChC,CAAC;AAGF,IAAa,QAAQ,GAArB,MAAa,QAAQ;IAKnB,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AARY,QAAQ;IADpB,IAAA,mBAAM,EAAC,sBAAc,CAAC;;GACV,QAAQ,CAQpB;AARY,4BAAQ"}
|
package/lib/dto/password-dto.js
CHANGED
|
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.PasswordDto = exports.PasswordDtoSchema = void 0;
|
|
10
13
|
const validation_1 = require("@spinajs/validation");
|
|
@@ -19,9 +22,13 @@ exports.PasswordDtoSchema = {
|
|
|
19
22
|
required: ['Password', 'ConfirmPassword'],
|
|
20
23
|
};
|
|
21
24
|
let PasswordDto = class PasswordDto {
|
|
25
|
+
constructor(data) {
|
|
26
|
+
Object.assign(this, data);
|
|
27
|
+
}
|
|
22
28
|
};
|
|
23
29
|
PasswordDto = __decorate([
|
|
24
|
-
(0, validation_1.Schema)(exports.PasswordDtoSchema)
|
|
30
|
+
(0, validation_1.Schema)(exports.PasswordDtoSchema),
|
|
31
|
+
__metadata("design:paramtypes", [Object])
|
|
25
32
|
], PasswordDto);
|
|
26
33
|
exports.PasswordDto = PasswordDto;
|
|
27
34
|
//# sourceMappingURL=password-dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-dto.js","sourceRoot":"","sources":["../../src/dto/password-dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"password-dto.js","sourceRoot":"","sources":["../../src/dto/password-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAEhC,QAAA,iBAAiB,GAAG;IAC/B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,mBAAmB;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;QACzD,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;KACjE;IACD,QAAQ,EAAE,CAAC,UAAU,EAAE,iBAAiB,CAAC;CAC1C,CAAC;AAGF,IAAa,WAAW,GAAxB,MAAa,WAAW;IAKtB,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AARY,WAAW;IADvB,IAAA,mBAAM,EAAC,yBAAiB,CAAC;;GACb,WAAW,CAQvB;AARY,kCAAW"}
|
package/lib/dto/user-dto.d.ts
CHANGED
|
@@ -33,10 +33,11 @@ export declare const UserDtoSchema: {
|
|
|
33
33
|
required: string[];
|
|
34
34
|
};
|
|
35
35
|
export declare class UserDto {
|
|
36
|
-
|
|
36
|
+
Idsss?: number;
|
|
37
37
|
Email: string;
|
|
38
38
|
Login: string;
|
|
39
39
|
Password: string;
|
|
40
40
|
ConfirmPassword: string;
|
|
41
41
|
NiceName: string;
|
|
42
|
+
constructor(data: any);
|
|
42
43
|
}
|
package/lib/dto/user-dto.js
CHANGED
|
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.UserDto = exports.UserDtoSchema = void 0;
|
|
10
13
|
const validation_1 = require("@spinajs/validation");
|
|
@@ -23,9 +26,13 @@ exports.UserDtoSchema = {
|
|
|
23
26
|
required: ['Email', 'NiceName'],
|
|
24
27
|
};
|
|
25
28
|
let UserDto = class UserDto {
|
|
29
|
+
constructor(data) {
|
|
30
|
+
Object.assign(this, data);
|
|
31
|
+
}
|
|
26
32
|
};
|
|
27
33
|
UserDto = __decorate([
|
|
28
|
-
(0, validation_1.Schema)(exports.UserDtoSchema)
|
|
34
|
+
(0, validation_1.Schema)(exports.UserDtoSchema),
|
|
35
|
+
__metadata("design:paramtypes", [Object])
|
|
29
36
|
], UserDto);
|
|
30
37
|
exports.UserDto = UserDto;
|
|
31
38
|
//# sourceMappingURL=user-dto.js.map
|
package/lib/dto/user-dto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-dto.js","sourceRoot":"","sources":["../../src/dto/user-dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-dto.js","sourceRoot":"","sources":["../../src/dto/user-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAChC,QAAA,aAAa,GAAG;IAC3B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;QACzD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;QACxC,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;QAChE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;QACzD,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;KAC5C;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;CAChC,CAAC;AAGF,IAAa,OAAO,GAApB,MAAa,OAAO;IAalB,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AAhBY,OAAO;IADnB,IAAA,mBAAM,EAAC,qBAAa,CAAC;;GACT,OAAO,CAgBnB;AAhBY,0BAAO"}
|
package/lib/middlewares.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { SessionProvider } from '@spinajs/rbac';
|
|
1
2
|
import 'reflect-metadata';
|
|
2
3
|
import * as express from 'express';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { ServerMiddleware } from '@spinajs/http';
|
|
5
|
+
export declare class UserFromSessionMiddleware extends ServerMiddleware {
|
|
6
|
+
protected CoockieSecret: string;
|
|
7
|
+
protected SessionProvider: SessionProvider;
|
|
8
|
+
resolveAsync(): Promise<void>;
|
|
9
|
+
before(): (req: express.Request, res: express.Response, next: express.NextFunction) => void;
|
|
10
|
+
after(): (req: express.Request, res: express.Response, next: express.NextFunction) => void;
|
|
11
|
+
}
|
package/lib/middlewares.js
CHANGED
|
@@ -15,6 +15,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
18
24
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
25
|
if (mod && mod.__esModule) return mod;
|
|
20
26
|
var result = {};
|
|
@@ -22,50 +28,64 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
28
|
__setModuleDefault(result, mod);
|
|
23
29
|
return result;
|
|
24
30
|
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
25
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
35
|
+
exports.UserFromSessionMiddleware = void 0;
|
|
27
36
|
const rbac_1 = require("@spinajs/rbac");
|
|
28
37
|
const di_1 = require("@spinajs/di");
|
|
29
38
|
require("reflect-metadata");
|
|
30
39
|
const configuration_1 = require("@spinajs/configuration");
|
|
31
40
|
const cs = __importStar(require("cookie-signature"));
|
|
32
|
-
const console_1 = require("console");
|
|
33
41
|
const luxon_1 = require("luxon");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
const http_1 = require("@spinajs/http");
|
|
43
|
+
let UserFromSessionMiddleware = class UserFromSessionMiddleware extends http_1.ServerMiddleware {
|
|
44
|
+
async resolveAsync() {
|
|
45
|
+
if (!this.CoockieSecret) {
|
|
46
|
+
throw new Error('http.cookie.secres is not set, cannot start UserFromSessionMiddleware. Set this value in configuration file !');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
before() {
|
|
50
|
+
return async (req, _res, next) => {
|
|
51
|
+
try {
|
|
52
|
+
if (req.cookies.ssid) {
|
|
53
|
+
const ssid = cs.unsign(req.cookies.ssid, this.CoockieSecret);
|
|
54
|
+
if (ssid) {
|
|
55
|
+
const session = (await this.SessionProvider.restoreSession(ssid));
|
|
56
|
+
if (session) {
|
|
57
|
+
req.storage.user = new rbac_1.User(session.Data);
|
|
58
|
+
const liveTimeDiff = session.Expiration.diff(luxon_1.DateTime.now());
|
|
59
|
+
if (liveTimeDiff.minutes < 30) {
|
|
60
|
+
await this.SessionProvider.refreshSession(session);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
req.storage.user = null;
|
|
55
66
|
}
|
|
56
67
|
}
|
|
68
|
+
next();
|
|
57
69
|
}
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
catch (err) {
|
|
71
|
+
next(err);
|
|
60
72
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
after() {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, configuration_1.Config)('http.cookie.secret'),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], UserFromSessionMiddleware.prototype, "CoockieSecret", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, di_1.Autoinject)(),
|
|
85
|
+
__metadata("design:type", rbac_1.SessionProvider)
|
|
86
|
+
], UserFromSessionMiddleware.prototype, "SessionProvider", void 0);
|
|
87
|
+
UserFromSessionMiddleware = __decorate([
|
|
88
|
+
(0, di_1.Injectable)(http_1.ServerMiddleware)
|
|
89
|
+
], UserFromSessionMiddleware);
|
|
90
|
+
exports.UserFromSessionMiddleware = UserFromSessionMiddleware;
|
|
71
91
|
//# sourceMappingURL=middlewares.js.map
|
package/lib/middlewares.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../src/middlewares.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../src/middlewares.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAmE;AACnE,oCAAqD;AACrD,4BAA0B;AAE1B,0DAAgD;AAChD,qDAAuC;AACvC,iCAAiC;AACjC,wCAAsE;AAGtE,IAAa,yBAAyB,GAAtC,MAAa,yBAA0B,SAAQ,uBAAgB;IAOtD,KAAK,CAAC,YAAY;QACvB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,+GAA+G,CAAC,CAAC;SAClI;IACH,CAAC;IAEM,MAAM;QACX,OAAO,KAAK,EAAE,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YACjF,IAAI;gBACF,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;oBACpB,MAAM,IAAI,GAAmB,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;oBAC7E,IAAI,IAAI,EAAE;wBACR,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,CAAgB,CAAC;wBACjF,IAAI,OAAO,EAAE;4BACX,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,WAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;4BAC1C,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;4BAC7D,IAAI,YAAY,CAAC,OAAO,GAAG,EAAE,EAAE;gCAC7B,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;6BACpD;yBACF;qBACF;yBAAM;wBACL,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;qBACzB;iBACF;gBACD,IAAI,EAAE,CAAC;aACR;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,GAAG,CAAC,CAAC;aACX;QACH,CAAC,CAAC;IACJ,CAAC;IACM,KAAK;QACV,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAtCC;IADC,IAAA,sBAAM,EAAC,oBAAoB,CAAC;;gEACG;AAGhC;IADC,IAAA,eAAU,GAAE;8BACc,sBAAe;kEAAC;AALhC,yBAAyB;IADrC,IAAA,eAAU,EAAC,uBAAgB,CAAC;GAChB,yBAAyB,CAwCrC;AAxCY,8DAAyB"}
|
package/lib/policies.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { AccessControl, Permission } from 'accesscontrol';
|
|
2
|
-
import { BasePolicy, IController, IRoute } from '@spinajs/http';
|
|
3
|
-
import * as express from 'express';
|
|
2
|
+
import { BasePolicy, IController, IRoute, Request as sRequest } from '@spinajs/http';
|
|
4
3
|
import { User } from '@spinajs/rbac';
|
|
5
4
|
export declare class RbacPolicy extends BasePolicy {
|
|
6
5
|
protected Ac: AccessControl;
|
|
7
6
|
constructor();
|
|
8
7
|
isEnabled(_action: IRoute, _instance: IController): boolean;
|
|
9
|
-
execute(req:
|
|
8
|
+
execute(req: sRequest, action: IRoute, instance: IController): Promise<void>;
|
|
10
9
|
}
|
|
11
10
|
export declare function checkRbacPermission(role: string | string[], resource: string, permission: string): Permission;
|
|
12
11
|
export declare function checkUserPermission(user: User, resource: string, permission: string): Permission;
|
|
13
|
-
export declare function checkRoutePermission(req:
|
|
12
|
+
export declare function checkRoutePermission(req: sRequest, resource: string, permission: string): Permission;
|
package/lib/policies.js
CHANGED
|
@@ -25,11 +25,11 @@ class RbacPolicy extends http_1.BasePolicy {
|
|
|
25
25
|
if (!descriptor || !descriptor.Permission) {
|
|
26
26
|
throw new exceptions_1.Forbidden(`no route permission or resources assigned`);
|
|
27
27
|
}
|
|
28
|
-
if (!req.
|
|
28
|
+
if (!req.storage || !req.storage.user) {
|
|
29
29
|
throw new exceptions_1.AuthenticationFailed();
|
|
30
30
|
}
|
|
31
31
|
if (!checkRoutePermission(req, descriptor.Resource, permission).granted) {
|
|
32
|
-
throw new exceptions_1.Forbidden(`role(s) ${req.
|
|
32
|
+
throw new exceptions_1.Forbidden(`role(s) ${req.storage.user.Role} does not have permission ${permission} for resource ${descriptor.Resource}`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -48,10 +48,10 @@ function checkUserPermission(user, resource, permission) {
|
|
|
48
48
|
}
|
|
49
49
|
exports.checkUserPermission = checkUserPermission;
|
|
50
50
|
function checkRoutePermission(req, resource, permission) {
|
|
51
|
-
if (!req.
|
|
51
|
+
if (!req.storage || !req.storage.user) {
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
|
-
return checkUserPermission(req.
|
|
54
|
+
return checkUserPermission(req.storage.user, resource, permission);
|
|
55
55
|
}
|
|
56
56
|
exports.checkRoutePermission = checkRoutePermission;
|
|
57
57
|
//# sourceMappingURL=policies.js.map
|
package/lib/policies.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":";;;AACA,wCAAqF;AACrF,oDAAsE;AACtE,6CAAyD;AAEzD,oCAAiC;AAGjC,MAAa,UAAW,SAAQ,iBAAU;IAGxC;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,EAAE,GAAG,OAAE,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACpC,CAAC;IAEM,SAAS,CAAC,OAAe,EAAE,SAAsB;QACtD,0BAA0B;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,GAAa,EAAE,MAAc,EAAE,QAAqB;;QACvE,MAAM,UAAU,GAAoB,OAAO,CAAC,WAAW,CAAC,sCAAyB,EAAE,QAAQ,CAAC,CAAC;QAC7F,IAAI,UAAU,GAAG,MAAA,UAAU,CAAC,UAAU,mCAAI,EAAE,CAAC;QAE7C,wCAAwC;QACxC,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YACxC,UAAU,GAAG,MAAA,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,mCAAI,EAAE,CAAC;SACpE;QAED,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YACzC,MAAM,IAAI,sBAAS,CAAC,2CAA2C,CAAC,CAAC;SAClE;QAED,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;YACrC,MAAM,IAAI,iCAAoB,EAAE,CAAC;SAClC;QAED,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,OAAO,EAAE;YACvE,MAAM,IAAI,sBAAS,CAAC,WAAW,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,6BAA6B,UAAU,iBAAiB,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;SACpI;IACH,CAAC;CACF;AAnCD,gCAmCC;AAED,SAAgB,mBAAmB,CAAC,IAAuB,EAAE,QAAgB,EAAE,UAAkB;IAC/F,MAAM,EAAE,GAAG,OAAE,CAAC,GAAG,CAAgB,eAAe,CAAC,CAAC;IAClD,OAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAS,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC;AACrD,CAAC;AAHD,kDAGC;AAED,SAAgB,mBAAmB,CAAC,IAAU,EAAE,QAAgB,EAAE,UAAkB;IAClF,MAAM,EAAE,GAAG,OAAE,CAAC,GAAG,CAAgB,eAAe,CAAC,CAAC;IAElD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,OAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAS,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC;AACrE,CAAC;AARD,kDAQC;AAED,SAAgB,oBAAoB,CAAC,GAAa,EAAE,QAAgB,EAAE,UAAkB;IACtF,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACrE,CAAC;AAND,oDAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spinajs/rbac-http",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.152",
|
|
4
4
|
"description": "HTTP API for user session & permissions",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@spinajs/exceptions": "^1.2.127",
|
|
44
44
|
"@spinajs/log": "^1.2.137",
|
|
45
45
|
"@spinajs/orm": "^1.2.140",
|
|
46
|
-
"@spinajs/rbac": "^1.2.
|
|
46
|
+
"@spinajs/rbac": "^1.2.152",
|
|
47
47
|
"@spinajs/reflection": "^1.2.137",
|
|
48
48
|
"accesscontrol": "^2.2.1",
|
|
49
49
|
"luxon": "^2.4.0"
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@spinajs/orm-sqlite": "^1.2.140"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "c18f00316083d2ce7a080572b833cb4cc37bef7d"
|
|
55
55
|
}
|