Merge pull request #6185 from sangaman/rpc-middleware-custom-caveat

rpcperms: set CustomCaveatCondition on middleware req
This commit is contained in:
Olaoluwa Osuntokun
2022-01-24 15:45:49 -08:00
committed by GitHub
5 changed files with 84 additions and 6 deletions

View File

@@ -910,7 +910,7 @@ func (r *InterceptorChain) middlewareRegistered() bool {
// acceptRequest sends an intercept request to all middlewares that have
// registered for it. This means either a middleware has requested read-only
// access or the request actually has a macaroon which a caveat the middleware
// access or the request actually has a macaroon with a caveat the middleware
// registered for.
func (r *InterceptorChain) acceptRequest(requestID uint64,
msg *InterceptionRequest) error {
@@ -929,6 +929,10 @@ func (r *InterceptorChain) acceptRequest(requestID uint64,
continue
}
msg.CustomCaveatCondition = macaroons.GetCustomCaveatCondition(
msg.Macaroon, middleware.customCaveatName,
)
resp, err := middleware.intercept(requestID, msg)
// Error during interception itself.
@@ -975,6 +979,10 @@ func (r *InterceptorChain) interceptResponse(ctx context.Context,
continue
}
msg.CustomCaveatCondition = macaroons.GetCustomCaveatCondition(
msg.Macaroon, middleware.customCaveatName,
)
resp, err := middleware.intercept(requestID, msg)
// Error during interception itself.