refactor: reject JWT expiration value at startup if less than 1 sec - #1172
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1172 +/- ##
==========================================
+ Coverage 50.24% 50.30% +0.05%
==========================================
Files 147 147
Lines 13656 13668 +12
==========================================
+ Hits 6862 6876 +14
+ Misses 6199 6194 -5
- Partials 595 598 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR prevents a misconfigured auth.jwtExpiration / auth.redirectionJWTExpiration (zero or negative durations) from allowing the server to start and then immediately issuing already-expired JWTs, which effectively denies access to legitimate users.
Changes:
- Adds startup-time config validation for JWT expiration durations.
- Introduces sentinel errors for invalid JWT expiration settings.
- Adds unit tests covering zero/negative durations and valid defaults.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
config/config.go |
Adds Config.validate() and calls it from NewConfig() to fail fast on non-positive JWT expirations. |
config/config_test.go |
Adds tests ensuring validation rejects zero/negative expirations and accepts defaults. |
Suppressed comments (3)
config/config_test.go:133
- The test asserts via substring matching on the error string. Since validate() returns a sentinel error, use require.ErrorIs so the test remains stable if the message wording changes.
err := cfg.validate()
require.Error(t, err)
assert.Contains(t, err.Error(), "auth.jwtExpiration")
}
config/config_test.go:144
- The test asserts via substring matching on the error string. Since validate() returns a sentinel error, use require.ErrorIs so the test remains stable if the message wording changes.
err := cfg.validate()
require.Error(t, err)
assert.Contains(t, err.Error(), "auth.redirectionJWTExpiration")
}
config/config_test.go:155
- The test asserts via substring matching on the error string. Since validate() returns a sentinel error, use require.ErrorIs so the test remains stable if the message wording changes.
err := cfg.validate()
require.Error(t, err)
assert.Contains(t, err.Error(), "auth.redirectionJWTExpiration")
}
b8d9299 to
e990ba4
Compare
sudhir-intc
left a comment
There was a problem hiding this comment.
LGTM, check if wee need to keep a minimum value of atleast 1m
e990ba4 to
f6ab15d
Compare
|
@ShradhaGupta31 The current validation rejects anything under 1 minute, but the commit says it’s rejecting zero/negative expirations. Please change it to
|
f6ab15d to
365da3f
Compare
ff50cb2 to
df465df
Compare
@madhavilosetty-intel - Updated title & config.go as well. |
- Modified config.go to validate jwtExpiration while console startup - Reject non-positive values of jwtExpiration Signed-off-by: ShradhaGupta31 <shradha.gupta@intel.com>
df465df to
8526529
Compare
sudhir-intc
left a comment
There was a problem hiding this comment.
LGTM.
Please ensure the CI passes before the merge
|
🎉 This PR is included in version 1.40.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.40.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
1 similar comment
|
🎉 This PR is included in version 1.40.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
commit 7e5511e Merge: 86d029f c28d7a3 Author: Sudhir Pola <sudhir.pola@intel.com> Date: Tue Aug 25 10:10:48 2026 +0530 Merge branch 'main' into feat/http-tenant-header commit c28d7a3 Author: Madhavi Losetty <madhavi.losetty@intel.com> Date: Mon Aug 24 10:16:23 2026 -0700 refactor(config): check admin password strength at startup (#1193) Warn when the configured admin password is shorter than 8 characters or misses a lowercase letter, uppercase letter, digit, or symbol. Startup continues either way. Generated passwords now draw one character from each required class and shuffle with crypto/rand, so a fresh install satisfies the same rule the warning describes. The generator draws its symbols from @ and * only, because the value gets pasted verbatim into files that mangle punctuation: $ and ! expand in sh, # truncates the value in make (the Makefile does -include .env, where quoting does not help), and % ^ & break cmd.exe's set. Operators may still use any of those themselves. There is no upper length bound, and any non-alphanumeric counts as a symbol: this password is only compared against the login request, so a long passphrase or one using - or _ must not be called weak. Existing passwords are untouched: the generator only runs when no password is configured, and a weak value only warns. Co-authored-by: Ganesh Raikhelkar <ganesh.raikhelkar@intel.com> commit 374987e Author: Amarnath C <amarnath.c@intel.com> Date: Mon Aug 24 22:21:20 2026 +0530 fix: align timeout budget with wsman client for slow devices (#1082) (#1153) 1. httpserver read/write timeout 15s to 40s so the wsman client (30s) times out first with a clean 504. 2. waitForAuth 3s to 30s so concurrent handlers share one Target instead of forking, preserving the library concurrency cap. 3. expireAfter 30s to 60s to keep the authenticated Target cached across rapid page refreshes. commit cc951f4 Author: Amarnath C <amarnath.c@intel.com> Date: Mon Aug 24 22:06:36 2026 +0530 build(deps): bump go-wsman-messages to v2.50.2 (#1219) Bumps go-wsman-messages from v2.50.1 to v2.50.2. commit 3022f37 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Aug 24 06:41:41 2026 -0700 build(deps): bump golang from 1.26-alpine to 1.27-alpine (#1215) Bumps golang from 1.26-alpine to 1.27-alpine. --- updated-dependencies: - dependency-name: golang dependency-version: 1.27-alpine dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Madhavi Losetty <madhavi.losetty@intel.com> commit f455536 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Aug 24 06:27:30 2026 -0700 build(deps): bump github.com/getkin/kin-openapi from 0.146.0 to 0.147.0 (#1216) Bumps [github.com/getkin/kin-openapi](https://github.com/getkin/kin-openapi) from 0.146.0 to 0.147.0. - [Release notes](https://github.com/getkin/kin-openapi/releases) - [Commits](getkin/kin-openapi@v0.146.0...v0.147.0) --- updated-dependencies: - dependency-name: github.com/getkin/kin-openapi dependency-version: 0.147.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Madhavi Losetty <madhavi.losetty@intel.com> commit 4cfb69f Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Aug 24 06:17:22 2026 -0700 build(deps): bump modernc.org/sqlite from 1.56.0 to 1.57.0 (#1217) Bumps [modernc.org/sqlite](https://gitlab.com/cznic/sqlite) from 1.56.0 to 1.57.0. - [Changelog](https://gitlab.com/cznic/sqlite/blob/master/CHANGELOG.md) - [Commits](https://gitlab.com/cznic/sqlite/compare/v1.56.0...v1.57.0) --- updated-dependencies: - dependency-name: modernc.org/sqlite dependency-version: 1.57.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 356828b Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Aug 24 06:12:50 2026 -0700 build(deps): bump the codeql-action group with 4 updates (#1218) Bumps the codeql-action group with 4 updates: [github/codeql-action/init](https://github.com/github/codeql-action), [github/codeql-action/autobuild](https://github.com/github/codeql-action), [github/codeql-action/analyze](https://github.com/github/codeql-action) and [github/codeql-action/upload-sarif](https://github.com/github/codeql-action). Updates `github/codeql-action/init` from 4.37.7 to 4.37.8 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@ff2f1c6...db488dd) Updates `github/codeql-action/autobuild` from 4.37.7 to 4.37.8 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@ff2f1c6...db488dd) Updates `github/codeql-action/analyze` from 4.37.7 to 4.37.8 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@ff2f1c6...db488dd) Updates `github/codeql-action/upload-sarif` from 4.37.7 to 4.37.8 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@ff2f1c6...db488dd) --- updated-dependencies: - dependency-name: github/codeql-action/init dependency-version: 4.37.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql-action - dependency-name: github/codeql-action/autobuild dependency-version: 4.37.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql-action - dependency-name: github/codeql-action/analyze dependency-version: 4.37.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql-action - dependency-name: github/codeql-action/upload-sarif dependency-version: 4.37.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: codeql-action ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 7e02b81 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri Aug 21 11:57:47 2026 -0700 build(deps): bump github.com/stretchr/testify from 1.12.0 to 1.12.1 (#1213) Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.12.0 to 1.12.1. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](stretchr/testify@v1.12.0...v1.12.1) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-version: 1.12.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 6e0906e Author: Natalie Gaston <natalie.gaston@intel.com> Date: Thu Aug 20 18:38:13 2026 -0700 fix(config): validate HTTP port and harden Windows browser launch (#1198) commit a493e12 Author: Sinchana S R <sinchana.s.r@intel.com> Date: Fri Aug 21 04:18:50 2026 +0530 refactor(api): prevent integer overflow in query parameters (#1180) * Add validation to prevent integer overflow in query parameters (top, skip, count). * Returns 400 instead of 500 on invalid input. Co-authored-by: Sudhir Pola <sudhir.pola@intel.com> commit fe0cf5c Author: ShradhaGupta31 <shradha.gupta@intel.com> Date: Fri Aug 21 04:14:50 2026 +0530 refactor: reject JWT expiration value at startup if less than 1 sec (#1172) - Modified config.go to validate jwtExpiration while console startup - Reject non-positive values of jwtExpiration Signed-off-by: ShradhaGupta31 <shradha.gupta@intel.com> Co-authored-by: Madhavi Losetty <madhavi.losetty@intel.com> Co-authored-by: Ganesh Raikhelkar <ganesh.raikhelkar@intel.com> commit 365531d Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu Aug 20 22:38:15 2026 +0000 build(deps): bump github.com/stretchr/testify from 1.11.1 to 1.12.0 (#1205) Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.11.1 to 1.12.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](stretchr/testify@v1.11.1...v1.12.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-version: 1.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Natalie Gaston <natalie.gaston@intel.com> commit 4c585b1 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu Aug 20 15:35:21 2026 -0700 build(deps): bump step-security/harden-runner from 2.20.1 to 2.21.0 (#1208) Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.20.1 to 2.21.0. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](step-security/harden-runner@b09bb98...05e3151) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.21.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: DevipriyaS17 <devipriya.s@intel.com> commit 9414597 Author: DevipriyaS17 <devipriya.s@intel.com> Date: Fri Aug 21 04:00:43 2026 +0530 build(docker): default dev service port bindings to loopback (#1168) * build(docker): default dev service port bindings to loopback * build(docker): address review comments --------- Co-authored-by: Sudhir Pola <sudhir.pola@intel.com> commit 001de52 Author: DevipriyaS17 <devipriya.s@intel.com> Date: Fri Aug 21 03:57:13 2026 +0530 refactor(security): default useTLS to true on device creation (#1169) * fix(security): default useTLS to true on device creation * fix: add code coverage * refactor(security): address review comments * refactor(security): fix the codeql error --------- Co-authored-by: Ganesh Raikhelkar <ganesh.raikhelkar@intel.com> commit 3003aa0 Author: Madhavi Losetty <madhavi.losetty@intel.com> Date: Thu Aug 20 15:20:56 2026 -0700 refactor: address golangci-lint 2.13.1 findings (#1212) commit 60d074d Author: Madhavi Losetty <madhavi.losetty@intel.com> Date: Thu Aug 20 13:02:13 2026 -0700 refactor(config): move config to user dir and enforce owner-only perms (#1078) Relocate config to the user directory and harden seedConfig error handling, enforcing owner-only file permissions. Co-authored-by: MadhaviLosetty <madhavi.losetty@gmail.com>
|
🎉 This PR is included in version 1.40.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
4 similar comments
|
🎉 This PR is included in version 1.40.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.40.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.40.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.40.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Changes Done:
Description:
config.ymlacceptsjwtExpiration: 0swhich is a syntactically valid zero duration that the YAML parser accepts without error. At runtime, every issued JWT hasexp = time.Now(), so all tokens expire at the moment of issuance and every subsequent API call is rejected.Before fix : Server starts silently with jwtExpiration 0s, login returns an already-expired token:
After fix : Server would fail to start if jwtExpiration is set to 0s