feat: allow configuring required token audience #109
Merged
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.
audclaim) for diode-to-netbox tokensetc
This pull request introduces support for validating token audiences in the NetBox Diode plugin. The changes ensure that authentication tokens can be checked against a configurable list of required audiences, enhancing security and compliance. Key updates include modifications to the plugin configuration, authentication logic, and unit tests.
Token Audience Validation
netbox_diode_plugin/__init__.py: Added a new configuration option,required_token_audience, which allows specifying a list of audiences that must be present in the authentication token.netbox_diode_plugin/api/authentication.py: Updated the_introspect_tokenmethod to validate the token's audience against therequired_token_audienceconfiguration, rejecting tokens missing required audiences.netbox_diode_plugin/plugin_config.py: Added theget_required_token_audiencefunction to retrieve therequired_token_audiencesetting from the plugin configuration.Unit Tests for Token Audience Validation
netbox_diode_plugin/tests/test_authentication.py: Enhanced test setup to mockget_required_token_audienceand added a new test,test_authenticate_token_with_required_audience, to verify that tokens are correctly authenticated based on their audience. [1] [2]