Skip to content

Conversation

@ltucker
Copy link
Contributor

@ltucker ltucker commented Jun 9, 2025

  • Adds a setting to specify a required token audience (JWT aud claim) for diode-to-netbox tokens
  • Defaults to nothing particular required

etc

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_token method to validate the token's audience against the required_token_audience configuration, rejecting tokens missing required audiences.
  • netbox_diode_plugin/plugin_config.py: Added the get_required_token_audience function to retrieve the required_token_audience setting from the plugin configuration.

Unit Tests for Token Audience Validation

@ltucker ltucker marked this pull request as draft June 9, 2025 22:14
@github-actions github-actions bot added the python label Jun 9, 2025
@github-actions
Copy link

github-actions bot commented Jun 9, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
3255 2906 89% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
netbox_diode_plugin/init.py 100% 🟢
netbox_diode_plugin/api/authentication.py 96% 🟢
netbox_diode_plugin/plugin_config.py 67% 🟢
netbox_diode_plugin/tests/test_authentication.py 99% 🟢
TOTAL 91% 🟢

updated for commit: 77b2446 by action🐍

Co-authored-by: Michal Fiedorowicz <mfiedorowicz@netboxlabs.com>
@ltucker ltucker marked this pull request as ready for review June 11, 2025 01:13
@ltucker ltucker changed the title WIP feat: allow configuring required token audience feat: allow configuring required token audience Jun 11, 2025
@ltucker ltucker merged commit e472807 into develop Jun 11, 2025
6 checks passed
@ltucker ltucker deleted the token_audience branch June 11, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants