示例#1
0
 def createLogoutRequest(self, session_index, name_id):
     now = saml2.utils.getDateAndTime(time.time())
     req = samlp.LogoutRequest(id=saml2.utils.createID(),
                               version=saml2.V2,
                               issue_instant=now)
     req.issuer = saml.Issuer(text=self.config.get('issuer_name'))
     req.name_id = name_id
     req.session_index = samlp.SessionIndex(text=session_index)
     req.signature = self._get_signature()
     return req
示例#2
0
def create_logout_request(subject_id,
                          destination,
                          issuer_entity_id,
                          req_entity_id,
                          sign=True):
    config = SPConfig()
    config.load(sp_config)
    sp_client = Saml2Client(config=config)
    # construct a request
    logout_request = samlp.LogoutRequest(id='a123456',
                                         version=VERSION,
                                         destination=destination,
                                         issuer=saml.Issuer(
                                             text=req_entity_id,
                                             format=saml.NAMEID_FORMAT_ENTITY),
                                         name_id=saml.NameID(text=subject_id))
    return logout_request
示例#3
0
    def construct_logout_request(self,
                                 subject_id,
                                 destination,
                                 issuer_entity_id,
                                 reason=None,
                                 expire=None):
        """ Constructs a LogoutRequest
        
        :param subject_id: The identifier of the subject
        :param destination:
        :param issuer_entity_id: The entity ID of the IdP the request is
            target at.
        :param reason: An indication of the reason for the logout, in the
            form of a URI reference.
        :param expire: The time at which the request expires,
            after which the recipient may discard the message.
        :return: A LogoutRequest instance
        """

        session_id = sid()
        # create NameID from subject_id
        name_id = saml.NameID(
            text=self.users.get_entityid(subject_id, issuer_entity_id, False))

        request = samlp.LogoutRequest(id=session_id,
                                      version=VERSION,
                                      issue_instant=instant(),
                                      destination=destination,
                                      issuer=self._issuer(),
                                      name_id=name_id)

        if reason:
            request.reason = reason

        if expire:
            request.not_on_or_after = expire

        return request
示例#4
0
 def setup_class(self):
     self.lr = samlp.LogoutRequest()