Beispiel #1
0
def user_put(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    name = flask.request.json['name']
    name = ''.join(x for x in name if x.isalnum() or x in NAME_SAFE_CHARS)
    user.rename(name)
    return utils.jsonify({})
Beispiel #2
0
def user_put(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    name = flask.request.json['name']
    name = ''.join(x for x in name if x.isalnum() or x in NAME_SAFE_CHARS)
    user.rename(name)
    return utils.jsonify({})
Beispiel #3
0
def _get_key_inline(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    archive = user.build_key_inline()

    response = flask.Response(response=archive, mimetype='application/octet-stream' )
    response.headers.add('Content-Disposition', 'inline; filename="%s.ovpn"' % user.name)

    return response
Beispiel #4
0
def user_delete(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    user_id = user.id
    user.remove()
    for server in org.get_servers():
        server_clients = server.get_clients()
        if user_id in server_clients:
            server.restart()
    return utils.jsonify({})
Beispiel #5
0
def _get_key_archive(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    archive_temp_path = user.build_key_archive()

    with open(archive_temp_path, "r") as archive_file:
        response = flask.Response(response=archive_file.read(), mimetype="application/x-tar")
        response.headers.add("Content-Disposition", 'inline; filename="%s.tar"' % user.name)

    os.remove(archive_temp_path)
    return response
Beispiel #6
0
def _get_key_inline(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    archive = user.build_key_inline()

    response = flask.Response(response=archive,
                              mimetype='application/octet-stream')
    response.headers.add('Content-Disposition',
                         'inline; filename="%s.ovpn"' % user.name)

    return response
Beispiel #7
0
def _get_key_archive(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    archive_temp_path = user.build_key_archive()

    with open(archive_temp_path, 'r') as archive_file:
        response = flask.Response(response=archive_file.read(),
                                  mimetype='application/x-tar')
        response.headers.add('Content-Disposition',
                             'inline; filename="%s.tar"' % user.name)

    os.remove(archive_temp_path)
    return response
Beispiel #8
0
def user_delete(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    user.remove()
    return utils.jsonify({})
Beispiel #9
0
def user_otp_secret_delete(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    user.generate_otp_secret()
    return utils.jsonify({})
Beispiel #10
0
def user_delete(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    user.remove()
    return utils.jsonify({})