def discharge(ctx, content, key, locator, checker): '''Handles a discharge request as received by the /discharge endpoint. @param ctx The context passed to the checker {checkers.AuthContext} @param content URL and form parameters {dict} @param locator Locator used to add third party caveats returned by the checker {macaroonbakery.ThirdPartyLocator} @param checker {macaroonbakery.ThirdPartyCaveatChecker} Used to check third party caveats. @return The discharge macaroon {macaroonbakery.Macaroon} ''' id = content.get('id') if id is None: id = content.get('id64') if id is not None: id = utils.b64decode(id) caveat = content.get('caveat64') if caveat is not None: caveat = utils.b64decode(caveat) return bakery.discharge( ctx, id=id, caveat=caveat, key=key, checker=checker, locator=locator, )
def discharge(self, ctx, cav, payload): return bakery.discharge( ctx, key=self._key, id=cav.caveat_id, caveat=payload, checker=self._checker, locator=self._locator, )
def get_discharge(cav, payload): return bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, third_party.oven.key, common.ThirdPartyStrcmpChecker('something'), third_party.oven.locator, )
def get_discharge(cav, payload): return bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, third_party.oven.key, ThirdPartyCaveatCheckerF(), third_party.oven.locator, )
def get_discharge(cav, payload): oven = bakeries[cav.location].oven return bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, oven.key, ThirdPartyCaveatCheckerF(cav.location), oven.locator, )
def get_discharge(cav, payload): self.assertEqual(cav.location, 'bs-loc') return bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, bs.oven.key, common.ThirdPartyStrcmpChecker('user==bob'), bs.oven.locator, )
def get_discharge(cav, payload): self.assertEqual(cav.location, 'bs-loc') return bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, bs.oven.key, common.ThirdPartyStrcmpChecker('user==bob'), bs.oven.locator, )
def get_discharge(cav, payload): m = bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, third_party.oven.key, common.ThirdPartyStrcmpChecker('true'), third_party.oven.locator, ) M.unbound = m.macaroon.copy() return m
def get_discharge(ctx, cav, payload): checker = common.ThirdPartyCheckerWithCaveats([ checkers.declared_caveat('foo', 'a'), checkers.declared_caveat('arble', 'b'), ]) # Sneaky client adds a first party caveat. m = macaroonbakery.discharge(ctx, cav.caveat_id_bytes, payload, third_party.oven.key, checker, third_party.oven.locator) m.add_caveat(checkers.declared_caveat('foo', 'c'), None, None) return m
def get_discharge(cav, payload): checker = common.ThirdPartyCheckerWithCaveats([ checkers.declared_caveat('foo', 'a'), checkers.declared_caveat('arble', 'b') ]) return bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, third_party.oven.key, checker, third_party.oven.locator, )
def get_discharge(cav, payload): # Make sure that the caveat id really is old-style. try: cav.caveat_id_bytes.decode('utf-8') except UnicodeDecodeError: self.fail('caveat id is not utf-8') return bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, bs.oven.key, common.ThirdPartyStrcmpChecker('something'), bs.oven.locator, )
def get_discharge(cav, payload): checker = common.ThirdPartyCheckerWithCaveats([ checkers.declared_caveat('foo', 'a'), checkers.declared_caveat('arble', 'b'), ]) # Sneaky client adds a first party caveat. m = bakery.discharge( common.test_context, cav.caveat_id_bytes, payload, third_party.oven.key, checker, third_party.oven.locator, ) m.add_caveat(checkers.declared_caveat('foo', 'c'), None, None) return m
def wait(url, request): class EmptyChecker(bakery.ThirdPartyCaveatChecker): def check_third_party_caveat(self, ctx, info): return [] if InfoStorage.info is None: self.fail('visit url has not been visited') m = bakery.discharge( checkers.AuthContext(), InfoStorage.info.id, InfoStorage.info.caveat, discharge_key, EmptyChecker(), _DischargerLocator(), ) return {'status_code': 200, 'content': {'Macaroon': m.to_dict()}}
def get_discharge(cav, payload): return bakery.discharge( common.test_context, cav.caveat_id, payload, bakeries[cav.location].oven.key, ThirdPartyCaveatCheckerF(), locator)
def get_discharge(ctx, cav, payload): return macaroonbakery.discharge( ctx, cav.caveat_id_bytes, payload, third_party.oven.key, common.ThirdPartyStrcmpChecker('something'), third_party.oven.locator)
def get_discharge(ctx, cav, payload): return macaroonbakery.discharge(ctx, cav.caveat_id_bytes, payload, third_party.oven.key, ThirdPartyCaveatCheckerF(), third_party.oven.locator)
def get_discharge(ctx, cav, payload): oven = bakeries[cav.location].oven return macaroonbakery.discharge( ctx, cav.caveat_id_bytes, payload, oven.key, ThirdPartyCaveatCheckerF(cav.location), oven.locator)
def get_discharge(ctx, cav, payload): return macaroonbakery.discharge(ctx, cav.caveat_id, payload, bakeries[cav.location].oven.key, ThirdPartyCaveatCheckerF(), locator)
def get_discharge(cav, payload): return bakery.discharge(common.test_context, cav.caveat_id, payload, bakeries[cav.location].oven.key, ThirdPartyCaveatCheckerF(), locator)