Add access token scope checks to improve authorization #17
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 adds the ability for SMD to check for scopes and implements two related functions:
VerifyClaims
andVerifyScope
. It also moves dedicated OAuth functionality to a separate, dedicated file incmd/smd/auth.go
.The
VerifyClaims
function is needed to make sure that thescope
claim is included in the incoming access token. It can also be used later for checking for inclusion of other claims such aspartition-id
required for accessing specific resources.The
VerifyScope
function is used to check the incoming access token for specific scopes for each endpoint. Currently, this has only been implemented for/State/Components
and/Inventory/RedfishEndpoints
with each requiring thesmd_read
scope. Submitting a valid token without thesmd_read
scope will return the following error:However, for any other endpoint that is not checking for scopes, any valid access token is sufficient to use like before.