(models) make user and authentication work with Keycloak and admin

The admin was broken as we did not worry about it up to now. On the frontend
we want to use OIDC authentication only but for the admin, it is better if
the default authentication works as well. To allow this, we propose to add
an "email" field to the user model and make it the identifier in place of
the usual username. Some changes are necessary to make the "createsuperuser"
management command work.

We also had to fix the "oidc_user_getter" method to make it work with Keycloak.
Some tests were added to secure that everything works as expected.
This commit is contained in:
Samuel Paccoud - DINUM
2024-01-15 09:09:01 +01:00
committed by Anthony LC
parent e1688b923e
commit 8b026078bc
11 changed files with 194 additions and 37 deletions

View File

@@ -177,7 +177,7 @@ migrate: ## run django migrations for the people project.
superuser: ## Create an admin superuser with password "admin"
@echo "$(BOLD)Creating a Django superuser$(RESET)"
@$(MANAGE) createsuperuser --username admin --email admin@example.com --no-input
@$(MANAGE) createsuperuser --email admin@example.com --password admin
.PHONY: superuser
back-i18n-compile: ## compile the gettext files