You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds POST /api/v1/authorize/password so an administrator can change their own password when AUTH_SECRET_BACKEND=keyring.
Scope
Route: registered only for standalone keyring auth (SecretBackend=keyring, Disabled=false, no OIDC ClientID). It requires an authenticated session.
Validation: correct current password, newPassword equal to confirmPassword, and the shared policy pkg/secrets.IsStrongAdminPassword (at least 8 characters with a lowercase letter, an uppercase letter, a digit and a symbol; the CLI uses the same rule). Reusing the current password is rejected.
Storage: the new password is saved as a PBKDF2-HMAC-SHA256 hash in the device-management-toolkit keyring service.
Session revocation: in keyring mode, login reads the username and hash from the keyring, and each token carries a cred claim (an HMAC of the stored hash, keyed with the JWT key). Every protected request checks it against the hash currently in the keyring. A password change stores a new hash, so every earlier session is rejected, including the one that made the change, across clients and restarts. No extra state or files are stored.
API contract: OpenAPI and the Postman collection (console_mps_apis) are updated.
Unchanged
Config backend, AUTH_DISABLED, OIDC: the route is not registered, login reads credentials exactly as before, and JWT claims stay {exp} only. TestOtherBackendsKeepOriginalBehavior covers this.
JWT signing key: storage and lifecycle are the same as before.
Testing notes
Prerequisites: Console built from this branch, AUTH_SECRET_BACKEND=keyring, and administrator credentials already in the keyring. -k is only needed for the default self-signed certificate. jq is used to build the JSON.
Check that the keyring holds a hash, not the password (Linux):
secret-tool lookup service device-management-toolkit username admin-password-hash # starts with $pbkdf2-sha256$
Check that other modes are unchanged: restart with AUTH_SECRET_BACKEND=config.
POST /api/v1/authorize/password returns 404.
The login JWT payload (cut -d. -f2 <<<"$TOKEN" | base64 -d) contains only exp.
Unit tests:
go test -race -count=1 ./internal/controller/httpapi/... ./internal/controller/openapi ./pkg/secrets ./cmd/app
Validation
gofumpt -extra, go vet ./..., go test -race -count=1 ./... and golangci-lint with the CI config all pass.
E2E against a real gnome-keyring passed: change 200, wrong current 401, old token rejected immediately and after restart, only the new password logs in. Config mode was unchanged.
❌ Patch coverage is 83.90805% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.16%. Comparing base (5748beb) to head (e149975).
Adds a keyring-only administrator password-change endpoint to Console’s standalone authentication flow, providing backend support for the workflow in #1356. Config-backed password changes remain out of scope.
Changes:
Adds password-change request/response types and a route with current-password, confirmation, and strength checks.
Shares administrator password-policy validation between startup and password changes.
Adds handler, password-policy, and OpenAPI contract tests.
Test password-change rejection paths and in-memory credential updates
internal/controller/httpapi/v1/login.go:119
The endpoint tests cover deployment guards and a successful keyring write, but not missing fields, weak passwords, confirmation mismatches, wrong current passwords, password reuse, or failed keyring writes. Add rejection tests that check the status and verify both stored and in-memory credentials remain unchanged. Extend the success test to verify that login rejects the old password and accepts the new one; the hash-only assertion misses a broken in-memory update.
Report keyring read failures as storage errors, not invalid credentials
internal/controller/httpapi/v1/login.go:146
If the OS keyring is locked or unavailable, both credential-read paths return 401 and report incorrect credentials even when the current password is correct. Handle username and password-hash read errors as storage failures (500) with availability/unlock guidance, and reserve 401 for a successfully read hash that fails verification.
Add POST /api/v1/authorize/password for AUTH_SECRET_BACKEND=keyring:
- Registered only for standalone keyring auth. The config backend,
AUTH_DISABLED and OIDC keep their existing routes, login, and token
claims.
- Verifies the current password and confirmation, applies the shared
admin password policy (pkg/secrets.IsStrongAdminPassword, also used
by the CLI), rejects reuse, and stores a PBKDF2 hash in the keyring.
- Keyring mode reads credentials from the keyring on login, and tokens
carry an HMAC tag of the stored hash that is checked on each
protected request. A password change replaces the hash, so every
earlier session is revoked, including across restarts, without any
extra state.
- OpenAPI and Postman updated.
Related: #1356
Signed-off-by: Nabendu Maiti <nabendu.bikash.maiti@intel.com>
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
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
POST /api/v1/authorize/passwordso an administrator can change their own password whenAUTH_SECRET_BACKEND=keyring.Scope
SecretBackend=keyring,Disabled=false, no OIDCClientID). It requires an authenticated session.newPasswordequal toconfirmPassword, and the shared policypkg/secrets.IsStrongAdminPassword(at least 8 characters with a lowercase letter, an uppercase letter, a digit and a symbol; the CLI uses the same rule). Reusing the current password is rejected.device-management-toolkitkeyring service.credclaim (an HMAC of the stored hash, keyed with the JWT key). Every protected request checks it against the hash currently in the keyring. A password change stores a new hash, so every earlier session is rejected, including the one that made the change, across clients and restarts. No extra state or files are stored.console_mps_apis) are updated.Unchanged
AUTH_DISABLED, OIDC: the route is not registered, login reads credentials exactly as before, and JWT claims stay{exp}only.TestOtherBackendsKeepOriginalBehaviorcovers this.Testing notes
Prerequisites: Console built from this branch,
AUTH_SECRET_BACKEND=keyring, and administrator credentials already in the keyring.-kis only needed for the default self-signed certificate.jqis used to build the JSON.printf '%s\n' "$P" weak weak | changeprintf '%s\n' "$P" "$N" "${N}x" | changeprintf '%s\n' 'Wrong-Pass-1!' "$N" "$N" | changeprintf '%s\n' "$P" "$P" "$P" | changeAuthorizationheaderprintf '%s\n' "$P" "$N" "$N" | change{"message":"password changed"}curl -sk -o /dev/null -w '%{http_code}\n' "$BASE/api/v1/devices" -H "Authorization: Bearer $TOKEN"Afterwards:
unset P N TOKEN.Check that the keyring holds a hash, not the password (Linux):
secret-tool lookup service device-management-toolkit username admin-password-hash # starts with $pbkdf2-sha256$Check that other modes are unchanged: restart with
AUTH_SECRET_BACKEND=config.POST /api/v1/authorize/passwordreturns 404.cut -d. -f2 <<<"$TOKEN" | base64 -d) contains onlyexp.Unit tests:
go test -race -count=1 ./internal/controller/httpapi/... ./internal/controller/openapi ./pkg/secrets ./cmd/appValidation
gofumpt -extra,go vet ./...,go test -race -count=1 ./...andgolangci-lintwith the CI config all pass.Related: #1356