1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Author: 金书记 | Author: Jin Shuji
//
//! Permission / Role / Ban Data Source | 权限、角色、封禁数据源
//!
//! Application-supplied permission / role data source (DB, RPC, config, …).
//! 由业务方实现的权限/角色数据源(数据库、RPC、配置中心……)。
//! This crate adds [`StpInterface::is_writable`] to answer where write ops land.
//! 本 crate 额外提供 [`StpInterface::is_writable`],标明写操作落点。
//!
//! The application implements it to plug a data
//! source (database, RPC, config service, ...) into the framework.
//! [`StpInterface::is_writable`] answers: **where should framework-issued writes land?**
//!
//! ## 唯一数据源 | Single Data Source
//!
//! B2 起,本 trait 是权限/角色/封禁数据的**唯一**抽象:
//! - 未注入自定义实现时,框架使用 [`StorageStpInterface`](读写都走 storage)
//! - 注入后,**读**走回调;**写**按 [`crate::config::GrantWritePolicy`] 处理
//! - 优先级判断**只存在于** [`crate::service::AuthzService`] 一处,
//! `GrantRepo` 不再感知本 trait
//!
//! Since B2 this trait is the single abstraction for grant data. Without a
//! custom implementation the framework uses `StorageStpInterface`. With one,
//! reads go to the callback while writes follow `GrantWritePolicy`. The
//! precedence decision lives **only** in `AuthzService`; `GrantRepo` is
//! deliberately unaware of this trait to avoid recursing through
//! `StorageStpInterface`.
use async_trait;
pub use StorageStpInterface;
use crateSaTokenResult;
/// 权限、角色、封禁数据回调 | Permission, role and ban data callback