[ISSUE #15510] Reject invalid credential before anonymous fallback#15526
[ISSUE #15510] Reject invalid credential before anonymous fallback#15526jay666mnj wants to merge 5 commits into
Conversation
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
|
Thanks for fixing the invalid-credential anonymous fallback. The general direction looks correct, but I think the following issues should be addressed before merging:
|
I updated the PR to address the review points:
Verified with the targeted unit tests for IdentityContext, HttpIdentityContextBuilder, NacosAuthPluginService, and AuthFilter. |
After reviewing the updated implementation, I think the
For the anonymous fallback fix, checking key presence is sufficient. Even if a blank request parameter overwrites an Authorization header value, the key still exists in Therefore, I suggest:
This keeps the change scoped to resources that explicitly enable anonymous access. In practice, the behavioral impact remains limited to the four Skill/AgentSpec anonymous endpoints, without changing credential precedence for all HTTP APIs, OIDC, or third-party auth plugins. |
Thanks for the review. I updated the PR to narrow the change scope as suggested.
|
What is the purpose of the change
Fix #15510.
When anonymous AI access is enabled, requests with an explicitly supplied invalid credential, such as
Authorization: Bearer invalid-token, should not silently fall back to anonymous access.This change keeps anonymous access available for requests without credentials, but rejects requests that provide invalid explicit credentials.
Brief changelog
Authorization,accessToken,username, orpasswordas explicit credentials.Verifying this change
Run:
.\mvnw.cmd --% -pl plugin-default-impl/nacos-default-auth-plugin -am -Dtest=NacosAuthPluginServiceTest#testValidateIdentityAnonymousAllowedAndDenied -Dsurefire.failIfNoSpecifiedTests=false -DskipITs test
git diff --check
Result:
Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check spotbugs:check -DskipTeststo make sure basic checks pass. Runmvn clean installto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.