Newer
Older
else:
messages.add_message(request, messages.INFO,
_("No authentication token has previously been set."))
form = AuthenticationTokenForm()
return render(request, "generic-form.html", {
"form_description": _("Manage Git Authentication Token"),
"form": form
})
# }}}
# {{{ SAML auth backend
# This ticks the 'verified' boxes once we've receive attribute assertions
# through SAML2.
class Saml2Backend(Saml2BackendBase):
def _set_attribute(self, obj, attr, value):
mod = super(Saml2Backend, self)._set_attribute(obj, attr, value)
if attr == "institutional_id":
if not obj.institutional_id_verified:
obj.institutional_id_verified = True
mod = True
if attr in ["first_name", "last_name"]:
if not obj.name_verified:
obj.name_verified = True
mod = True
if attr == "email":
from course.constants import user_status
if obj.status != user_status.active:
obj.status = user_status.active
mod = True
return mod
# }}}
Dong Zhuang
committed
def sign_out_confirmation(request, redirect_field_name=REDIRECT_FIELD_NAME):
redirect_to = request.POST.get(redirect_field_name,
request.GET.get(redirect_field_name, ''))
next_uri = ""
if redirect_to:
next_uri = "?%s=%s" % (redirect_field_name, redirect_to)
return render(request, "sign-out-confirmation.html",
{"next_uri": next_uri})
Dong Zhuang
committed
def sign_out(request, redirect_field_name=REDIRECT_FIELD_NAME):
Dong Zhuang
committed
redirect_to = request.POST.get(redirect_field_name,
request.GET.get(redirect_field_name, ''))
if settings.RELATE_SIGN_IN_BY_SAML2_ENABLED:
from djangosaml2.views import _get_subject_id, logout as saml2_logout
if _get_subject_id(request.session) is not None:
response = saml2_logout(request)
auth_logout(request)
Dong Zhuang
committed
elif redirect_to:
return redirect(redirect_to)