Skip to content

Feature/feat datset 14 invenio rdm credentials - #1499

Open
sven1103 wants to merge 18 commits into
developmentfrom
feature/feat-datset-14-invenio-rdm-credentials
Open

Feature/feat datset 14 invenio rdm credentials#1499
sven1103 wants to merge 18 commits into
developmentfrom
feature/feat-datset-14-invenio-rdm-credentials

Conversation

@sven1103

Copy link
Copy Markdown
Contributor

Description

Issue and Traceability

Linked Task Issue

  • Closes: #

Requirement IDs Addressed

  • Requirement IDs:

Requirement Update Status

  • Requirements Updated: The corresponding functional/non-functional requirements in docs/requirements.md have been updated to reflect this implementation.
  • Justification Provided: This PR does not change externally observable behavior, so no requirement update is needed. (Provide brief justification below)

Justification (if applicable)

Changes Summary

Modified Areas

  • Domain layer (domain/model/, domain events, aggregates)
  • Application layer (application/ services, use cases)
  • Infrastructure layer (JPA repositories, external integrations, config)
  • UI / Views (views/ components, Vaadin routes)
  • Database schema (sql/, DDL changes)
  • Tests (unit, integration, or Spock specs)
  • Documentation, CI/CD, or build configuration
  • Other (describe):

Behavioral Changes

  • No behavioral changes (internal refactoring, optimization, test addition, etc.)
  • Yes, behavior changes:

Sensitive Changes Requiring Review

  • Database schema changes (sql/complete-schema.sql, table/column DDL)
  • Spring Security configuration (security/, ACL setup, authentication/authorization)
  • FAIR / RO-Crate export format (docs/fair/, RO-Crate builder logic)
  • Artemis messaging topics (JMS topic names, consumer configuration)
  • Requirement file edits (docs/requirements.md)
  • None of the above

Pre-Submission Checklist

  • Issue Linked: PR references a Task issue (see "Linked Task Issue" section above)
  • Requirements Listed: All functional (R) and non-functional (NFR) requirement IDs are listed above
  • No Constraint IDs: No C (constraint) IDs are listed in the Requirement IDs section
  • Behavior vs. Requirements: Requirement update confirmed OR explicit justification provided
  • Code Style: Code follows Google Java Style Guide (run formatter before commit)
  • Tests: New tests added or existing tests updated to cover changes
  • No Secrets: No hardcoded credentials, API keys, passwords, or secrets committed
  • Documentation: Updated relevant docs if the change affects user-facing behavior or public APIs

Notes for Reviewers

sven1103 and others added 18 commits July 29, 2026 11:47
Implement Checkpoints 1-9 of the implementation plan:

Database & Config:
- New user_external_credential table (source-agnostic, per user/instance)
- Vault config property for dedicated AES-256 master key alias

Encryption (ADR-0002 S2):
- CredentialEncryptor port (application layer)
- AesGcmCredentialEncryptor impl (infrastructure, AES/GCM/NoPadding)
- Per-token random 12-byte nonce, 128-bit GCM tag
- 10 unit tests covering roundtrip, nonce uniqueness, wrong key, etc.

Domain model:
- UserExternalCredential entity (JPA + domain, same-class convention)
- CredentialStatus enum (VALID / INVALIDATED)
- UserExternalCredentialRepository port
- Spring Data JPA repo + repository impl

Validation layer (composite dispatcher pattern):
- ExternalCredentialValidator port (application layer)
- CredentialValidatorAdapter interface (infrastructure, per-provider)
- InvenioRdmCredentialValidatorAdapter (GET /api/users, per OpenAPI spec)
- SourceTypeDispatchingCredentialValidator (routes by SourceType)
- CredentialValidationException

Client enhancements:
- InvenioRdmClient.getAuthenticatedUser() (new endpoint)
- InvenioRdmClient.search()/getRecord() (auth-header overloads)
- SourceInstanceDescriptor now carries sourceType

Application service:
- ExternalCredentialService interface + DefaultExternalCredentialService
- Sealed AddCredentialResult (Success/InvalidToken/ServiceError/UnknownInstance)
- Token zeroed in finally block after add

DatasetSource adapter:
- InvenioRdmDatasetSource now resolves per-user tokens for authenticated
  search/resolve (decryption boundary ADR-0002 D1 enforced)

Spring wiring:
- InvenioRdmConfiguration registers all new beans
- Dispatcher configured for INVENIO_RDM (extensible for future providers)

All 263 existing tests still pass (0 failures, 0 errors).
Implement Checkpoint 10 of the implementation plan:
- Route: /external-providers (alongside /profile and /personal-access-token)
- Layout: heading + benefit text (AC-6), list of configured instances, Add/Remove buttons
- Add Token dialog: PasswordField input with no echo, validate-then-save flow
- Token field is cleared on dialog close (no stale secrets in component state)
- Status indicators: green check for connected, red X for not configured
- Help link to standard InvenioRDM token settings page
- Toast notifications for success, invalid token, transient errors
- Error messages are generic (no upstream details leaked)
- Token zeroed by the service; field cleared on close
…lidation

- AesGcmCredentialEncryptor now validates that the master key material is exactly 32 bytes (AES-256) and rejects AES-128/AES-192 keys at construction time
- InvenioRdmConfiguration reads vault entry as Base64-encoded string, decodes, and validates the decoded length is exactly 32 bytes before constructing the SecretKey
- Vault provisioning instructions updated to document Base64 encoding requirement (e.g., openssl rand -base64 32)
- Implementation plan and migration guides updated to reflect new key handling requirements
- Checklist updated to include key size validation checkpoints

This fixes the provisioning issue where the previous 32-byte raw string requirement was not well-supported
- Redesign External Providers page with card-based layout
  - Colored left border accents (green/gray/red)
  - Top-right action buttons (Connect/Disconnect)
  - Provider home page links
  - Configured date display

- Add verification sidebar (right slide-in drawer)
  - Verify all tokens in parallel
  - Skip providers without tokens (not connected state)
  - Real-time status updates (Valid/Invalid/Error)
  - Inline Reconnect action for invalid tokens
  - Refreshes on close to sync with main view

- Add manual token validation to domain layer
  - validateCredential() decrypts stored token and validates
  - Updates credential status to VALID or INVALIDATED per ADR-0002
  - Only explicit user action triggers validation (no silent updates)

- Handle invalidated credentials gracefully
  - Invalidated cards show two-button recovery: [Reconnect] [Disconnect]
  - Sidebar marks invalid tokens red with reason and Reconnect link
  - Successful reconnection from either surface refreshes both views

- Fix provider URL rendering (use base-url field, not display name parsing)
- Add toolbar with global 'Verify connections' button
- Add security reassurance text and page padding
@sven1103
sven1103 requested a review from a team as a code owner August 10, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants