Commit 010c5943 authored by Florent Chehab's avatar Florent Chehab

WIP, a lot of stuff is broken

parent dc264b86
......@@ -54,8 +54,13 @@ class RexDriRequestMiddleware(MiddlewareMixin):
# User is authenticated
# We check if he / she has validated the CGU and the full RGPD
if not request.user.has_validated_cgu_rgpd:
if not path.startswith("cgu-rgpd"):
return HttpResponseRedirect("/cgu-rgpd/?next={}".format(full_path))
if not path.startswith(settings.BASE_URL_PATH + "cgu-rgpd"):
return HttpResponseRedirect(
settings.BASE_URL_PATH + "cgu-rgpd/?next={}".format(full_path)
)
# Handling of banned users
elif request.user.is_banned and full_path != "/banned_note/":
return HttpResponseRedirect("/banned_note/")
elif (
request.user.is_banned
and full_path != settings.BASE_URL_PATH + "banned_note/"
):
return HttpResponseRedirect(settings.BASE_URL_PATH + "banned_note/")
......@@ -13,3 +13,6 @@ CAS_SERVER_URL = "https://cas.utc.fr/cas/"
CAS_APPLY_ATTRIBUTES_TO_USER = True
# Mapping of the attribute
CAS_RENAME_ATTRIBUTES = {"mail": "email", "givenName": "first_name", "sn": "last_name"}
# Location of the website on the domain/sub domain
BASE_URL_PATH = "/rex-dri/"
......@@ -34,11 +34,11 @@ ROOT_URLCONF = "base_app.urls"
WSGI_APPLICATION = "base_app.wsgi.application"
STATIC_URL = "/static/"
STATIC_URL = BASE_URL_PATH + "static/"
STATIC_ROOT = normpath(join(BACKEND_ROOT_DIR, "static"))
MEDIA_URL = BASE_URL_PATH + "media/"
MEDIA_ROOT = normpath(join(BACKEND_ROOT_DIR, "media"))
MEDIA_URL = "/media/"
#
#
......@@ -178,14 +178,14 @@ AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation." "NumericPasswordValidator"},
]
LOGIN_URL = "/user/login"
RGPD_URL = "/rgpd-raw"
LOGIN_URL = BASE_URL_PATH + "user/login"
RGPD_URL = BASE_URL_PATH + "rgpd-raw"
LOGIN_EXEMPT_URLS = [LOGIN_URL, RGPD_URL]
if TESTING:
# In a testing environment we may want to by pass the loginRequiredMiddleware
LOGIN_EXEMPT_URLS.append("api")
LOGIN_EXEMPT_URLS.append("/admin/")
LOGIN_EXEMPT_URLS.append(BASE_URL_PATH + "api")
LOGIN_EXEMPT_URLS.append(BASE_URL_PATH + "admin/")
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
......
......@@ -10,11 +10,11 @@ from . import views
if settings.DEBUG:
import debug_toolbar
urlpatterns = [url(r"^__debug__/", include(debug_toolbar.urls))]
urlpatterns_tmp = [url(r"^__debug__/", include(debug_toolbar.urls))]
else:
urlpatterns = []
urlpatterns_tmp = []
urlpatterns += [
urlpatterns_tmp += [
url(r"^admin/", admin.site.urls),
url(r"^user/login$", django_cas_ng.views.LoginView.as_view(), name="cas_ng_login"),
url(
......@@ -33,3 +33,7 @@ urlpatterns += [
url(r"", include("backend_app.urls")),
url(r"^media/(?P<path>.*)", media_files_view, name="media"),
]
urlpatterns = [
url(r"^{}".format(settings.BASE_URL_PATH.lstrip("/")), include(urlpatterns_tmp))
]
......@@ -10,4 +10,3 @@ def show_toolbar(request) -> bool:
url = request.get_full_path()
return "/api/" in url or "__debug__" in url
return True
import {CURRENT_USER_ID} from "./user";
const base = "/app/",
export const WEBSITE_ROUTE_PATH = "/rex-dri/";
const base = `${WEBSITE_ROUTE_PATH}app/`,
map = base + "map/",
search = base + "search/",
university = base + "university/",
......
......@@ -5,10 +5,11 @@
import getCrudActionTypes from "./getCrudActionTypes";
import axiosLib from "axios";
import {RequestParams} from "./RequestParams";
import {WEBSITE_ROUTE_PATH} from "../../config/appRoutes";
/** base configuration of axios. */
const axios = axiosLib.create({
baseURL: "/api",
baseURL: `${WEBSITE_ROUTE_PATH}api`,
xsrfCookieName: "csrftoken",
xsrfHeaderName: "X-CSRFToken",
});
......
......@@ -10,7 +10,7 @@ server {
listen 80;
charset utf-8;
location / {
location /rex-dri {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment