Skip to content

Conversation

@divarvel
Copy link
Contributor

@divarvel divarvel commented May 18, 2023

While biscuit-servant provides biscuit support in servant, not everybody uses servant (shocking, I know).

This middleware is based on the same ideas:

  • token extraction & parsing can be done for all endpoints in the same way
  • actual authorization usually has per-endpoint logic / depends on data extracted during routing, so will usually happen outside middleware
  • in some cases, authorization logic will be the same everywhere, so dedicated support should be provided to run the whole authorization process in a middleware.

Notes

Default configuration for both middlewares use the same error type, out of simplicity. it means that the default error type has an AuthorizationError branch even though it's not possible to reach it when only parsing is handled.

No post-processing of authorization results is possible, since the request extensions method is type-directed and requires a dedicated key shared by the middleware and its users. At that point, either writing a post-processing middleware or re-writing the middleware from scratch is simpler.

ToDo

  • token extraction & parsing
    • default behaviour (bearer token, single public key, default error messages)
    • custom behaviour (token extraction, public key selection, custom error handling)
  • complete authorization
  • find better names
  • documentation
  • support for optional biscuit (eg don’t fail if nothing is extracted, but still return errors if something invalid is extracted)
  • add initial changelog
  • add @since annotations

@divarvel divarvel mentioned this pull request Jul 5, 2023
70 tasks
@divarvel divarvel force-pushed the wai-middleware branch 2 times, most recently from b41933b to 94ffc8b Compare April 23, 2024 21:04
@divarvel divarvel force-pushed the wai-middleware branch 2 times, most recently from 6d3dbf1 to 851bcfa Compare June 24, 2025 08:01
@divarvel divarvel marked this pull request as ready for review June 24, 2025 20:10
@divarvel divarvel merged commit 91abccf into main Jul 7, 2025
5 checks passed
@divarvel divarvel deleted the wai-middleware branch July 7, 2025 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants