Beispiel #1
0
    def run_user_role_link_roles(user_id):
        """This function will return the roles in the RBAC database for a user"""
        with orm.UserRolesManager() as urm:
            user_roles = list(
                role.id
                for role in urm.get_all_roles_from_user(user_id=user_id))

        return user_roles
Beispiel #2
0
    def run_user_role_link(user_id):
        """This function will return the final policies of a user according to its roles in the RBAC database"""
        with orm.UserRolesManager() as urm:
            user_roles = list(role for role in urm.get_all_roles_from_user(user_id=user_id))
        user_roles_policies = defaultdict(list)
        with orm.RolesPoliciesManager() as rpm:
            for role in user_roles:
                for policy in rpm.get_all_policies_from_role(role_id=role.id):
                    user_roles_policies['policies'].append(policy.to_dict()['policy'])
                user_roles_policies['roles'].append(role.id)

        return user_roles_policies