2020-07-08 11:56:37 +00:00
|
|
|
package authz
|
2020-03-23 06:01:59 +00:00
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
RolePermissionMappings []RoleMapping
|
|
|
|
}
|
|
|
|
|
|
|
|
type RoleMapping struct {
|
|
|
|
Role string
|
|
|
|
Permissions []string
|
|
|
|
}
|
|
|
|
|
|
|
|
type MethodMapping map[string]Option
|
|
|
|
|
|
|
|
type Option struct {
|
|
|
|
Permission string
|
|
|
|
CheckParam string
|
2023-04-25 07:02:29 +00:00
|
|
|
AllowSelf bool
|
2020-03-23 06:01:59 +00:00
|
|
|
}
|
|
|
|
|
2023-04-25 07:02:29 +00:00
|
|
|
func getPermissionsFromRole(rolePermissionMappings []RoleMapping, role string) []string {
|
|
|
|
for _, roleMap := range rolePermissionMappings {
|
2020-03-23 06:01:59 +00:00
|
|
|
if roleMap.Role == role {
|
|
|
|
return roleMap.Permissions
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|