mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2024-12-25 06:22:20 +00:00
Use a custom Matrix username
This commit is contained in:
parent
2ead8cdad5
commit
642ac94b7a
@ -15,6 +15,11 @@ RUN pip install -r requirements.txt psycopg2-binary sympasoap --no-cache-dir
|
|||||||
|
|
||||||
COPY . /code/
|
COPY . /code/
|
||||||
|
|
||||||
|
RUN python manage.py collectstatic --noinput && \
|
||||||
|
python manage.py compilemessages && \
|
||||||
|
python manage.py migrate && \
|
||||||
|
python manage.py loaddata initial
|
||||||
|
|
||||||
# Configure nginx
|
# Configure nginx
|
||||||
RUN mkdir /run/nginx
|
RUN mkdir /run/nginx
|
||||||
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
|
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
|
||||||
|
14
apps/registration/auth.py
Normal file
14
apps/registration/auth.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from cas_server.auth import DjangoAuthUser
|
||||||
|
from django.utils.text import slugify
|
||||||
|
|
||||||
|
|
||||||
|
class CustomAuthUser(DjangoAuthUser):
|
||||||
|
"""
|
||||||
|
Override Django Auth User model to define a custom Matrix username.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def attributs(self):
|
||||||
|
d = super().attributs()
|
||||||
|
if self.user:
|
||||||
|
d["matrix_username"] = slugify(str(self.user.registration))
|
||||||
|
return d
|
17
apps/registration/fixtures/initial.json
Normal file
17
apps/registration/fixtures/initial.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"model": "cas_server.servicepattern",
|
||||||
|
"pk": 1,
|
||||||
|
"fields": {
|
||||||
|
"pos": 100,
|
||||||
|
"name": "Plateforme des Correspondances",
|
||||||
|
"pattern": "^https://correspondances-maths.fr:8448/.*$",
|
||||||
|
"user_field": "matrix_username",
|
||||||
|
"restrict_users": false,
|
||||||
|
"proxy": true,
|
||||||
|
"proxy_callback": true,
|
||||||
|
"single_log_out": true,
|
||||||
|
"single_log_out_callback": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -131,6 +131,8 @@ PASSWORD_HASHERS = [
|
|||||||
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
CAS_AUTH_CLASS = 'registration.auth.CustomAuthUser'
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
'DEFAULT_PERMISSION_CLASSES': [
|
||||||
'rest_framework.permissions.IsAdminUser'
|
'rest_framework.permissions.IsAdminUser'
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
crond -l 0
|
crond -l 0
|
||||||
|
|
||||||
python manage.py compilemessages
|
|
||||||
python manage.py migrate
|
|
||||||
|
|
||||||
nginx
|
nginx
|
||||||
|
|
||||||
if [ "$CORRES2MATH_STAGE" = "prod" ]; then
|
if [ "$CORRES2MATH_STAGE" = "prod" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user