def rpt_endpoint_(self, requestor, client_id, **kwargs): """ The endpoint URI at which the client asks the authorization server for a RPT. """ #res = self.client_authentication(authn) #if isinstance(res, Response): # return res # create RPT, just overwrites whatever was there before rpt = rndstr(32) self.rpt[rpt] = {"requestor": requestor, "client_id": client_id} self.session.set(rpt) msg = RPTResponse(rpt=rpt) return Response(msg.to_json(), content="application/json")
def get_rpt(self, user): authn = "Bearer %s" % self.client.token[user]["AAT"]["access_token"] pre_trace("C-->AS", "*get_rpt", authn=authn) resp = self.srv.rpt_endpoint(authn) rtr = RPTResponse().from_json(resp.message) self.client.token[user]["RPT"] = rtr["rpt"] post_trace("C<--AS", RPT=self.client.token[user]["RPT"])
def get_rpt(self, user): kwargs = self.create_rpt_request(user) url = self.provider_info["rpt_endpoint"] resp = self.send(url, "POST", **kwargs) if resp.status_code == 200: rptr = RPTResponse().from_json(resp.text) self.token[user]["RPT"] = rptr["rpt"] else: raise UMAError(resp.reason)
def get_rpt(self, user): authn = "Bearer %s" % self.client.token[user]["AAT"]["access_token"] self.trace.append(trace("*get_rpt", "C-->AS", authn_info=authn)) resp = self.rpt_endpoint(authn) rtr = RPTResponse().from_json(resp.message) self.client.token[user]["RPT"] = rtr["rpt"] self.trace.append( trace("*get_rpt", "C<--AS", data={"RPT": self.client.token[user]["RPT"]}))
authn = "Basic {}".format( b64e_enc_dec( "{}:{}".format(_uma_client.client_id, _uma_client.client_secret), "ascii", "ascii")) rqp_claims = b64e_enc_dec(json.dumps({"uid": REQUESTOR}), "utf-8", "ascii") request = RPTRequest( grant_type=RQP_CLAIMS_GRANT_TYPE, ticket=ticket, claim_tokens=[ClaimToken(format="json", token=rqp_claims)]) resp = authzsrv.rpt_token_endpoint(authn=authn, request=request.to_json()) rtr = RPTResponse().from_json(resp.message) _uma_client.token[REQUESTOR] = {} _uma_client.token[REQUESTOR]["RPT"] = rtr["rpt"] # Introspection of the RPT pat = ressrv.rs_handler.token['PAT'] _rpt = _uma_client.token[REQUESTOR]["RPT"] ir = IntrospectionRequest(token=_rpt) request_args = {"access_token": pat} ht_args = ressrv.client.client_authn_method["bearer_header"](ressrv).construct( ir, request_args=request_args) resp = authzsrv.introspection_endpoint(ir.to_json(), ht_args["headers"]["Authorization"])