Exemplo n.º 1
0
def find_role_for_user(username, project, environ):
    if username is None:
        return "Anonymous"

    admin_file = environ['OPENCORE_ADMIN_INFO_FILENAME']
    admin, password = libopencore.auth.get_admin_info(admin_file)
    domain = environ['OPENCORE_INTERNAL_ROOT_URL']

    users = get_users_for_project(project, domain, (admin, password))

    for user in users:
        name = user['username']
        if name != username: continue
        roles = user['roles']
        return roles[0]
    return "Authenticated"
Exemplo n.º 2
0
def _fetch_user_roles(project):
    admin_info = auth.get_admin_info(settings.OPENCORE_ADMIN_FILE)
    users = get_users_for_project(project,
                                  settings.OPENCORE_SERVER,
                                  admin_info)
    return users