Exemple #1
0
def get_role(keycloak: KeycloakClient, role_id):
    try:
        role_data = keycloak.role_get(role_id)
        return role_data | {'_href': _role_href(role_data)}
    except KeycloakGetError as e:
        logger.exception(e)
        return problem_from_keycloak_error(e)
    except Exception as e:
        logger.exception(e)
        return problem(500, 'Unknown Error', str(e))
Exemple #2
0
def create_role(keycloak: KeycloakClient, body, user):
    try:
        role_id = keycloak.role_create(body)
        logger.info(f'Create role {role_id}')
        role_data = keycloak.role_get(role_id)
        return role_data | {'_href': _role_href(role_data)}
    except KeycloakGetError as e:
        logger.exception(e)
        return problem_from_keycloak_error(e)
    except Exception as e:
        logger.exception(e)
        return problem(500, 'Unknown Error', str(e))
Exemple #3
0
def update_role(keycloak: KeycloakClient, role_id, body, user):
    try:
        keycloak.role_update(role_id, body)
        role_name = body['name']
        logger.info(f'Updated role {role_id}')
        role_data = keycloak.role_get(role_name)
        return role_data | {'_href': _role_href(role_data)}
    except KeycloakGetError as e:
        logger.exception(e)
        return problem_from_keycloak_error(e)
    except Exception as e:
        logger.exception(e)
        return problem(500, 'Unknown Error', str(e))