Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
73ed68a
* UPGRADE Django to v4.2.16
Badatos Oct 24, 2024
e50187e
Merge branch 'develop' into pod_V4
Badatos Oct 28, 2024
7e4cd06
* Remove USE_L10N deprecated param
Badatos Oct 28, 2024
af15471
Remove `USE_L10N` from test_settings
Badatos Oct 28, 2024
7c01d4b
Merge branch 'develop' into pod_V4
Badatos Oct 29, 2024
a721a03
* Correct video_edit slect2 display with tagulous (remove duplicated …
Badatos Oct 29, 2024
4deb722
* Remove Python 3.8 from compatible py versions, and add 3.12
Badatos Oct 30, 2024
b2975a6
Merge branch 'develop' into pod_V4
Badatos Oct 30, 2024
645b930
Upgrade dependencies
Badatos Oct 30, 2024
7c5d362
several corrections for 4.0. Prepare to say goodbye to CKEditor
Badatos Nov 13, 2024
917a006
correct video/models.py
Badatos Nov 13, 2024
9a4ab7f
Remove Compatibility with ES 6
Badatos Nov 21, 2024
097edab
Replace js_asset by django.templatetags.static, as js_asset is deprec…
Badatos Nov 21, 2024
151af7c
Fix code scanning alert no. 81: URL redirection from remote source
Badatos Nov 21, 2024
ccfebc3
Improve security in pod playlists, as suggested by CodeQL
Badatos Nov 21, 2024
5941015
Disable some video_tags functions
Badatos Nov 21, 2024
bf7dc21
Flake8 compliance
Badatos Nov 21, 2024
cb32056
Disable Debug in test_settings
Badatos Nov 21, 2024
c9de8e1
only add debug toolbar when not in testing mode
Badatos Nov 21, 2024
d28b3dc
Add title_en to sample videos.json
Badatos Nov 21, 2024
6bd0164
Reset ES-INDEX for tests as "Pod"
Badatos Nov 21, 2024
3c17c09
Use Elasticsearch 7 in github workflows
Badatos Nov 21, 2024
b54952b
set Video tags as "not required" + correct bug on video tags indexing
Badatos Nov 21, 2024
fd9fbaa
Adapt Video views and video-info to Tagulous
Badatos Nov 25, 2024
bf5cabd
adapt video get_json_to_index() function to Tagulous
Badatos Nov 25, 2024
92ac5b2
Adapt Video Recorder to Tagulous
Badatos Nov 25, 2024
cecec76
Only do dressing tests when `USE_DRESSING==True
Badatos Nov 25, 2024
f7d1a21
* Only run `cut` tests when `USE_CUT==True`
Badatos Nov 25, 2024
44a9a5b
Merge branch 'develop' into pod_V4
Badatos Nov 28, 2024
dfd0662
+ Upgrade all py packages
Badatos Dec 2, 2024
14c3457
Drop compatibility with ES 7
Badatos Dec 2, 2024
ff15569
Upgrade importlib-metadata to 7.2.1 for compatibility with ralph-malp…
Badatos Dec 2, 2024
e6ed3f7
replace "order" by "date_added" in channel video sorting
Badatos Dec 3, 2024
abd6cdc
Display a tag cloud with tags assigned to videos
Badatos Dec 3, 2024
4698507
apply GH actions "pod_dev" and "code_formatting" on pod_V4 branch
Badatos Dec 3, 2024
2501b45
Fixup. Format code with Prettier
invalid-email-address Dec 3, 2024
a18ea13
Fixup. Format code with Black
invalid-email-address Dec 3, 2024
76e6191
Auto-update configuration files
invalid-email-address Dec 3, 2024
7b58f99
Merge branch 'main' into pod_V4
Badatos Dec 4, 2024
c2d1011
Bump ELASTICSEARCH_TAG to 8.16.1
Badatos Dec 4, 2024
b5fc92a
Change elastic-github-actions to master to avoid ES 8 issue
Badatos Dec 4, 2024
92fa056
Set ES_VERSION=8 in settings_local_docker
Badatos Dec 5, 2024
4853cdd
Fixup. Format code with Black
invalid-email-address Dec 5, 2024
12d0c3f
test ES with CURL after create_pod_index
Badatos Dec 5, 2024
e62575b
Merge branch 'pod_V4' of https://github.com/EsupPortail/Esup-Pod into…
Badatos Dec 5, 2024
68d7f5f
test with es1:9200 url
Badatos Dec 5, 2024
3216702
Return to elasticsearch.localhost url
Badatos Dec 5, 2024
6eeedd4
add --insecure to curl command
Badatos Dec 5, 2024
8cfc848
Disable elastic-github-actions security
Badatos Dec 9, 2024
50c5437
replace https by http in curl
Badatos Dec 9, 2024
7343fa0
increase sqlite timeout in test settings to have less "sqlite3.Operat…
Badatos Dec 9, 2024
5115cb4
Replace `assertNotEquals`by `assertNotEqual`for Python 3.12 compatibi…
Badatos Dec 9, 2024
2f928f9
Replace remaining assertEquals by assertEqual
Badatos Dec 9, 2024
ec9addf
Bump Django to 4.2.17 (fix 2 CVE, see https://docs.djangoproject.com/…
Badatos Dec 9, 2024
241712f
Replace unmaintained django-cas-client by django-cas-ng
Badatos Jan 9, 2025
c80323a
* Add pod_affiliation_handler() func to set staff status to CAS user …
Badatos Jan 9, 2025
06301b5
Flake8 compliance + Black formatting
Badatos Jan 9, 2025
bd764a4
Replace `CAS_RESPONSE_CALLBACKS` by `cas_user_authenticated_callback
Badatos Jan 17, 2025
e91aa1a
Remove typing for compatibility with Python 3.9
Badatos Jan 17, 2025
4dfae61
Force `CAS_APPLY_ATTRIBUTES_TO_USER` to True when `POPULATE_USER==CAS`
Badatos Jan 17, 2025
e91fea4
Bump Django to 4.2.18
Badatos Jan 17, 2025
6ab6f93
Merge branch 'pod_V4' into replace_cas
Badatos Jan 17, 2025
385937a
Set CAS_APPLY_ATTRIBUTES_TO_USER to True in settings
Badatos Jan 17, 2025
1b02e4f
Merge branch 'main' into pod_V4
Badatos Jan 24, 2025
31aae7a
Merge branch 'pod_V4' into replace_cas
Badatos Jan 31, 2025
5359641
Update backends.py
FBrosset Feb 3, 2025
3c0a15b
Update CONFIGURATION_FR.md
FBrosset Feb 3, 2025
ab86186
Update CONFIGURATION_EN.md
FBrosset Feb 3, 2025
1c16298
Update configuration.json
FBrosset Feb 3, 2025
17fce3f
Update test_populated.py
FBrosset Feb 3, 2025
e2df422
Update backends.py
FBrosset Feb 4, 2025
79bd664
Update test_populated.py
FBrosset Feb 4, 2025
10fa81b
correct some bugs after unit testing with @Fbrosset
Badatos Feb 4, 2025
e62bb86
Correct test_populated to test presence of group from OIDC_DEFAULT_AF…
Badatos Feb 5, 2025
a7bac5b
Add english translations for configs
Badatos Feb 6, 2025
ebcc0d2
Merge branch 'main' into replace_cas
Badatos Feb 10, 2025
2d6f6b0
Cleanup merge artifacts
Badatos Feb 10, 2025
3a014b9
Merge branch 'main' into replace_cas
Badatos Feb 13, 2025
4df1dd2
Merge branch 'replace_cas' into replace_cas_fbrosset
Badatos Feb 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/pod_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- name: cat env
run: cat .env.dev

- name: make Build container
- name: Build containers
run: |
sudo rm -rf ./pod/log
sudo rm -rf ./pod/static
Expand All @@ -105,29 +105,29 @@ jobs:
with:
time: '60s'

- name: show running container
- name: Show running containers
run: |
docker ps
echo "🍏 Docker is UP ${{ job.status }}."
docker exec pod-back-with-volumes ps auxf
docker exec pod-back-with-volumes python manage.py loaddata pod/video/fixtures/sample_videos.json

- name: run test in docker
- name: Run test_remote_encode_transcode in docker
run: docker exec pod-back-with-volumes coverage run --append manage.py test -v 3 --keepdb pod.video_encode_transcript.tests.test_remote_encode_transcode

- name: Run pa11y-ci full
- name: Run pa11y-ci
run: docker exec pa11y-ci pa11y-ci -c /usr/src/app/dockerfile-dev-with-volumes/pa11y-ci/config.json

- name: Run pa11y-ci mobile
run: docker exec pa11y-ci pa11y-ci -c /usr/src/app/dockerfile-dev-with-volumes/pa11y-ci/config_mobile.json

- name: show pa11y results
- name: Show pa11y results
run: cat pa11y-results.json

- name: Stop containers
if: always()
run: docker compose -f ./docker-compose-full-dev-with-volumes-test.yml down
- name: delete unused file and change owner
- name: Delete unused file and change owner
run: |
sudo rm -f pod/custom/settings_local.py
sudo chown -R runner:runner .
Expand Down
3 changes: 3 additions & 0 deletions CONFIGURATION_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ Set `USE_AI_ENHANCEMENT` to True to activate this application.<br>
* `OIDC_DEFAULT_AFFILIATION`
> default value: ``
>>
* `OIDC_DEFAULT_AFFILIATION`
> valeur par défaut : ``
>> Affiliation par défaut d’un utilisateur authentifié par OIDC.<br>
* `OIDC_NAME`
> default value: ``
>>
Expand Down
4 changes: 4 additions & 0 deletions CONFIGURATION_FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,10 @@ Mettre `USE_AI_ENHANCEMENT` à True pour activer cette application.<br>
> valeur par défaut : `preferred_username`
>> Noms des Claim permettant de récupérer<br>
>> l’attribut login mais dépendant de l’attribut du client dans l’IDP.<br>
* `OIDC_CLAIM_AFFILIATION`
> valeur par défaut : `affiliations`
>> Noms des Claim permettant de récupérer<br>
>> l’attribut affiliations.<br>
* `OIDC_CLAIM_GIVEN_NAME`
> valeur par défaut : `given_name`
>> Noms des Claim permettant de récupérer les attributs nom, prénom, email<br>
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ lang:
echo "Processing javascript files..."
python3 manage.py makemessages -d djangojs -l fr -l nl -i "*.min.js" -i "pod/static/*" -i "opencast-studio/*" -i "*/node_modules/*" -i "node_modules/*" -i "pod/custom/*" --add-location=file

#compilation des fichiers de langue
# Compilation des fichiers de langue
compilelang:
python3 manage.py compilemessages -l fr -l nl

# Suppression des sessions inutilisées
clearsessions:
python3 manage.py clearsessions
python3 manage.py django_cas_ng_clean_sessions

# Look for changes to apply in DB
updatedb:
python3 manage.py makemigrations
Expand Down
5 changes: 5 additions & 0 deletions pod/authentication/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


def create_groupsite_if_not_exists(g) -> None:
"""Create a GroupSite if it does not exist."""
from pod.authentication.models import GroupSite

try:
Expand All @@ -16,6 +17,7 @@ def create_groupsite_if_not_exists(g) -> None:


def set_default_site(sender, **kwargs) -> None:
"""Set the default site for all groups and owners."""
from pod.authentication.models import Owner
from django.contrib.sites.models import Site
from django.contrib.auth.models import Group
Expand All @@ -34,9 +36,12 @@ def set_default_site(sender, **kwargs) -> None:


class AuthConfig(AppConfig):
"""Authentication configuration."""

name = "pod.authentication"
default_auto_field = "django.db.models.BigAutoField"
verbose_name = _("Authentication")

def ready(self) -> None:
"""Called after the Django app registry is ready."""
post_migrate.connect(set_default_site, sender=self)
73 changes: 55 additions & 18 deletions pod/authentication/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.core.exceptions import ObjectDoesNotExist

import logging
from pod.authentication.models import AccessGroup, DEFAULT_AFFILIATION, AFFILIATION_STAFF
from django.contrib.sites.models import Site

logger = logging.getLogger(__name__)
User = get_user_model()

CREATE_GROUP_FROM_AFFILIATION = getattr(settings, "CREATE_GROUP_FROM_AFFILIATION", False)
Expand Down Expand Up @@ -76,9 +78,8 @@ def update_owner_params(user, params) -> None:
OIDC_DEFAULT_AFFILIATION = getattr(
settings, "OIDC_DEFAULT_AFFILIATION", DEFAULT_AFFILIATION
)
OIDC_DEFAULT_ACCESS_GROUP_CODE_NAMES = getattr(
settings, "OIDC_DEFAULT_ACCESS_GROUP_CODE_NAMES", []
)

OIDC_CLAIM_AFFILIATION = getattr(settings, "OIDC_CLAIM_AFFILIATION", "affiliations")


class OIDCBackend(OIDCAuthenticationBackend):
Expand All @@ -87,32 +88,68 @@ class OIDCBackend(OIDCAuthenticationBackend):
def create_user(self, claims):
"""Create user connectd by OIDC."""
user = super(OIDCBackend, self).create_user(claims)

user.first_name = claims.get(OIDC_CLAIM_GIVEN_NAME, "")
user.last_name = claims.get(OIDC_CLAIM_FAMILY_NAME, "")
user.username = claims.get(OIDC_CLAIM_PREFERRED_USERNAME, "")
user.owner.affiliation = OIDC_DEFAULT_AFFILIATION
for code_name in OIDC_DEFAULT_ACCESS_GROUP_CODE_NAMES:
try:
user.owner.accessgroup_set.add(
AccessGroup.objects.get(code_name=code_name)
)
except ObjectDoesNotExist:
pass
user.is_staff = is_staff_affiliation(affiliation=user.owner.affiliation)
self._initialize_user(user, claims)
user.is_staff = is_staff_affiliation(user.owner.affiliation)
user.owner.save()
user.save()

return user

def update_user(self, user, claims):
"""Update OIDC user."""
user.first_name = claims.get(OIDC_CLAIM_GIVEN_NAME, "")
user.last_name = claims.get(OIDC_CLAIM_FAMILY_NAME, "")
user.username = claims.get(OIDC_CLAIM_PREFERRED_USERNAME, "")
user.owner.accessgroup_set.clear()
self._assign_affiliations(user, claims)
user.is_staff = is_staff_affiliation(user.owner.affiliation)

user.save()

user.owner.auth_type = "OIDC"
user.owner.save()

return user

def _initialize_user(self, user, claims):
"""Initialize user object from OIDC claims."""
user.first_name = claims.get(OIDC_CLAIM_GIVEN_NAME, "")
user.last_name = claims.get(OIDC_CLAIM_FAMILY_NAME, "")
user.username = claims.get(OIDC_CLAIM_PREFERRED_USERNAME, "")
self._assign_affiliations(user, claims)
return user

def _assign_affiliations(self, user, claims) -> None:
"""Assign affiliations and access groups to user."""
affiliations = claims.get(OIDC_CLAIM_AFFILIATION, [OIDC_DEFAULT_AFFILIATION])

for affiliation in affiliations:
self._add_access_group(user, affiliation)

OIDC_DEFAULT_ACCESS_GROUP_CODE_NAMES = getattr(
settings, "OIDC_DEFAULT_ACCESS_GROUP_CODE_NAMES", []
)

# Add default access groups
for code_name in OIDC_DEFAULT_ACCESS_GROUP_CODE_NAMES:
self._safe_assign_access_group(user, code_name)

user.owner.affiliation = (
affiliations[0] if affiliations else OIDC_DEFAULT_AFFILIATION
)

def _add_access_group(self, user, affiliation) -> None:
"""Create or retrieve access group and assign to user."""
accessgroup, created = AccessGroup.objects.get_or_create(code_name=affiliation)
if created:
accessgroup.display_name = affiliation
accessgroup.auto_sync = True
accessgroup.sites.add(Site.objects.get_current())
accessgroup.save()
user.owner.accessgroup_set.add(accessgroup)

def _safe_assign_access_group(self, user, code_name) -> None:
"""Safely add an access group if it exists."""
try:
user.owner.accessgroup_set.add(AccessGroup.objects.get(code_name=code_name))
except ObjectDoesNotExist:
pass
Loading