feat: add API token authentication for REST API access#8402
Open
cnewkirk wants to merge 1 commit into
Open
Conversation
Contributor
|
This should be for: NMS-19642 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds API token authentication to OpenNMS Horizon, allowing users to generate long-lived bearer tokens as an alternative to basic auth for REST API access.
onms_prefix (enabling secret scanning), stored as SHA-256 hashes only — plaintext is shown once at creation and never retrievable againorg.opennms.api.tokens.max-expiry-days, default 365)/api/v2/apiTokens), web UI (self-service + admin pages), and Karaf shell commandslast_used_atis updated on successful authentication, debounced to avoid write amplificationChanges
features/api-tokens/— new Maven module (api, impl, shell submodules):ApiTokenentity,ApiTokenDao,ApiTokenService,ApiTokenServiceImpl, Karaf shell commandsfeatures/springframework-security/—ApiTokenAuthenticationFilteradded to all four REST<http>blocks via<custom-filter before="BASIC_AUTH_FILTER">opennms-webapp-rest/—ApiTokenRestServiceJAX-RS resource at/api/v2/apiTokensopennms-webapp/— self-service JSP (/account/selfService/apiTokens.jsp) and admin JSP (/admin/userGroupView/users/apiTokens.jsp)core/schema/— Liquibase changeset addingapi_tokenstablecontainer/features/—opennms-api-tokensKaraf feature definitionsmoke-test/—ApiTokenITcovering auth, lifecycle, admin ops, validation, and bulk revocationTest plan
ApiTokenServiceImplTest(9 tests),ApiTokenAuthenticationFilterTest(8 tests)ApiTokenIT— run with-Dsmoke -Dtest=ApiTokenIT