chore(api): Only check CAS Backend status on needed endpoints #2420
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.
This PR splits the
CheckOrgRequirement
middleware in two.Middleware changes
ValidateCASBackend
: Middleware in charge of checking the organization has configured a valid CAS backend and the credentials work. It does not block if the status of the middleware is invalid.BlockIfCASBackendNotValid
: Checks the default middleware in the organization is valid and blocks the request if is not valid.This give us flexibility since there are some endpoints where we still want to check the status of the CAS backend without blocking the request if they are not valid and others where we want to directly block the request because they are needed.
Endpoint scope changes
BlockIfCASBackendNotValid
applies to only the following endpoints:API token handling
The middleware branch for API token authentication has also been updated. It now includes
ValidateCASBackend
andBlockIfCASBackendNotValid
only when the operation requires a CAS backend. For example, with a failing CAS backend:Others
GetUploadCreds
: It will run the validation on the CAS Backend of the workflow associated instead the default CAS Backend (it could have changed since att init was done)Init
,Store
: We cannot store even an attestation that is empty, so we validate them in those cases as well.