コード例 #1
0
def list_users(request, access_token):
    conf = _get_config(request)
    get = request.GET
    starts_with = None
    if 'startsWith' in get:
        starts_with = get['startsWith']

    client = UsersClient('https://' + conf['org'], config.get_api_key(request))

    is_org_token = False
    try:
        token_obj = parse_bearer_token(access_token)
        if token_obj['iss'] == 'https://{0}'.format(conf['org']):
            is_org_token = True
    except Exception as e:
        print(e)

    if is_org_token:
        client.set_bearer_token(access_token)
        users = client.list_users(15, starts_with)
    else:
        profile_dict = request.session['profile']
        company_name = profile_dict.get('companyName')
        if api_access_admin(conf, access_token):
            users = client.list_users(15, starts_with)
        elif api_access_company_admin(conf, access_token):
            users = client.list_users_scoped(15, company_name, starts_with)
        else:
            return not_authorized(request)

    response = HttpResponse()
    response.status_code = 200
    response.content = users
    return response
コード例 #2
0
def list_users(request):
    get = request.GET
    startsWith = None
    if 'startsWith' in get:
        startsWith = get['startsWith']
    client = UsersClient('https://' + OKTA_ORG, API_KEY)
    users = client.list_users(15, startsWith)
    response = HttpResponse()
    response.status_code = 200
    response.content = users
    return response
コード例 #3
0
def list_users(request):
    get = request.GET
    startsWith = None
    if 'startsWith' in get:
        startsWith = get['startsWith']
    client = UsersClient('https://' + OKTA_ORG, API_KEY)

    if 'admin' in request.session:
        users = client.list_users(15, startsWith)
    elif 'department_admin' in request.session:
        users = client.list_users_scoped(15,
                                         request.session.get('department', ''),
                                         startsWith)
    else:
        return not_authorized(request)

    response = HttpResponse()
    response.status_code = 200
    response.content = users
    return response
コード例 #4
0
def list_users(request, token):
    get = request.GET
    startsWith = None
    if 'startsWith' in get:
        startsWith = get['startsWith']

    client = UsersClient('https://' + OKTA_ORG, API_KEY)
    profile_dict = request.session['profile']
    #profile_dict = json.loads(profile)
    companyName = profile_dict.get('companyName')

    if api_access_admin(token):
        users = client.list_users(15, startsWith)
    elif api_access_company_admin(token):
        users = client.list_users_scoped(15, companyName, startsWith)
    else:
        return not_authorized(request)

    response = HttpResponse()
    response.status_code = 200
    response.content = users
    return response