-
Notifications
You must be signed in to change notification settings - Fork 13
shv access control
Fanda Vacek edited this page Jun 27, 2022
·
42 revisions
- Each user has list of roles defined and accessible to shvbroker. Each role has property
weight
of typeint
defined. - Each SHV method defines its
accessLevel
as a number > 0 or string which must be convertible to access level int by node, see methodShvNode::grantToAccessLevel(...)
.accessLevel == 0
means no-access. - When client calls the RPC method, then shvbroker check access list (ACL) for all the user's
roles sorted by weight DESC
. - For
role
in roles sorted byweight
, greatest first- For
access-rule
in acces-rules forrole
sorted by most specific rule first- if request
shvPath
matchesaccess-rule
- then
grant
of this role is assigned to RPC request asAccessGrant
meta-value and it is sent to the client. It is up to the client implementation whether it checks theaccessGrant
or not. - stop searching with success
- then
- if request
- For
- 'Operation not permitted' RPC error is returned, because
shvPath
match is not found for any ofrole
of anyweight
Access rule consist of:
- service-pattern, used for experimental service down-tree calls only, which might have form:
-
-
**
- ANY -
service-name
- SOME
-
- path-pattern, which might have form:
shv-path
shv-path/**
- method-pattern, which might have form:
method-name
-
- access-grant, will be explained later in Access Grant
Following access rules examples are sorted from most specific to least specific (see bool AclAccessRule::isMoreSpecificThan(const AclAccessRule &other) const
)
Service precedence:
- SOME service
- ANY service
- NO service
Path precedence:
- Exact path with method
- Exact path without method
- Longest path prefix with method
- Longest path prefix without method
path | method | note |
---|---|---|
foo/bar |
baz |
exact match |
foo |
baz |
(same specific as above) |
foo/bar |
(same specific as above) | |
foo |
(same specific as above) | |
foo/bar/** |
baz |
longest path prefix match, exact method match |
foo/** |
baz |
shorter path prefix match, exact method match |
** |
baz |
any path, exact method match |
foo/bar/** |
longer path prefix match, any method | |
foo/** |
shorter path prefix match, any method | |
** |
any path, any method |
This way we can use any path pattern like **/PME/**
because we do not have to define path specificity level and we can also get rid of role weight property.
- When client calls the RPC method, then shvbroker check access list (ACL) for all the user's
roles sorted by order of definition in users roles list, for example
["userAdmin", "support"]`. - For
access-rule
in acces-rules forrole
sorted by natural order of rules definition- if request
shvPath
matchesaccess-rule
thenacces-grant
is read- if
access-grant
is in formjmp role-name
, note that this is not valid Cpon, then searching continues in access table for rolerole-name
- else
access-grant
is added toaccess-grant-list
- if
- if request
- If
access-grant-list
is empty 'Operation not permitted' RPC error is returned, becauseshvPath
match is not found. -
access-grant-list
is assigned to RPC request asaccessGrant
meta-value and it is sent to the client. It is up to the client implementation whether it checks theaccessGrant
or not. Ifaccess-grant-list
size == 1, thenaccessGrant = access-grant-list[0]
Acces grant is rpc value of next forms:
-
Int
, then it isaccessLevel
. -
String
, then id isRole
. -
IMap
, then it isAccessGrant
, meta typeAccessGrant
is optional.- Possible fields: Type = 1, NotResolved, Role, AccessLevel, User, Password, LoginType
Access grants in client requests are removed by broker form security reasons. Only broker can set this field in RpcRequest.
- If slave broker receives RpcMessage
- if
grant
field IS SET, then RpcMessage is forwarded downstream with original grant unchanged. Request is authorized by master broker. - if
grant
field IS NOT SET, then rolemasterBroker
is used in access grant resolution usingaccess
table. This is used mainly for service calls as (un)subscribe propagation to slave brokers etc.
- if
- If client receives RpcMessage
- Access grant from RpcMessage is converted to
accessLevel
by methodShvNode::grantToAccessLevel(...)
on client implementation.
- Access grant from RpcMessage is converted to