rpcperms: set CustomCaveatCondition on middleware req

This sets the `CustomCaveatCondition` value on rpc middleware requests
if one exists. Previously, this value was always blank even if the
macaroon had a value set for its custom caveat condition.
This commit is contained in:
Daniel McNally
2022-01-21 09:40:46 -05:00
parent a4474447c2
commit 4a573b18cf
3 changed files with 40 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.