Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a WAI middleware #81

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Provide a WAI middleware #81

wants to merge 6 commits into from

Conversation

divarvel
Copy link
Collaborator

@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
  • add initial changelog
  • add @since annotations

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.

1 participant