コード例 #1
0
def test():

    r = request.headers

    if api(r):

        return 'Authorized!'

    else:
        return 'Unuthorized'
コード例 #2
0
def banned_addresses():

    banned_ip = BannedIPManager(conf)

    if api(request.headers):

        # Adds IP in POST to banned-ips.json
        if request.method == "POST":
            req = ast.literal_eval(request.data.decode("utf-8"))
            banned_ip.add(req['address'])

        return banned_ip.get()
    else:
        return banned_ip.unauthorized()
コード例 #3
0
def banned_players():

    banned = BannedPlayerManager(conf)

    if api(request.headers):

        # Adds Player in POST to banned-players.json
        if request.method == "POST":
            req = ast.literal_eval(request.data.decode("utf-8"))
            message = banned.add(req['username'])

            return UserListManager.jsonify(message)

        return banned.get()
    else:
        return banned.unauthorized()
コード例 #4
0
def admin_usernames():

    # create OppedManager
    opped = OppedManager(conf)

    if api(request.headers):

        # Adds Player in POST to ops.json
        if request.method == "POST":
            req = ast.literal_eval(request.data.decode("utf-8"))
            message = opped.add(req['username'])

            return UserListManager.jsonify(message)

        return opped.get()
    else:
        return opped.unauthorized()
コード例 #5
0
def banned_address(address: str):

    address = address.replace("-", ".")

    banned_ip = BannedIPManager(conf)

    if api(request.headers):

        # Removes IP in DELETE from banned-ips.json
        if request.method == "DELETE":

            req = ast.literal_eval(request.data.decode("utf-8"))

            message = banned_ip.remove(req['address'])

            return UserListManager.jsonify(message)

        return banned_ip.get()
    else:
        return banned_ip.unauthorized()
コード例 #6
0
def whitelist_users():

    whitelist = WhitelistManager(conf)

    if api(request.headers):

        # Adds Player from POST to whitelist.json
        if request.method == "POST":

            key = request.headers['Authorization']
            print(key)

            req = ast.literal_eval(request.data.decode("utf-8"))

            message = whitelist.add(req['username'])

            return UserListManager.jsonify(message)

        return whitelist.get()
    else:
        return whitelist.unauthorized()
コード例 #7
0
def banned_player(uuid: str):
    banned = BannedPlayerManager(conf)
    mojang = MojangAPI()

    uuid = uuid.replace("-", "")
    player = mojang.username(uuid=uuid)

    if api(request.headers):

        if not player:
            return UserListManager.jsonify([])

        # removes Player in DELETE from banned-players.json
        if request.method == "DELETE":

            message = banned.remove(player)

            return UserListManager.jsonify(message)

        return banned.get(item=player)
    else:
        return banned.unauthorized()
コード例 #8
0
def whitelist_user(uuid: str):

    whitelist = WhitelistManager(conf)
    mojang = MojangAPI()

    uuid = uuid.replace("-", "")
    player = mojang.username(uuid=uuid)

    if api(request.headers):

        if not player:
            return UserListManager.jsonify([])

        # Removes Player in DELETE from whitelist.json
        if request.method == "DELETE":

            message = whitelist.remove(player)

            return UserListManager.jsonify(message)

        return whitelist.get(item=player)
    else:
        return whitelist.unauthorized()
コード例 #9
0
def admin_user(uuid: str):

    # create OppedManager
    opped = OppedManager(conf)
    mojang = MojangAPI()

    uuid = uuid.replace("-", "")
    player = mojang.username(uuid=uuid)

    if api(request.headers):

        if not player:
            return UserListManager.jsonify([])

        # Removes Player in DELETE from ops.json
        if request.method == "DELETE":

            message = opped.remove(player)

            return UserListManager.jsonify(message)

        return opped.get(item=player)
    else:
        return opped.unauthorized()