2fa-0.5
This commit is contained in:
parent
d477a40859
commit
e6c8abe026
34
_2fa.tpl
34
_2fa.tpl
@ -15,17 +15,35 @@
|
|||||||
<main>
|
<main>
|
||||||
<h1>2FA</h1>
|
<h1>2FA</h1>
|
||||||
|
|
||||||
<form name="editEmailForm" method="post" action="/user">
|
% if data['secureAuth'] == True:
|
||||||
|
|
||||||
|
<form name="editEmailForm" method="post" action="/user">
|
||||||
|
|
||||||
<label for="2fa">2FA</label>
|
<label for="2fa">2FA</label>
|
||||||
<input id="2fa" name="2fa" type="text" value="" required>
|
<input id="2fa" name="2fa" type="text" value="" required>
|
||||||
|
|
||||||
<div class="form-buttons">
|
<div class="form-buttons">
|
||||||
<a href="/user"><button class="green" type="button">{{ str['back'] }}</button></a>
|
<a href="/user"><button class="green" type="button">{{ str['back'] }}</button></a>
|
||||||
<button class="green" type="submit">{{ str['update'] }}</button>
|
<button class="green" type="submit">Disable</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
% else:
|
||||||
|
|
||||||
|
<form name="editEmailForm" method="post" action="/user">
|
||||||
|
|
||||||
|
<label for="2fa">2FA</label>
|
||||||
|
<input id="2fa" name="2fa" type="text" value="" required>
|
||||||
|
|
||||||
|
<div class="form-buttons">
|
||||||
|
<a href="/user"><button class="green" type="button">{{ str['back'] }}</button></a>
|
||||||
|
<button class="green" type="submit">Enable</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
%end
|
||||||
|
|
||||||
%for type, text, animation in get('alerts', []):
|
%for type, text, animation in get('alerts', []):
|
||||||
<div class="alerts {{ animation }}">
|
<div class="alerts {{ animation }}">
|
||||||
|
29
libs/gen2fa.py
Normal file
29
libs/gen2fa.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from onetimepass import valid_totp
|
||||||
|
from secrets import choice
|
||||||
|
|
||||||
|
|
||||||
|
def generate_secret(): # Function to return a random string with length 16.
|
||||||
|
secret = ''
|
||||||
|
while len(secret) < 16:
|
||||||
|
secret += choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567')
|
||||||
|
return secret
|
||||||
|
|
||||||
|
|
||||||
|
secret = generate_secret()
|
||||||
|
print('Enter the following secret in your authenticator app: ', secret)
|
||||||
|
print("""
|
||||||
|
Instructions for saving this secret it Google Authenticator:
|
||||||
|
1. Open Google Authenticator.
|
||||||
|
2. Click plus icon at the right bottom.
|
||||||
|
3. Click Enter a setup key.
|
||||||
|
4. Enter an Account name of your choice and enter the secret provided above.
|
||||||
|
5. Click Add.
|
||||||
|
""")
|
||||||
|
while True:
|
||||||
|
otp = int(input('Please enter the otp generated by your authenticator app: '))
|
||||||
|
authenticated = valid_totp(otp, secret)
|
||||||
|
if authenticated:
|
||||||
|
print('Correct otp, Authenticated!')
|
||||||
|
elif not authenticated:
|
||||||
|
print('Wrong otp, please try again.')
|
||||||
|
|
26
user.tpl
26
user.tpl
@ -50,34 +50,22 @@
|
|||||||
<div class="grid-item">
|
<div class="grid-item">
|
||||||
<a href="/change_pwd">{{ str['edit'] }}</a>
|
<a href="/change_pwd">{{ str['edit'] }}</a>
|
||||||
</div>
|
</div>
|
||||||
<!--
|
|
||||||
<div class="grid-item">
|
|
||||||
<div class="account">
|
|
||||||
<h5>2FA</h5>
|
|
||||||
<p>Bi urratseko autentifikazioa {{data['secureAuth']}}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid-item">
|
<!-- 2FA -->
|
||||||
<input type="checkbox" id="2fa" name="2fa" value="2fa" {{!'checked="checked"' if data['secureAuth'] == True else ""}} >
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
<!--
|
|
||||||
<div class="grid-item">
|
|
||||||
<a href="/_2fa">{{'Desgaitu' if data['secureAuth'] == True else "Gaitu"}}</a>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
<div class="grid-item">
|
<div class="grid-item">
|
||||||
<div class="account">
|
<div class="account">
|
||||||
<h5>2FA</h5>
|
<h5>2FA</h5>
|
||||||
<p>Bi urratseko autentifikazioa {{data['secureAuth']}}</p>
|
<p>Bi urratseko autentifikazioa</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid-item">
|
<div class="grid-item">
|
||||||
<!--<a href="/_2fa">{{'Kendu' if data['secureAuth'] == True else "Ezarri"}}</a>-->
|
<!--<a href="/_2fa">{{'Kendu' if data['secureAuth'] == True else "Ezarri"}}</a>-->
|
||||||
<a href="/_2fa">{{"<i class='ri-toogle-fill'></i>" if data['secureAuth'] == True else "<i class='ri-toggle-line'></i>"}}</a>
|
% if data['secureAuth'] == True:
|
||||||
<!-- <a href="/_2fa"><i class="ri-toggle-fill"></i></a> -->
|
<a href="/_2fa"><i class='ri-toggle-fill'></i></a>
|
||||||
|
% else:
|
||||||
|
<a href="/_2fa"><i class='ri-toggle-line'></i></a>
|
||||||
|
%end
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid-item">
|
<div class="grid-item">
|
||||||
|
Loading…
Reference in New Issue
Block a user