def test_get_user(self): # no setting, default to uwnetid self.assertEquals(get_user(self.request), 'javerage') with self.settings(SAML_USER_ATTRIBUTE='uwnetid'): self.assertEquals(get_user(self.request), 'javerage') with self.settings(SAML_USER_ATTRIBUTE='eppn'): self.assertEquals(get_user(self.request), '*****@*****.**')
def process_response(self): """ Overrides the implementation method to store the SAML attributes and add the Django login. """ self._implementation.process_response() self._request.session['samlUserdata'] = self.get_attributes() self._request.session['samlNameId'] = self.get_nameid() self._request.session['samlSessionIndex'] = self.get_session_index() # Django login user = authenticate(self._request, remote_user=get_user(self._request)) login(self._request, user)
def test_get_user_without_saml(self): del self.request.session['samlUserdata'] self.assertEquals(get_user(self.request), None)
def test_get_user_without_uwnetid(self): self.request.session['samlUserdata'] = {} self.assertEquals(get_user(self.request), None)
def can_manage_external_tools(request): return Admin.objects.is_account_admin(get_user(request))
def can_manage_jobs(request): return Admin.objects.is_account_admin(get_user(request))
def can_manage_admin_group(request): return is_group_admin(settings.CANVAS_MANAGER_ADMIN_GROUP, get_user(request))
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['netid'] = get_user(self.request) context['ga_key'] = getattr(settings, "GA_KEY", None) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['netid'] = get_user(self.request) context['aat_env'] = settings.AAT_ENV return context