-
Notifications
You must be signed in to change notification settings - Fork 67
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
Basic auth middleware #238
Conversation
@Jerben I'm curious, do you have any authentication layer in Sihl? If so, would it be compatible with the changes in this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I look over the changes and have some comments about the example, but also how 'other' authentication methods are handled.
@tmattio At the moment, we have that in the projects themselves. Your approach looks good and we could definitely use the middleware as proposed, I especially like the configurable rock handler 👍 |
It looks good to me now. Thanks for implementing it! 🎉 |
Thanks for the reviews, appreciate it! I'll investigate further to support Bearer / other auth methods before I merge it: I'm not confident enough that the current implementation generalizes well 🙂 |
edb5eb5
to
c9d2c32
Compare
CHANGES: ## Added - New `Auth` module to work with `Authorization` header (rgrinberg/opium#238) - New `basic_auth` middleware to protect handlers with a `Basic` authentication method (rgrinberg/opium#238) - New `Response.of_file` API for conveniently creating a response of a file (rgrinberg/opium#244) - Add a package `opium-graphql` to easily create GraphQL server with Opium (rgrinberg/opium#235) - Add a function `App.run_multicore` that uses pre-forking and spawns multiple processes that will handle incoming requests (rgrinberg/opium#239) ## Fixed - Fix reading cookie values when multiple cookies are present in `Cookie` header (rgrinberg/opium#246)
This PR adds a
basic_auth
middleware to protect handlers with an authentication mechanism.It also adds an
Auth
module with functions to encode/decodeAuthorization
header values.The
basic_auth
middleware has typeI believe it is flexible enough and will allow users to build their own authentication logic, without having to deal with the boilerplate logic.
TODO
Auth
moduleBearer
, and maybe cookie?