This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## main #3133 +/- ##
==========================================
- Coverage 29.97% 29.63% -0.34%
==========================================
Files 327 331 +4
Lines 38816 38773 -43
==========================================
- Hits 11634 11492 -142
- Misses 27182 27281 +99
|
Passes check-pr. |
tevoinea
reviewed
May 29, 2023
tevoinea
reviewed
May 29, 2023
tevoinea
approved these changes
May 29, 2023
chkeita
reviewed
May 30, 2023
chkeita
reviewed
May 30, 2023
chkeita
approved these changes
May 30, 2023
tevoinea
approved these changes
May 31, 2023
Did some manual validation after check-pr. All looks good. |
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2098.
This cleans up the authentication a bit; after this change we have two stages in the middleware pipeline:
AuthenticationMiddleware
reads the JWT token (it does not validate it, this is done by the Azure Functions service) and stores it inFunctionContext.Items["ONEFUZZ_USER_INFO"]
AuthorizationMiddleware
checks the user info against the[Authorize]
attribute to see if the user has the required permissionsFunctionContext
if neededThe authorize attribute can be
[Authorize(Allow.User)]
orAllow.Agent
orAllow.Admin
. TheAdmin
case is new and allows this to be declaratively specified rather than being checked in code. We have several functions which could be changed to use this (e.g. Pool POST/DELETE/PATCH, Scaleset POST/DELETE/PATCH), but I have only changed one so far (JinjaToScriban).One of the benefits here is that this simplifies the test code a lot: we can set the desired user info directly onto our
(Test)FunctionContext
rather than having to supply a fake that pretends to parse the token from the HTTP request. This will also have benefits when running the service locally for testing purposes (refer to internal issue).The other benefit is the ability to programmatically read the required authentication for each function, which may help with Swagger generation.