5 releases (breaking)
0.6.0 | Feb 21, 2024 |
---|---|
0.4.0 | Feb 3, 2022 |
0.3.0 | Jan 26, 2022 |
0.2.0 | Jan 23, 2022 |
0.1.1 | Jan 22, 2022 |
#1061 in Rust patterns
165KB
3.5K
SLoC
4dk-security
The lib extends core behaviour with security features.
It implements the entites : SecuredCommand
, SecuredQuery
, SecuredCommandHandler
, SecuredQueryHandler
, SecuredCommandDispatcher
, SecuredQueryDispatcher
.
Command
SecuredCommand
Extends Command
by decoration. SecuredCommand has to be constructed with user roles.
SecuredCommandHandler
Extends CommandHandler
by decoration. SecuredHandler is defined with a permission.
SecuredCommandDispatcher
Replace the CommandDispatcher
implementation from core-rust
.
When a command is dispatch to the CommandBus
, it will replaces (with RoleReadRepository
impl) user roles by its permissions. Then it will check if user command has the permission to call the handler.
Query
SecuredQuery
Extends Query
by decoration. SecuredQuery has to be constructed with user roles.
SecuredQueryHandler
Extends QueryHandler
by decoration. SecuredHandler is defined with a permission.
SecuredQueryDispatcher
Replace the QueryDispatcher
implementation from core-rust
.
When a query is dispatch to the QueryBus
, it will replaces (with RoleReadRepository
impl) user roles by its permissions. Then it will check if user query has the permission to call the handler.
You can find in samples different bus composition.
Dependencies
~87KB