def dispatch(self, request, organization_slug): from sentry.auth.helper import AuthHelper helper = AuthHelper.get_for_request(request) # SP initiated authentication, request helper is provided if helper: from sentry.web.frontend.auth_provider_login import AuthProviderLoginView sso_login = AuthProviderLoginView() return sso_login.handle(request) # IdP initiated authentication. The organizatio_slug must be valid and # an auth provider must exist for this organization to proceed with # IdP initiated SAML auth. try: organization = Organization.objects.get(slug=organization_slug) except Organization.DoesNotExist: messages.add_message(request, messages.ERROR, ERR_NO_SAML_SSO) return self.redirect(reverse('sentry-login')) try: auth_provider = AuthProvider.objects.get(organization=organization) except AuthProvider.DoesNotExist: messages.add_message(request, messages.ERROR, ERR_NO_SAML_SSO) return self.redirect(reverse('sentry-login')) helper = AuthHelper( request=request, organization=organization, auth_provider=auth_provider, flow=AuthHelper.FLOW_LOGIN, ) helper.init_pipeline() return helper.current_step()
def dispatch(self, request, organization_slug): # NB: The 'auth' key is used in the helper in_auth_flow = request.session.get('auth', False) # SP initiated authentication if in_auth_flow: from sentry.web.frontend.auth_provider_login import AuthProviderLoginView sso_login = AuthProviderLoginView() return sso_login.handle(request) # IdP initiated authentication. Start from org login flow from sentry.web.frontend.auth_organization_login import AuthOrganizationLoginView # AuthOranizationLogin will init the login flow *only if* the ``init`` # parameter is set. request.POST = request.POST.copy() request.POST['init'] = True org_login = AuthOrganizationLoginView() return org_login.handle(request, organization_slug)