whitenoise!

This commit is contained in:
2024-05-18 01:22:29 +02:00
parent 41bdd859d5
commit f2528af95e
3 changed files with 5 additions and 4 deletions

View File

@@ -16,7 +16,6 @@ from mozilla_django_oidc.contrib.drf import OIDCAuthentication
class CustomOIDCBackend(OIDCAuthenticationBackend):
def get_username(self, claims):
if 'preferred_username' in claims and not User.objects.filter(username=claims['preferred_username']).exists():
print(claims['preferred_username'])
return claims['preferred_username']
return super().get_username(claims)
@@ -32,7 +31,6 @@ class CustomOIDCBackend(OIDCAuthenticationBackend):
def get_userinfo(self, access_token, id_token, payload):
userinfo = cache.get(f'userinfo-{access_token}')
if userinfo is None:
print("no cache found for userinfo-{access_token} yet.")
userinfo = super().get_userinfo(access_token, id_token, payload)
if userinfo:
cache.set(f'userinfo-{access_token}', userinfo, timeout=settings.OIDC_CACHE_USERINFO)

View File

@@ -71,6 +71,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
@@ -166,8 +167,9 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_ROOT = 'static/'
STATIC_ROOT = BASE_DIR / 'static'
STATIC_URL = 'static/'
STATICFILES_STORAGE = "whitenoise.storage.CompressedStaticFilesStorage"
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

View File

@@ -11,4 +11,5 @@ inflection
django-esi
django-health-check
mozilla-django-oidc
django-cors-headers
django-cors-headers
whitenoise