(request, domain_obj)
return True
Checks whether a given request is allowed to view a domain.

    :param request: HttpRequest
    :param domain_obj: Domain object
    :return: Boolean (True if request is blocked)
Checks whether a given request is allowed to view a domain.
Checks whether a given request is allowed to view a domain .
def is_request_blocked_from_viewing_domain_due_to_sso(request, domain_obj):
    """
    Checks whether a given request is allowed to view a domain.

    :param request: HttpRequest
    :param domain_obj: Domain object
    :return: Boolean (True if request is blocked)
    """
    if not is_request_using_sso(request):
        # Request is not using SSO, so it's never blocked
        return False

    username = request.user.username
    idp = IdentityProvider.get_active_identity_provider_by_username(username)
    if not idp:
        raise SingleSignOnError(
            f"User {username} was authenticated via SSO, but does not appear "
            f"to be associated with an Identity Provider!"
        )

    if idp.does_domain_trust_this_idp(domain_obj.name):
        return False

    if domain_obj.creating_user == username:
        # The user created this domain and thus should never be blocked.
        # However, a Trust was not yet established. Since the current user
        # owns this domain, a Trust will be created automatically and a message
        # will be displayed to the user.
        if idp.create_trust_with_domain(domain_obj.name, request.user.username):
            messages.success(
                request,
                get_success_message_for_trusted_idp(idp, domain_obj)
            )
        return False

    # None of the above criteria was met so the user is definitely blocked!
    return True
def is_request_blocked_from_viewing_domain_due_to_sso ( request , domain_obj ) : if not is_request_using_sso ( request ) : # Request is not using SSO, so it's never blocked return False username = request . user . username idp = IdentityProvider . get_active_identity_provider_by_username ( username ) if not idp : raise SingleSignOnError ( f"User {username} was authenticated via SSO, but does not appear " f"to be associated with an Identity Provider!" ) if idp . does_domain_trust_this_idp ( domain_obj . name ) : return False if domain_obj . creating_user == username : # The user created this domain and thus should never be blocked. # However, a Trust was not yet established. Since the current user # owns this domain, a Trust will be created automatically and a message # will be displayed to the user. if idp . create_trust_with_domain ( domain_obj . name , request . user . username ) : messages . success ( request , get_success_message_for_trusted_idp ( idp , domain_obj ) ) return False # None of the above criteria was met so the user is definitely blocked! return True