Use a Tower Buffer service/layer to verify the crate handles inner
service readyness correctly as the buffer service will panic when being
called if it's not ready
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
Cloning the inner service to use in call can mean a not-ready clone gets
used which violates the tower service preconditions. Replace the cloned
service with the ready service to ensure the right copy gets used. See
https://docs.rs/tower/0.4.13/tower/trait.Service.html#be-careful-when-cloning-inner-services
for more details
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
As tonic support is optional also run cargo test with all features
enabled such that the tonic support gets tested
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
Add an integration tests for tonic in such a way that it avoids having
to create a build.rs with tonic code generation; As such it hand-codes
some parts of the tonic service implementation which is normally
code-generated. This also simply tests successfull and failed auth
without validating other authorization functionality as that's not
different between usage in tonic and axum
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
Tonic and Axum are quite closely related; From a tower perspective the
main difference is in the Error type in the body for their Response.
This refactor the code a little bit and add conversions from AuthError
to a tonic's Response such that the exact same code can be used by both
Axum and tonic services
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
- JwtSource:Bearer renamed to AuthorizationHeader for more consistency with jwt terminology
- documentation added
- the token cookie should be taken from request not from the tower-cookies middleware jar
- dependency on tower-cookies is no longer needed
- tests added
* feat: working but naive implementation of named cookie as jwt source
* refactor: add with_jwt_source to JwtAuthorizer. Make Bearer default
* fix: fix the demo-server. Remove JWTSource
* refactor: rename with_jwt_source() -> jwt_source()