async def _redirect_to_next_new_user_step( self, auth_provider_id: str, remote_user_id: str, attributes: UserAttributes, client_redirect_url: str, next_step_url: bytes, extra_login_attributes: Optional[JsonDict], ) -> NoReturn: """Creates a UsernameMappingSession and redirects the browser Called if the user mapping provider doesn't return complete information for a new user. Raises a RedirectException which redirects the browser to a specified URL. Args: auth_provider_id: A unique identifier for this SSO provider, e.g. "oidc" or "saml". remote_user_id: The unique identifier from the SSO provider. attributes: the user attributes returned by the user mapping provider. client_redirect_url: The redirect URL passed in by the client, which we will eventually redirect back to. next_step_url: The URL to redirect to for the next step of the new user flow. extra_login_attributes: An optional dictionary of extra attributes to be provided to the client in the login response. Raises: RedirectException """ # TODO: If needed, allow using/looking up an existing session here. session_id = random_string(16) now = self._clock.time_msec() session = UsernameMappingSession( auth_provider_id=auth_provider_id, remote_user_id=remote_user_id, display_name=attributes.display_name, emails=attributes.emails, client_redirect_url=client_redirect_url, expiry_time_ms=now + self._MAPPING_SESSION_VALIDITY_PERIOD_MS, extra_login_attributes=extra_login_attributes, # Treat the localpart returned by the user mapping provider as though # it was chosen by the user. If it's None, it must be chosen eventually. chosen_localpart=attributes.localpart, # TODO: Consider letting the user mapping provider specify defaults for # other user-chosen attributes. ) self._username_mapping_sessions[session_id] = session logger.info("Recorded registration session id %s", session_id) # Set the cookie and redirect to the next step e = RedirectException(next_step_url) e.cookies.append( b"%s=%s; path=/" % (USERNAME_MAPPING_SESSION_COOKIE_NAME, session_id.encode("ascii"))) raise e
async def _redirect_to_username_picker( self, auth_provider_id: str, remote_user_id: str, attributes: UserAttributes, client_redirect_url: str, extra_login_attributes: Optional[JsonDict], ) -> NoReturn: """Creates a UsernameMappingSession and redirects the browser Called if the user mapping provider doesn't return a localpart for a new user. Raises a RedirectException which redirects the browser to the username picker. Args: auth_provider_id: A unique identifier for this SSO provider, e.g. "oidc" or "saml". remote_user_id: The unique identifier from the SSO provider. attributes: the user attributes returned by the user mapping provider. client_redirect_url: The redirect URL passed in by the client, which we will eventually redirect back to. extra_login_attributes: An optional dictionary of extra attributes to be provided to the client in the login response. Raises: RedirectException """ session_id = random_string(16) now = self._clock.time_msec() session = UsernameMappingSession( auth_provider_id=auth_provider_id, remote_user_id=remote_user_id, display_name=attributes.display_name, emails=attributes.emails, client_redirect_url=client_redirect_url, expiry_time_ms=now + self._MAPPING_SESSION_VALIDITY_PERIOD_MS, extra_login_attributes=extra_login_attributes, ) self._username_mapping_sessions[session_id] = session logger.info("Recorded registration session id %s", session_id) # Set the cookie and redirect to the username picker e = RedirectException( b"/_synapse/client/pick_username/account_details") e.cookies.append( b"%s=%s; path=/" % (USERNAME_MAPPING_SESSION_COOKIE_NAME, session_id.encode("ascii"))) raise e
async def callback(request: SynapseRequest, **kwargs: object) -> NoReturn: e = RedirectException(b"/no/over/there", 304) e.cookies.append(b"session=yespls") raise e
async def callback(request: SynapseRequest, **kwargs: object) -> None: raise RedirectException(b"/look/an/eagle", 301)
def callback(request, **kwargs): e = RedirectException(b"/no/over/there", 304) e.cookies.append(b"session=yespls") raise e
def callback(request, **kwargs): raise RedirectException(b"/look/an/eagle", 301)
def saml_response_to_user_attributes(self, saml_response, failures, client_redirect_url): raise RedirectException(b"https://custom-saml-redirect/")