public static List <RoleAttribute> GetRoleAttributes(this AuthorizationAssertion assert, string appId) { List <RoleAttribute> attributes = null; if (assert != null && assert.Roles != null) { attributes = new List <RoleAttribute>(); foreach (BitKoo.Keystone.AuthService.Role role in assert.Roles) { if (role != null && role.Attributes != null) { foreach (var attr in role.Attributes) { attributes.Add(new RoleAttribute { RoleName = role.Name, ApplicationId = appId, Name = attr.Name, Type = attr.AttributeType, Value = attr.Value }); } } } } return(attributes); }
public static List <AuthFunctionMsg> GetFunctions(this AuthorizationAssertion assert, string appId) { List <AuthFunctionMsg> functions = null; if (assert != null && assert.Roles != null) { functions = new List <AuthFunctionMsg>(); foreach (BitKoo.Keystone.AuthService.Role role in assert.Roles) { if (role != null && role.FunctionalAbilities != null) { foreach (FunctionalAbility func in role.FunctionalAbilities) { AuthFunctionMsg msg = func.ToMessage(appId); functions.Add(msg); } } } } return(functions); }