def verify(self, request, **kwargs): """ Verifies that the given username and password was correct :param request: Either the query part of a URL a urlencoded body of a HTTP message or a parse such. :param kwargs: Catch whatever else is sent. :return: redirect back to where ever the base applications wants the user after authentication. """ logger.debug("verify(%s)" % request) if isinstance(request, basestring): _dict = parse_qs(request) elif isinstance(request, dict): _dict = request else: raise ValueError("Wrong type of input") logger.debug("dict: %s" % _dict) logger.debug("passwd: %s" % self.passwd) # verify username and password try: self._verify(_dict["password"][0], _dict["login"][0]) timestamp = str(int(time.mktime(time.gmtime()))) info = self.aes.encrypt("::".join([_dict["login"][0], timestamp])) self.active[info] = timestamp cookie = make_cookie(self.cookie_name, info, self.srv.seed) return_to = create_return_url(self.return_to, _dict["query"][0], **{self.query_param: "true"}) resp = Redirect(return_to, headers=[cookie]) except (AssertionError, KeyError): resp = Unauthorized("Unknown user or wrong password") return resp
def verify(self, request, **kwargs): """ Verifies that the given username and password was correct :param request: Either the query part of a URL a urlencoded body of a HTTP message or a parse such. :param kwargs: Catch whatever else is sent. :return: redirect back to where ever the base applications wants the user after authentication. """ #logger.debug("verify(%s)" % request) if isinstance(request, six.string_types): _dict = parse_qs(request) elif isinstance(request, dict): _dict = request else: raise ValueError("Wrong type of input") # verify username and password try: self._verify(_dict["password"][0], _dict["login"][0]) timestamp = str(int(time.mktime(time.gmtime()))) msg = "::".join([_dict["login"][0], timestamp]) info = self.symmetric.encrypt(msg.encode()) self.active[info] = timestamp cookie = make_cookie(self.cookie_name, info, self.srv.seed) return_to = create_return_url(self.return_to, _dict["query"][0], **{self.query_param: "true"}) resp = Redirect(return_to, headers=[cookie]) except (ValueError, KeyError): resp = Unauthorized("Unknown user or wrong password") return resp
def authn_context(environ, start_response): query = parse_qs(environ["QUERY_STRING"]) _cntxt = query["AuthnContext"][0] _sso = SSO(SP, environ, start_response, cache=CACHE, discosrv=ARGS["discosrv"], accr=_cntxt) resp = _sso.do() # Add cookie kaka = make_cookie("ac_disco", _cntxt, "SEED_SAW") resp.headers.append(kaka) return resp(environ, start_response)
def disco(environ, start_response): query = parse_qs(environ["QUERY_STRING"]) entity_id = query["entityID"][0] came_from = "/user_info" _sso = SSO(SP, environ, start_response, cache=CACHE) resp = _sso._redirect_to_auth(_sso.sp, entity_id, came_from) # Add cookie kaka = make_cookie("ve_disco", entity_id, "SEED_SAW") resp.headers.append(kaka) return resp(environ, start_response)
def disco(environ, start_response, _sp): query = parse_qs(environ["QUERY_STRING"]) entity_id = query["entityID"][0] _sid = query["sid"][0] came_from = CACHE.outstanding_queries[_sid] _sso = SSO(_sp, environ, start_response, cache=CACHE, **ARGS) resp = _sso.redirect_to_auth(_sso.sp, entity_id, came_from) # Add cookie kaka = make_cookie("ve_disco", entity_id, "SEED_SAW") resp.headers.append(kaka) return resp(environ, start_response)
def disco(environ, start_response): query = parse_qs(environ["QUERY_STRING"]) entity_id = query["entityID"][0] sid = query["sid"][0] came_from = CACHE.outstanding_queries[sid] kwargs = SESSIONDB[sid] kwargs.update(ARGS) _sso = SSO(SP, environ, start_response, cache=CACHE, **kwargs) resp = _sso._redirect_to_auth(_sso.sp, entity_id, came_from, dont_send=True) # Add cookie kaka = make_cookie("ve_disco", entity_id, "SEED_SAW") resp.headers.append(kaka) return resp(environ, start_response)