コード例 #1
0
ファイル: client.go プロジェクト: frankban/macaroon-bakery
// CheckRequestM is like CheckRequest except that on success it also returns
// the set of macaroons that was successfully checked.
// The "M" suffix is for backward compatibility reasons - in a
// later bakery version, the signature of CheckRequest will be
// changed to return the macaroon slice and CheckRequestM will be
// removed.
func CheckRequestM(svc *bakery.Service, req *http.Request, assert map[string]string, checker checkers.Checker) (map[string]string, macaroon.Slice, error) {
	mss := RequestMacaroons(req)
	if len(mss) == 0 {
		return nil, nil, &bakery.VerificationError{
			Reason: errgo.Newf("no macaroon cookies in request"),
		}
	}
	checker = checkers.New(
		checker,
		Checkers(req),
		checkers.TimeBefore,
	)
	attrs, ms, err := svc.CheckAnyM(mss, assert, checker)
	if err != nil {
		return nil, nil, errgo.Mask(err, isVerificationError)
	}
	return attrs, ms, nil
}