@riao/iam 5.0.1 → 5.0.2
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/README.md
CHANGED
|
@@ -95,13 +95,6 @@ class RoleBasedAuthorization extends Authorization<Principal> {
|
|
|
95
95
|
return hasPermission;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
async grantPermission(options: GrantPermissionOptions): Promise<void> {
|
|
99
|
-
// Implement grant logic
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async revokePermission(options: RevokePermissionOptions): Promise<void> {
|
|
103
|
-
// Implement revoke logic
|
|
104
|
-
}
|
|
105
98
|
}
|
|
106
99
|
|
|
107
100
|
const authz = new RoleBasedAuthorization({ db });
|
|
@@ -152,27 +145,6 @@ if (isAuthorized) {
|
|
|
152
145
|
}
|
|
153
146
|
```
|
|
154
147
|
|
|
155
|
-
#### Grant Permissions
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
await authz.grantPermission({
|
|
159
|
-
principalId: principal.id,
|
|
160
|
-
action: 'delete',
|
|
161
|
-
resource: 'document-123',
|
|
162
|
-
metadata: { grantedBy: 'admin', grantedAt: new Date() }
|
|
163
|
-
});
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
#### Revoke Permissions
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
await authz.revokePermission({
|
|
170
|
-
principalId: principal.id,
|
|
171
|
-
action: 'delete',
|
|
172
|
-
resource: 'document-123'
|
|
173
|
-
});
|
|
174
|
-
```
|
|
175
|
-
|
|
176
148
|
### Authentication Protection and Lockout
|
|
177
149
|
|
|
178
150
|
Authentication drivers can optionally plug into a shared protection contract to prevent brute-force attempts and enforce temporary lockout windows.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DatabaseRecordId } from '@riao/dbal';
|
|
2
1
|
import { Auth, AuthOptions, Principal } from '../auth';
|
|
3
2
|
export type AuthorizationOptions = AuthOptions;
|
|
4
3
|
export interface AuthorizationSubject {
|
|
@@ -19,18 +18,6 @@ export interface AuthorizationResult {
|
|
|
19
18
|
export interface AuthorizationService<TSubject extends AuthorizationSubject = AuthorizationSubject> {
|
|
20
19
|
evaluate(context: AuthorizationContext<TSubject>): Promise<AuthorizationResult>;
|
|
21
20
|
}
|
|
22
|
-
export interface GrantPermissionOptions {
|
|
23
|
-
principalId: DatabaseRecordId;
|
|
24
|
-
action: string;
|
|
25
|
-
resource?: string;
|
|
26
|
-
metadata?: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
export interface RevokePermissionOptions {
|
|
29
|
-
principalId: DatabaseRecordId;
|
|
30
|
-
action: string;
|
|
31
|
-
resource?: string;
|
|
32
|
-
metadata?: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
21
|
export declare abstract class Authorization<TPrincipal extends Principal, TSubject extends AuthorizationSubject = TPrincipal> extends Auth<TPrincipal> implements AuthorizationService<TSubject> {
|
|
35
22
|
/**
|
|
36
23
|
* Evaluate authorization for a given context
|
|
@@ -52,16 +39,4 @@ export declare abstract class Authorization<TPrincipal extends Principal, TSubje
|
|
|
52
39
|
* @returns Authorization result
|
|
53
40
|
*/
|
|
54
41
|
protected checkPermission(context: AuthorizationContext<TSubject>): Promise<AuthorizationResult>;
|
|
55
|
-
/**
|
|
56
|
-
* Grant a permission to a principal
|
|
57
|
-
* Subclasses should implement this based on their model
|
|
58
|
-
* @param options The grant permission options
|
|
59
|
-
*/
|
|
60
|
-
abstract grantPermission(options: GrantPermissionOptions): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Revoke a permission from a principal
|
|
63
|
-
* Subclasses should implement this based on their model
|
|
64
|
-
* @param options The revoke permission options
|
|
65
|
-
*/
|
|
66
|
-
abstract revokePermission(options: RevokePermissionOptions): Promise<void>;
|
|
67
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../../src/authorization/authorization.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../../src/authorization/authorization.ts"],"names":[],"mappings":";;;AAAA,kCAAuD;AAiCvD,MAAsB,aAGpB,SAAQ,WAAgB;IAWzB;;;;OAIG;IACI,KAAK,CAAC,YAAY,CACxB,OAAuC;QAEvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,OAAO,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,eAAe;IAC9B,6DAA6D;IAC7D,OAAuC;QAEvC,uCAAuC;QACvC,OAAO;YACN,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,mCAAmC;SAC3C,CAAC;IACH,CAAC;CACD;AA1CD,sCA0CC"}
|
package/authorization/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Authorization, AuthorizationSubject, AuthorizationRequirement, AuthorizationService, AuthorizationContext, AuthorizationOptions, AuthorizationResult,
|
|
1
|
+
export { Authorization, AuthorizationSubject, AuthorizationRequirement, AuthorizationService, AuthorizationContext, AuthorizationOptions, AuthorizationResult, } from './authorization';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/authorization/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/authorization/index.ts"],"names":[],"mappings":";;;AAAA,iDAQyB;AAPxB,8GAAA,aAAa,OAAA"}
|