[ISSUE-4322][Bug] Fix OpenAPI token authentication#4361
Open
hutiefang76 wants to merge 1 commit into
Open
Conversation
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



What changes were proposed in this pull request?
This PR fixes OpenAPI token authentication for generated access tokens.
The OpenAPI token is stored as an encrypted JWT. During authentication the request token is already decrypted by
JWTFilter, so the realm should compare the decrypted stored token with the current credential instead of encrypting the credential again.Because token encryption uses a random IV, encrypting the same JWT again does not produce the same stored token string, which caused valid OpenAPI requests to be rejected with 401.
Brief change log
ShiroRealm./openapi/app/start, verifying the authentication layer no longer returns 401.Verifying this change
AccessTokenServiceTest#testOpenApiTokenCanAuthenticatefailed withexpected: not equal but was: <401>.JAVA_HOME=$(/usr/libexec/java_home -v 17) ./mvnw -pl streampark-console/streampark-console-service -am -Dtest=AccessTokenServiceTest,JWTTest -Dsurefire.failIfNoSpecifiedTests=false testgit diff --checkCloses #4322