public static IPipelineBuilder <MessageEnvelope <T> > RequiresAllClaims <T>( this IPipelineBuilder <MessageEnvelope <T> > builder, params Claim[] claims) => builder.Pipe(next => (message, ct) => { if (!claims.All(claim => message.Subject.HasClaim(claim.Type, claim.Value))) { throw new AuthorizationFailedException(message.Subject); } return(next(message, ct)); });
public static IPipelineBuilder <T> Log <T>(this IPipelineBuilder <T> builder) => builder.Pipe(next => async(message, ct) => { Serilog.Log.Information(message.ToString()); try { await next(message, ct); } catch (Exception ex) { Serilog.Log.Error(ex, "Error"); throw; } });