You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
The context processor is evaluated on every request, and due the get_token() call it will reset the CSRF token over and over again. That disables pretty much all upstream caches such as CloudFlare or Cloudfront.
Plus the unnecessary cost of generating the authorisation URL. Let aside the needless HTTPS warnings when developing on a localhost.
Since these variables are only used on the login.html template, loading them only there using a template tag is the better choice. I've changed the setup this way:
Create a new template tag get_microsoft_auth_variables.
from django import template
from microsoft_auth.context_processors import microsoft
register = template.Library()
@register.simple_tag(takes_context=True)
def get_microsoft_auth_variables(context):
"""Adds template variables for microsoft_auth"""
context.update(microsoft(context["request"]))
return ''
Remove microsoft_auth.context_processors.microsoft from the context_processors list.
Add a new Login template by copying the one from msauth and adjust it:
The usage of a context processor to load variables into the login.html template is not the right place and has major disadvantages.
https://github.com/AngellusMortis/django_microsoft_auth/blob/master/microsoft_auth/context_processors.py#L51-L58
The context processor is evaluated on every request, and due the
get_token()
call it will reset the CSRF token over and over again. That disables pretty much all upstream caches such as CloudFlare or Cloudfront.Plus the unnecessary cost of generating the authorisation URL. Let aside the needless HTTPS warnings when developing on a localhost.
Since these variables are only used on the login.html template, loading them only there using a template tag is the better choice. I've changed the setup this way:
get_microsoft_auth_variables
.Remove
microsoft_auth.context_processors.microsoft
from the context_processors list.Add a new Login template by copying the one from msauth and adjust it:
Curious if I miss something here. Otherwise I'm happy to provide a PR with the necessary changes.
The text was updated successfully, but these errors were encountered: