Skip to content

fix: Decouple JWT signing key from user password hash - #6408

Open
hengyuss wants to merge 4 commits into
apache:masterfrom
hengyuss:fix/decouple-jwt-signing-key-from-user-password-hash
Open

fix: Decouple JWT signing key from user password hash#6408
hengyuss wants to merge 4 commits into
apache:masterfrom
hengyuss:fix/decouple-jwt-signing-key-from-user-password-hash

Conversation

@hengyuss

@hengyuss hengyuss commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

#6398

decouple jwt signing key from user password hash

add secret-key in application.yml to configure the key of jwt secret key, the code will generate a random string as secretKey if user doesn't configure it.

i don't update JwtUtils.generateToken() and JwtUtils.verifyToken() . the two function receive the argument as secretKey and i think the behavior is correct. So that i change two place that invoke these two funcitons.
Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

@hengyuss
hengyuss force-pushed the fix/decouple-jwt-signing-key-from-user-password-hash branch from 8d5d2eb to 953511c Compare July 5, 2026 15:02
@Aias00

Aias00 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

The @PostConstruct init generates a SecureRandom secretKey per JVM when shenyu.jwt.secretKey is not explicitly configured. In a multi-instance Admin cluster this causes tokens signed by instance A to fail verification on instance B, resulting in random 401s for dashboard users. Consider either failing fast (throw new IllegalStateException) to force explicit configuration, or persisting the generated key somewhere shared across the cluster.

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