implemented add host, authenticate user before performing action of vm
This commit is contained in:
parent
68f9bebccb
commit
c474282b33
4 changed files with 123 additions and 39 deletions
14
helper.py
14
helper.py
|
|
@ -8,22 +8,22 @@ from pyotp import TOTP
|
|||
def check_otp(name, realm, token):
|
||||
try:
|
||||
data = {
|
||||
"auth_name": config('AUTH_NAME', ''),
|
||||
"auth_token": TOTP(config('AUTH_SEED', '')).now(),
|
||||
"auth_realm": config('AUTH_REALM', ''),
|
||||
"auth_name": config("AUTH_NAME", ""),
|
||||
"auth_token": TOTP(config("AUTH_SEED", "")).now(),
|
||||
"auth_realm": config("AUTH_REALM", ""),
|
||||
"name": name,
|
||||
"realm": realm,
|
||||
"token": token
|
||||
"token": token,
|
||||
}
|
||||
except binascii.Error:
|
||||
return 400
|
||||
|
||||
response = requests.post(
|
||||
"{OTP_SERVER}{OTP_VERIFY_ENDPOINT}".format(
|
||||
OTP_SERVER=config('OTP_SERVER', ''),
|
||||
OTP_VERIFY_ENDPOINT=config('OTP_VERIFY_ENDPOINT', 'verify/')
|
||||
OTP_SERVER=config("OTP_SERVER", ""),
|
||||
OTP_VERIFY_ENDPOINT=config("OTP_VERIFY_ENDPOINT", "verify/"),
|
||||
),
|
||||
data=data
|
||||
data=data,
|
||||
)
|
||||
return response.status_code
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue