Django middleware when using msal for authentication

Viewed 32

I Have implemented oauth2 login for users in a django app using the msal library following this guide https://medium.com/@madhok.simran8/how-to-setup-azure-oauth-2-0-sso-in-django-with-microsoft-graph-api-d2639b8f7e36.

However Im not able to set the request.user variable right, which in turn means i cant check if request.user.is_authenticated.

I believe this should be solved using the proper middleware, but Im not sure how to set it up.

This is my current middleware:

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
0 Answers
Related