This commit is contained in:
parent
b47c5d5f32
commit
60963ef69d
5
main.py
5
main.py
@ -4,6 +4,7 @@ from flask import Flask
|
||||
from flask import Response
|
||||
from flask import request
|
||||
from hvac import Client
|
||||
from hvac.exceptions import InvalidRequest
|
||||
|
||||
|
||||
BIND_HOST = os.getenv("BIND_HOST", "0.0.0.0")
|
||||
@ -46,7 +47,11 @@ def login():
|
||||
username, password = request.form["username"], request.form["password"]
|
||||
|
||||
client = Client(VAULT_ADDR)
|
||||
try:
|
||||
client.auth.userpass.login(username, password)
|
||||
except InvalidRequest:
|
||||
return Response(response="Unauthorized", status=401)
|
||||
|
||||
if not client.is_authenticated():
|
||||
return Response(response="Unauthorized", status=401)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user