@lanaqi/rsr 0.0.1 → 0.0.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.
- package/README.md +52 -28
- package/dist/access/blocker.d.ts +3 -3
- package/dist/access/resource.d.ts +5 -5
- package/dist/access/storer.d.ts +3 -3
- package/dist/bridge.d.ts +2 -2
- package/dist/index.js +845 -391
- package/dist/security/blocker.d.ts +5 -10
- package/dist/security/context.d.ts +9 -0
- package/dist/security/index.d.ts +4 -0
- package/dist/security/provider.d.ts +8 -14
- package/dist/support/aaa.d.ts +4 -6
- package/dist/support/signature.d.ts +2 -3
- package/dist/support/user.d.ts +6 -7
- package/dist/warpper/permission.d.ts +5 -9
- package/package.json +25 -15
package/README.md
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
React 安全路由器
|
|
4
4
|
|
|
5
|
+
# 如何安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
|
|
9
|
+
npm add @lanaqi/rsr -S
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
|
|
5
13
|
# 框架说明
|
|
6
14
|
|
|
7
|
-
rsr 是 react security router 的简写,一个基于 react router
|
|
15
|
+
rsr 是 react security router 的简写,一个基于 react router 实现纯前端路由级别控制的安全框架。
|
|
8
16
|
|
|
9
17
|
功能简介:
|
|
10
18
|
|
|
@@ -13,37 +21,53 @@ rsr 是 react security router 的简写,一个基于 react router 实现路由
|
|
|
13
21
|
- 二次签证(签名:如要求再次输入密码等)
|
|
14
22
|
- 等等
|
|
15
23
|
|
|
24
|
+
注意: 该框架没有编写相关文档,需要自行看源码(注释)和例子。
|
|
25
|
+
|
|
16
26
|
# 版本兼容
|
|
17
27
|
|
|
18
|
-
|
|
28
|
+
注意:目前 0.0.3 + 版本只支持 react 19 + ,另外只兼容 react router v7 (react-router) 版本 (并非:react-router-dom),其它的版本,暂时不考虑兼容。
|
|
19
29
|
|
|
20
30
|
# 简单例子
|
|
21
31
|
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
```tsx
|
|
33
|
+
export default withSecurityBlocker(Root, (bundler) => {
|
|
34
|
+
return (
|
|
35
|
+
bundler
|
|
36
|
+
.context((builder) => {
|
|
37
|
+
return (
|
|
38
|
+
builder
|
|
39
|
+
// 可选层级权限
|
|
40
|
+
// .hierarchy('superadmin>admin;admin>users;users>guest')
|
|
41
|
+
.resource((rb) =>
|
|
42
|
+
rb
|
|
43
|
+
.patterns("/login", "/logout", "/denied", "/signature")
|
|
44
|
+
.anonymous()
|
|
45
|
+
.build(),
|
|
46
|
+
)
|
|
47
|
+
.resource((rb) =>
|
|
48
|
+
rb.patterns("/sheet").permissions("admin").signatured().build(),
|
|
49
|
+
)
|
|
50
|
+
.resource((rb) => rb.patterns("/*").authenticated().build())
|
|
51
|
+
.build()
|
|
52
|
+
);
|
|
53
|
+
})
|
|
54
|
+
.manager((builder) => {
|
|
55
|
+
return builder
|
|
56
|
+
.behave({
|
|
57
|
+
notAuthenticationPath: "/login",
|
|
58
|
+
notSignaturePath: "/signature",
|
|
59
|
+
accessDeniedPath: "/denied",
|
|
60
|
+
})
|
|
61
|
+
.build();
|
|
62
|
+
})
|
|
63
|
+
// .addons()
|
|
64
|
+
.build()
|
|
65
|
+
);
|
|
47
66
|
});
|
|
48
|
-
|
|
49
67
|
```
|
|
68
|
+
|
|
69
|
+
# 其它例子
|
|
70
|
+
|
|
71
|
+
基于 Modern.js 的例子:https://github.com/lanaqi-opensource/rsr-demo
|
|
72
|
+
|
|
73
|
+
基于 react-router 的例子:https://github.com/lanaqi-opensource/rsr6-demo
|
package/dist/access/blocker.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface AccessBlocker {
|
|
|
28
28
|
* 注销处理器
|
|
29
29
|
* @param handler 处理器
|
|
30
30
|
*/
|
|
31
|
-
unregister(handler
|
|
31
|
+
unregister(handler?: BlockHandler): void;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* 单一阻断器
|
|
@@ -55,7 +55,7 @@ export declare class SingleBlocker implements AccessBlocker {
|
|
|
55
55
|
* 注销处理器
|
|
56
56
|
* @param handler 处理器
|
|
57
57
|
*/
|
|
58
|
-
unregister(handler
|
|
58
|
+
unregister(handler?: BlockHandler): void;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* 多个阻断器
|
|
@@ -86,7 +86,7 @@ export declare class MultiBlocker implements AccessBlocker {
|
|
|
86
86
|
* 注销处理器
|
|
87
87
|
* @param handler 处理器
|
|
88
88
|
*/
|
|
89
|
-
unregister(handler
|
|
89
|
+
unregister(handler?: BlockHandler): void;
|
|
90
90
|
/**
|
|
91
91
|
* 清理处理器集合
|
|
92
92
|
*/
|
|
@@ -87,23 +87,23 @@ export declare class SimpleResource implements AccessResource {
|
|
|
87
87
|
/**
|
|
88
88
|
* 权限:匿名的
|
|
89
89
|
*/
|
|
90
|
-
static readonly PERMISSION_ANONYMOUS = "
|
|
90
|
+
static readonly PERMISSION_ANONYMOUS = "__aqi_rsr_anonymous";
|
|
91
91
|
/**
|
|
92
92
|
* 权限:已认证
|
|
93
93
|
*/
|
|
94
|
-
static readonly PERMISSION_AUTHENTICATED = "
|
|
94
|
+
static readonly PERMISSION_AUTHENTICATED = "__aqi_rsr_authenticated";
|
|
95
95
|
/**
|
|
96
96
|
* 权限:已授权
|
|
97
97
|
*/
|
|
98
|
-
static readonly PERMISSION_AUTHORIZED = "
|
|
98
|
+
static readonly PERMISSION_AUTHORIZED = "__aqi_rsr_authorized";
|
|
99
99
|
/**
|
|
100
100
|
* 标签:已签名
|
|
101
101
|
*/
|
|
102
|
-
static readonly LABEL_SIGNATURED = "
|
|
102
|
+
static readonly LABEL_SIGNATURED = "__aqi_rsr_signatured";
|
|
103
103
|
/**
|
|
104
104
|
* 标签:始终签名
|
|
105
105
|
*/
|
|
106
|
-
static readonly LABEL_ALWAYS_SIGNATURE = "
|
|
106
|
+
static readonly LABEL_ALWAYS_SIGNATURE = "__aqi_rsr_always_signature";
|
|
107
107
|
/**
|
|
108
108
|
* 模式集合
|
|
109
109
|
* @private
|
package/dist/access/storer.d.ts
CHANGED
|
@@ -81,15 +81,15 @@ export declare class SimpleStorer implements AccessStorer {
|
|
|
81
81
|
/**
|
|
82
82
|
* 存储健:认证
|
|
83
83
|
*/
|
|
84
|
-
static readonly KEY_AUTHENTICATION = "
|
|
84
|
+
static readonly KEY_AUTHENTICATION = "__aqi_rsr_authentication";
|
|
85
85
|
/**
|
|
86
86
|
* 存储健:授权
|
|
87
87
|
*/
|
|
88
|
-
static readonly KEY_AUTHORIZATION = "
|
|
88
|
+
static readonly KEY_AUTHORIZATION = "__aqi_rsr_authorization";
|
|
89
89
|
/**
|
|
90
90
|
* 存储健:签名
|
|
91
91
|
*/
|
|
92
|
-
static readonly KEY_SIGNATURE = "
|
|
92
|
+
static readonly KEY_SIGNATURE = "__aqi_rsr_signature";
|
|
93
93
|
/**
|
|
94
94
|
* 认证与授权存储
|
|
95
95
|
* @private
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 桥接引用的函数和钩子
|
|
3
3
|
*/
|
|
4
|
-
export { matchPath, useBlocker, useLocation, useNavigate } from 'react-router
|
|
4
|
+
export { matchPath, useBlocker, useLocation, useNavigate } from 'react-router';
|
|
5
5
|
/**
|
|
6
6
|
* 桥接引用的类型
|
|
7
7
|
*/
|
|
8
|
-
export type { PathPattern, NavigateFunction, NavigateOptions, To, Path } from 'react-router
|
|
8
|
+
export type { PathPattern, NavigateFunction, NavigateOptions, To, Path } from 'react-router';
|