tower-rs / tower-http

HTTP specific Tower utilities.
675 stars 156 forks source link

Allow multiple valid bearer keys for ValidateRequestHeaderLayer #485

Open ifsheldon opened 4 months ago

ifsheldon commented 4 months ago

Feature Request

Motivation

I found tower_http::validate_request::ValidateRequestHeaderLayer::bearer very convenient, but it's a bit too simplistic. I am thinking maybe we can have a layer that checks a lookup table that is dynamically changing, which should cover most of the use cases.

Proposal

I think we can let developers pass a closure which checks if a bearer token passed in the closure is valid or not, this should give them max flexibility.

Alternatives

Or, we can allow them to pass an object that impl a new trait.