예제 #1
0
def is_admin(token):
    print("is_admin(token)")
    result = False
    okta_auth = OktaAuth(default_settings)
    check_admin = TokenUtil.get_single_claim_from_token(token,"taa")
    result = check_admin

    return result
예제 #2
0
def users():
    user_info = get_user_info()
    okta_admin = OktaAdmin(default_settings)

    token = oidc.get_access_token()
    group_name = TokenUtil.get_single_claim_from_token(token,"tagrp")
    user_group = get_travel_agency_group_by_name(group_name)
    group_id = user_group["id"]

    group_user_list = okta_admin.get_user_list_by_group_id(group_id)
    return render_template("users.html", user_info=user_info, oidc=oidc, userlist= group_user_list, config=default_settings, travel_agency_group=user_group)
예제 #3
0
def admincreateuser():
    print("Admin Create User()")

    okta_admin = OktaAdmin(default_settings)
    first_name = request.form.get('firstname')
    last_name = request.form.get('lastname')
    email = request.form.get('email')
    login = request.form.get('login')
    mobile_phone = request.form.get('phonenumber')

    if not login:
        login = email

    #  Group and find a Travel Agency
    token = oidc.get_access_token()
    group_name = TokenUtil.get_single_claim_from_token(token,"tagrp")


    user_data = {
                "profile": {
                    "firstName": first_name,
                    "lastName": last_name,
                    "email": email,
                    "login": login,
                    "mobilePhone": mobile_phone,
                    "travelAgencyGroup": group_name
                }
            }

    user_create_response = okta_admin.create_user(user_data)
    if user_create_response:
        message = "User " + first_name + " "+  last_name+ " was Created"
    else:
        message = "Error During Create"


    return redirect(url_for("users", _external="True", _scheme="https",message=message))
예제 #4
0
def upload_route_summary():
    if request.method == 'POST':
        user_info = get_user_info()
        okta_admin = OktaAdmin(default_settings)


        # Group Name from Claims
        token = oidc.get_access_token()
        group_name = TokenUtil.get_single_claim_from_token(token,"tagrp")
        user_group = get_travel_agency_group_by_name(group_name)

        # Create variable for uploaded file
        f = request.files['fileupload']

        #store the file contents as a string
        fstring = f.read().decode('utf-8')

        #create list of dictionaries keyed by header row
        csv_dicts = [{k: v for k, v in row.items()} for row in csv.DictReader(fstring.splitlines(), skipinitialspace=True)]
        return_list = []
        return_users = []
        for user_record in csv_dicts:
            user_data = {
                "profile": {
                    "firstName": user_record['firstName'].replace("'", ""),
                    "lastName": user_record['lastName'].replace("'", ""),
                    "email": user_record['email'].replace("'", ""),
                    "login": user_record['email'].replace("'", ""),
                    "mobilePhone": user_record['mobilePhone'].replace("'", ""),
                    "travelAgencyGroup": group_name
                }
            }
            return_users.append(user_data)
            import_users = okta_admin.create_user(user_data,True)
            return_list.append(import_users)

    return render_template("upload.html", user_info=user_info, oidc=oidc,returnlist=return_list, userlist=return_users, config=default_settings, travel_agency_group=user_group)
예제 #5
0
def healthcare_profile():
    user_info = get_userinfo()
    okta_admin = OktaAdmin(session[SESSION_INSTANCE_SETTINGS_KEY])
    user = okta_admin.get_user(user_info["sub"])

    if get_udp_ns_fieldname("consent") in user["profile"]:
        logging.debug(user)
        consent = user["profile"][get_udp_ns_fieldname("consent")]
        logging.debug(consent)
        if consent.strip() == "":
            consent = ''
            session['appointment'] = "No Appointments Currently Set."
    else:
        consent = ''
    logging.debug(consent)

    factors = get_enrolled_factors(user["id"])

    id_token = TokenUtil.get_id_token(request.cookies)
    patientid = TokenUtil.get_single_claim_from_token(id_token, "extPatientId")

    is_evident_validated = ""
    if get_udp_ns_fieldname("is_evident_validated") in user["profile"]:
        is_evident_validated = user["profile"][get_udp_ns_fieldname(
            "is_evident_validated")]

    return render_template("healthcare/profile.html",
                           id_token=TokenUtil.get_id_token(request.cookies),
                           access_token=TokenUtil.get_access_token(
                               request.cookies),
                           user_info=get_userinfo(),
                           user_info2=user,
                           config=session[SESSION_INSTANCE_SETTINGS_KEY],
                           consent=consent,
                           factors=factors,
                           patientid=patientid,
                           is_evident_validated=is_evident_validated)