Compare commits

...

6 Commits

Author SHA1 Message Date
pablohashescobar
62f9be1aaa dev: update the magic login expire check 2024-05-16 16:27:00 +05:30
pablohashescobar
3a907677c6 Merge branch 'fix-session-save' of github.com:makeplane/plane into fix-session-save 2024-05-16 16:07:28 +05:30
pablohashescobar
b3ba55c1c0 dev: nginx configuration 2024-05-16 16:05:54 +05:30
sriram veeraghanta
fdc22b28c7 fix: adding save every request django session 2024-05-16 16:02:01 +05:30
pablohashescobar
2b8437714c dev: update session cookie age to environment variable 2024-05-16 14:13:31 +05:30
pablohashescobar
715ad1320c dev: fix session token save on admin and remove session save every request 2024-05-16 11:58:15 +05:30
5 changed files with 69 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
# Django imports
from django.contrib.auth import login
from django.conf import settings
# Module imports
from plane.authentication.utils.host import base_host
@@ -7,6 +8,11 @@ from plane.authentication.utils.host import base_host
def user_login(request, user, is_app=False, is_admin=False, is_space=False):
login(request=request, user=user)
# If is admin cookie set the custom age
if is_admin:
request.session.set_expiry(settings.ADMIN_SESSION_COOKIE_AGE)
device_info = {
"user_agent": request.META.get("HTTP_USER_AGENT", ""),
"ip_address": request.META.get("REMOTE_ADDR", ""),

View File

@@ -188,7 +188,7 @@ class MagicSignUpEndpoint(View):
return HttpResponseRedirect(url)
# Existing user
existing_user = User.objects.filter(email=email).first()
if not existing_user:
if existing_user:
exc = AuthenticationException(
error_code=AUTHENTICATION_ERROR_CODES["USER_ALREADY_EXIST"],
error_message="USER_ALREADY_EXIST",

View File

@@ -328,14 +328,14 @@ DATA_UPLOAD_MAX_MEMORY_SIZE = int(os.environ.get("FILE_SIZE_LIMIT", 5242880))
SESSION_COOKIE_SECURE = secure_origins
SESSION_COOKIE_HTTPONLY = True
SESSION_ENGINE = "plane.db.models.session"
SESSION_COOKIE_AGE = 604800
SESSION_COOKIE_AGE = os.environ.get("SESSION_COOKIE_AGE", 604800)
SESSION_COOKIE_NAME = "plane-session-id"
SESSION_COOKIE_DOMAIN = os.environ.get("COOKIE_DOMAIN", None)
SESSION_SAVE_EVERY_REQUEST = True
# Admin Cookie
ADMIN_SESSION_COOKIE_NAME = "plane-admin-session-id"
ADMIN_SESSION_COOKIE_AGE = 3600
ADMIN_SESSION_COOKIE_AGE = os.environ.get("ADMIN_SESSION_COOKIE_AGE", 3600)
# CSRF cookies
CSRF_COOKIE_SECURE = secure_origins

View File

@@ -18,37 +18,54 @@ http {
add_header X-Forwarded-Proto "${dollar}scheme";
add_header X-Forwarded-Host "${dollar}host";
add_header X-Forwarded-For "${dollar}proxy_add_x_forwarded_for";
add_header Host "${dollar}http_host";
add_header X-Real-IP "${dollar}remote_addr";
location / {
proxy_pass http://web:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://web:3000/;
}
location /god-mode/ {
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://admin:3001/god-mode/;
}
location /api/ {
proxy_set_header X-Forwarded-For "${dollar}proxy_add_x_forwarded_for";
proxy_set_header Host "${dollar}http_host";
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://api:8000/api/;
}
location /auth/ {
proxy_set_header X-Forwarded-For "${dollar}proxy_add_x_forwarded_for";
proxy_set_header Host "${dollar}http_host";
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://api:8000/auth/;
}
location /spaces/ {
rewrite ^/spaces/?$ /spaces/login break;
rewrite ^/spaces/?$ /spaces/login break;
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://space:3002/spaces/;
}
location /${BUCKET_NAME}/ {
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://plane-minio:9000/uploads/;
}
}

View File

@@ -18,34 +18,55 @@ http {
add_header X-Forwarded-Proto "${dollar}scheme";
add_header X-Forwarded-Host "${dollar}host";
add_header X-Forwarded-For "${dollar}proxy_add_x_forwarded_for";
add_header Host "${dollar}http_host";
add_header X-Real-IP "${dollar}remote_addr";
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://web:3000/;
}
location /api/ {
proxy_set_header X-Forwarded-For "${dollar}proxy_add_x_forwarded_for";
proxy_set_header Host "${dollar}http_host";
proxy_pass http://api:8000/api/;
}
location /spaces/ {
proxy_pass http://space:3000/spaces/;
}
location /god-mode/ {
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://admin:3000/god-mode/;
}
location /api/ {
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://api:8000/api/;
}
location /auth/ {
proxy_set_header X-Forwarded-For "${dollar}proxy_add_x_forwarded_for";
proxy_set_header Host "${dollar}http_host";
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://api:8000/auth/;
}
location /spaces/ {
rewrite ^/spaces/?$ /spaces/login break;
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://space:3000/spaces/;
}
location /${BUCKET_NAME}/ {
proxy_pass http://plane-minio:9000/${BUCKET_NAME}/;
proxy_http_version 1.1;
proxy_set_header Upgrade ${dollar}http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host ${dollar}http_host;
proxy_pass http://plane-minio:9000/uploads/;
}
}
}
}