-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from Nuno-Jesus/2factor
2factor
- Loading branch information
Showing
70 changed files
with
1,706 additions
and
896 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ POSTGRES_PASSWORD="1234" | |
PGADMIN_DEFAULT_EMAIL="[email protected]" | ||
PGADMIN_DEFAULT_PASSWORD="1234" | ||
PGADMIN_LISTEN_PORT="8080" | ||
|
||
EMAIL_USER='[email protected]' | ||
EMAIL_PASS='uwgk hbmf sera vxch' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
|
||
from pathlib import Path | ||
import os | ||
from datetime import timedelta | ||
|
||
from dotenv import load_dotenv | ||
|
||
|
@@ -41,8 +42,8 @@ | |
DEBUG = True | ||
|
||
|
||
LOGOUT_REDIRECT_URL = "login" | ||
LOGIN_REDIRECT_URL = '' | ||
LOGOUT_REDIRECT_URL = 'login' | ||
LOGIN_REDIRECT_URL = 'home' | ||
LOGIN_URL = 'login' | ||
|
||
ALLOWED_HOSTS = ['*'] | ||
|
@@ -58,12 +59,13 @@ | |
SESSION_COOKIE_SECURE = False # Deve ser True em produção, requer HTTPS | ||
SESSION_EXPIRE_AT_BROWSER_CLOSE = False # Define se a sessão expira ao fechar o navegador | ||
|
||
CSRF_COOKIE_SECURE = False | ||
CSRF_COOKIE_HTTPONLY = True | ||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'daphne', | ||
'crispy_forms', | ||
'crispy_bootstrap4', | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
|
@@ -72,6 +74,12 @@ | |
'django.contrib.staticfiles', | ||
'rest_framework', #django rest framework | ||
'rest_framework_swagger', | ||
'rest_framework_simplejwt', | ||
'rest_framework_simplejwt.token_blacklist', | ||
'corsheaders', | ||
'django_otp', | ||
'django_otp.plugins.otp_totp', | ||
'django_otp.plugins.otp_static', | ||
'drf_yasg', | ||
"pong", | ||
'bootstrap4', | ||
|
@@ -80,11 +88,12 @@ | |
MIDDLEWARE = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
"corsheaders.middleware.CorsMiddleware", | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
'django_otp.middleware.OTPMiddleware', | ||
] | ||
|
||
AUTHENTICATION_BACKENDS = [ | ||
|
@@ -131,17 +140,20 @@ | |
} | ||
|
||
REST_FRAMEWORK = { | ||
# Use Django's standard `django.contrib.auth` permissions, | ||
# or allow read-only access for unauthenticated users. | ||
# 'DEFAULT_PERMISSION_CLASSES': [ | ||
# 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' | ||
# ] | ||
# For a quick way to limit permissions to authenticated users, we add the following to our settings file: | ||
# 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',) | ||
'DEFAULT_AUTHENTICATION_CLASSES': ( | ||
'rest_framework_simplejwt.authentication.JWTAuthentication', | ||
), | ||
|
||
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema' | ||
} | ||
|
||
SIMPLE_JWT = { | ||
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=10), | ||
'REFRESH_TOKEN_LIFETIME': timedelta(minutes=60), | ||
'AUTH_HEADER_TYPES': ('Bearer',), | ||
'BLACKLIST_AFTER_ROTATION': True, | ||
} | ||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators | ||
|
||
|
@@ -190,7 +202,7 @@ | |
EMAIL_USE_TLS = True | ||
EMAIL_PORT = 587 | ||
EMAIL_HOST_USER = '[email protected]' | ||
EMAIL_HOST_PASSWORD = 'nfvzbxadhvgzfgpq' | ||
EMAIL_HOST_PASSWORD = 'uwgk hbmf sera vxch' | ||
|
||
|
||
# Default primary key field type | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
|
||
{% block body %} | ||
<link rel="stylesheet" href="{% static 'css/signup.css' %}"> | ||
<script defer src="{% static 'js/login.js' %}"></script> | ||
<script defer src="{% static 'js/opt.js' %}"></script> | ||
<div class="login-container"> | ||
<div class="login-container2"> | ||
<h4 class="title"><img src="{% static 'assets/icons/42logosmall.png' %}"> My Website</h4> | ||
<p>A code was sent to your email {{ user.email }}</p> | ||
<form id="otpForm" method="POST" onsubmit="return submitOtp(event);"> | ||
<div class="input-group"> | ||
<label for="otp">Code: </label> | ||
<input type="text" id="otp" name="otp" placeholder="Please insert the code sent to your email" required> | ||
</div> | ||
<p id="errorMessage" class="error-message"></p> | ||
<p>If you didn't receive your code, please | ||
<a onclick="resend_code()" style="color: blue;">click here</a> to resend the code | ||
</p> | ||
<button type="submit">Confirm</button> | ||
</form> | ||
<br> | ||
<h6>© 42 Porto 2024</h6> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.