예제 #1
0
    def discovery_endpoint(self, request, handle=None, **kwargs):
        """
        :param request:
        :param handle:
        """

        _log_debug = logger.debug

        _log_debug("@discovery_endpoint")

        request = DiscoveryRequest().deserialize(request, "urlencoded")
        _log_debug("discovery_request:%s" % (request.to_dict(),))

        try:
            assert request["service"] == SWD_ISSUER
        except AssertionError:
            return BadRequest("Unsupported service")

        # verify that the principal is one of mine

        _response = DiscoveryResponse(locations=[self.baseurl])

        _log_debug("discovery_response:%s" % (_response.to_dict(),))

        headers = [("Cache-Control", "no-store")]
        (key, timestamp) = handle
        if key.startswith(STR) and key.endswith(STR):
            cookie = self.cookie_func(key, self.cookie_name, "disc",
                                      self.sso_ttl)
            headers.append(cookie)

        return Response(_response.to_json(), content="application/json",
                        headers=headers)
예제 #2
0
    def discovery_endpoint(self, request, handle=None, **kwargs):
        if isinstance(request, dict):
            request = DiscoveryRequest(**request)
        else:
            request = DiscoveryRequest().deserialize(request, "urlencoded")

        try:
            assert request["service"] == SWD_ISSUER
        except AssertionError:
            return BadRequest("Unsupported service")

        _response = DiscoveryResponse(locations=[self.baseurl])
        if self.signed_metadata_statements:
            _response.update(
                {'metadata_statements': self.signed_metadata_statements})

        headers = [("Cache-Control", "no-store")]

        return Response(_response.to_json(),
                        content="application/json",
                        headers=headers)
예제 #3
0
    def discovery_endpoint(self, environ, start_response, **kwargs):
        logger.debug("@discovery_endpoint")
        try:
            query = kwargs["query"]
        except KeyError:
            try:
                query = get_or_post(environ)
            except UnsupportedMethod:
                resp = BadRequest("Unsupported method")
                return resp(environ, start_response)

        request = DiscoveryRequest().deserialize(query, "urlencoded")
        logger.debug("discovery_request:%s" % (request.to_dict(),))

        try:
            assert request["service"] == SWD_ISSUER
        except AssertionError:
            resp = BadRequest("Unsupported service")
            return resp(environ, start_response)

        # verify that the principal is one of mine

        _response = DiscoveryResponse(locations=[self.baseurl])

        logger.debug("discovery_response:%s" % (_response.to_dict(),))

        headers=[("Cache-Control", "no-store")]
        (key, timestamp) = kwargs["handle"]
        if key.startswith(STR) and key.endswith(STR):
            cookie = self.cookie_func(self.cookie_name, key, self.seed,
                                      self.cookie_ttl)
            headers.append(cookie)

        resp = Response(_response.to_json(), content="application/json",
                        headers=headers)
        return resp(environ, start_response)