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

Encode Authorization requirements in Endpoint API #2592

Open
987Nabil opened this issue Jan 7, 2024 · 8 comments · May be fixed by #3266
Open

Encode Authorization requirements in Endpoint API #2592

987Nabil opened this issue Jan 7, 2024 · 8 comments · May be fixed by #3266
Labels
💎 Bounty enhancement New feature or request

Comments

@987Nabil
Copy link
Contributor

987Nabil commented Jan 7, 2024

Currently, we can require the authorization header in the endpoint API, but we do not know, if this is for example Basic Auth or Bearer Auth. This makes it impossible to generate auth schemas for OpenAPI for example.

Two possible solutions might be

  • Explicit auth schema on Endpoint
  • split the generic Authorization header codec into specific ones (HeaderCodec.basicAuth etc)
@987Nabil 987Nabil added the enhancement New feature or request label Jan 7, 2024
@987Nabil
Copy link
Contributor Author

987Nabil commented Jan 7, 2024

@jdegoes would you like to add some requirements?

@jdegoes
Copy link
Member

jdegoes commented Jan 18, 2024

I prefer to split the generic Authorization header codec into specific ones.

@jdegoes
Copy link
Member

jdegoes commented Jan 18, 2024

/bounty $100

Copy link

algora-pbc bot commented Jan 18, 2024

💎 $100 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #2592 with your implementation plan
  2. Submit work: Create a pull request including /claim #2592 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-http!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @mobley-trent Dec 31, 2024, 10:13:48 AM #3266

@hanneshauer
Copy link

hanneshauer commented Jan 20, 2024

OpenAPI 3.1 allows for using scopes even on Non-OAuth2-Security Schemes (example).

It would be great if zio-http allowed declaration of scopes on any Authorization type, and generation of matching OpenAPI-specs. Declaring permissions as types or values and expressing that one of potentially multiple allowed ones is required for an Endpoint would be very useful, and could allow for thorough authorization-testing of APIs.

While authorization would typically be handled by middleware, OpenAPI-generation probably can't be modified by that. I think having a way to (optionally) express authorization requirements on header inputs that can be retrieved both for API specs but also e.g. tests, with middleware being responsible for augmenting "raw" header inputs with appropriate permissions (by reading OAuth-scopes from a bearer token, matching Basic Auth-Information against a database, ...), would be an awesome way to encode security requirements in a zio-http-API. Security should be a first-class citizen of an API, like any other input like a path or request body.

@jdegoes
Copy link
Member

jdegoes commented Jan 20, 2024

@hanneshauer I like that idea. 👍

@mobley-trent
Copy link
Contributor

mobley-trent commented Dec 31, 2024

/attempt #2592

Algora profile Completed bounties Tech Active attempts Options
@mobley-trent    2 ZIO bounties
+ 10 bounties from 4 projects
Python, Rust,
Go & more
Cancel attempt

@mobley-trent mobley-trent linked a pull request Dec 31, 2024 that will close this issue
Copy link

algora-pbc bot commented Dec 31, 2024

💡 @mobley-trent submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants