Improved and more secure API Key handling
Current Behavior
Each team gets an API key automatically. All API keys are visible for admins in the web interface (therefore must be stored somewhere in plaintext or only encrypted to be revertable).
Proposed Behavior
- By default a Team should not have API keys
- It shall be able to generate API keys by admins, ideally with an additional comment or name, to document the purpose
- API keys should not be visible in plain text except once after generation
- API keys should be stored as a secret with proper one-way hashing (basically it's a secret and must be handled like one!)
- We should consider improving the API key length or at least characters, not sure about best practices but most other systems I know use larger keys
- (Ideally) Creation Date and Last usage date should be shown next to the API key for the admin to be able to clear up
- Also consider #2543
Checklist
- [X] I have read and understand the contributing guidelines
- [X] I have checked the existing issues for whether this enhancement was already requested
I agree these improvements are welcome/needed, but probably should be moved to https://github.com/stevespringett/Alpine ?
If this is part of the alpine framework, then yes :D
Alpine doesn't automatically create API keys for teams, it's parametrized: https://github.com/stevespringett/Alpine/blob/master/alpine-infra/src/main/java/alpine/persistence/AlpineQueryManager.java#L559
Dependency-Track invokes the inherited AlpineQueryManager#createTeam method with the "true" parameter which generates the API key: https://github.com/DependencyTrack/dependency-track/blob/master/src/main/java/org/dependencytrack/resources/v1/TeamResource.java#L135
The simplest fix would be changing true to false.
@mprencipe That sounds like a sensible thing to do. Do you fancy raising a PR for this?
@rkg-mm:
- It shall be able to generate API keys by admins, ideally with an additional comment or name, to document the purpose
Comments to document the purpose is coming in v4.11, as per https://github.com/DependencyTrack/frontend/pull/768.
- (Ideally) Creation Date and Last usage date should be shown next to the API key for the admin to be able to clear up
Timestamps to track creation and "last used" timestamps are coming in v4.11, as per https://github.com/DependencyTrack/frontend/pull/768.
- Also consider https://github.com/DependencyTrack/dependency-track/issues/2543
This was shipped in v4.9.
Sure, I can raise a PR.