[feat](plugin) Support multi-root auth plugin loading and normalize OIDC access token auth#62159
Conversation
…IDC access token auth Problem Summary: FE authentication plugin loading currently assumes a single plugin root in several runtime paths, which makes external plugin deployment less flexible and inconsistent across callers. In addition, OIDC token-based authentication uses inconsistent credential typing across MySQL authentication and authentication_chain fallback flows, and the client-visible error message handling is not aligned with access-token- specific failures. This change makes plugin root parsing reusable across FE runtime paths, allows configuring multiple authentication or authorization plugin roots with a comma-separated list, normalizes OIDC access token requests to use `OAUTH_TOKEN`, broadens OIDC request detection in fallback authentication flow, and aligns access-token-related failure messages. It also marks `authentication_chain` as mutable so the fallback chain can be adjusted dynamically.
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
|
/review |
There was a problem hiding this comment.
Findings:
fe/fe-core/src/main/java/org/apache/doris/common/util/ClassLoaderUtils.java:loadServicesFromDirectory()still interprets each configured entry as a flat jar directory, even though this PR changesauthentication_plugins_dir/authorization_plugins_dirto documented plugin roots.AuthenticatorManager.loadCustomerFactories()andAccessControllerManager.loadAccessControllerPlugins()still call this helper, so a deployment laid out as<root>/<plugin>/<plugin>.jarwill work for the newAuthenticationPluginManagerpaths but silently fail for legacyauthentication_type=<plugin_name>and authorization factory loading.fe/fe-core/src/main/java/org/apache/doris/mysql/authenticate/integration/AuthenticationIntegrationAuthenticator.javaand.../plugin/AuthenticationPluginAuthenticator.java: the sanitization branch for the old"OIDC token signature validation failed"prefix was removed. Older OIDC plugins or mixed-version deployments that still emit that message now fall through tostartsWith("OIDC token ")and the full raw detail is returned to the client, which is a behavior regression and weakens the previous redaction.
Critical checkpoints:
- Goal of the task: Partially achieved. Multi-root loading was updated for the new authentication plugin manager paths, but not for the remaining legacy loader paths, and the OIDC message normalization is not backward compatible with older emitters. Existing unit tests only cover the updated paths, not these regressions.
- Small / clear / focused change: Mostly yes, but the config semantic change was not applied consistently to all parallel loading paths.
- Concurrency: No new concurrency issue found in the touched code paths.
- Lifecycle / static initialization: Acceptable. Switching
pluginDirMappingtoSupplier<String>correctly avoids stale config snapshots. - Configuration changes: Yes.
authentication_chainbecoming mutable looks fine, but the newplugin rootsemantics are inconsistent across callers. - Compatibility / incompatible changes: Problematic. Client-visible OIDC failure handling is not backward compatible with older plugins/message formats.
- Parallel code paths: Problematic. Multi-root handling was updated in
AuthenticationIntegrationRuntimeandAuthenticationPluginAuthenticator, but not in theClassLoaderUtils.loadServicesFromDirectory()callers used by legacy authentication and authorization loading. - Special conditional checks: The new OIDC message-prefix checks are incomplete for the old signature-validation prefix.
- Test coverage: Insufficient for the changed surface. Added tests cover only the new manager paths and
OAUTH_TOKENplumbing, not legacyClassLoaderUtilscallers or old-message compatibility. - Observability: No additional observability requirement identified here.
- Transaction / persistence: Not applicable.
- Data writes / modifications: Not applicable.
- FE/BE variable passing: Not applicable.
- Performance: No material performance regression found in the touched code.
- Other issues: None beyond the two findings above.
Overall opinion: the PR is close, but these two regressions should be addressed before merge.
| throw new IOException("The specified path is not a directory: " + pluginRoot); | ||
| } | ||
|
|
||
| File[] jarFiles = jarDir.listFiles((dir, name) -> name.endsWith(".jar")); |
There was a problem hiding this comment.
This helper is still used by AuthenticatorManager.loadCustomerFactories() and AccessControllerManager.loadAccessControllerPlugins(), but it still treats each configured entry as a flat jar directory. After this PR, the same configs are documented as plugin roots, and the newer AuthenticationPluginManager path now scans <root>/<plugin>/.... That means a deployment like authentication_plugins_dir=/opt/doris/plugins/authentication with jars under /opt/doris/plugins/authentication/my-auth/my-auth.jar will work for integration-based loading but fail for legacy authentication_type=<plugin_name> and authorization factory loading. The config semantic change needs to be applied consistently to these legacy callers too, or the docs/config text here stays misleading and introduces a real loading regression.
| String detailMessage = Strings.nullToEmpty(exception.getMessage()); | ||
| if (detailMessage.startsWith("OIDC token signature validation failed")) { | ||
| return "OIDC token signature validation failed"; | ||
| if (detailMessage.startsWith("OIDC access token signature validation failed")) { |
There was a problem hiding this comment.
This drops the old "OIDC token signature validation failed" sanitization path. In mixed-version or external-plugin setups that still emit the old prefix, the message now falls through the next branch (startsWith("OIDC token ")) and the full raw detail is sent back to the client instead of the generic redacted text they got before. That is a client-visible compatibility regression and should be preserved here (and in AuthenticationPluginAuthenticator) while adding the new OIDC access token ... variant.
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
|
run cloud_p0 |
### What problem does this PR solve? Issue Number: None Related PR: apache#62159 Problem Summary: Preserve the original OIDC auth packet when native auth switch runs on branch-4.1, normalize OIDC access-token requests to OAUTH_TOKEN across auth packet extraction and authentication_chain fallback, and create AuthenticationPluginManager under AuthenticationPluginAuthenticator's classloader context so SPI lookup does not depend on the caller thread context classloader. ### Release note None ### Check List (For Author) - Test: FE unit test - mvn -f pom.xml -pl fe-core -am -Dskip.clean=true -Dtest=org.apache.doris.mysql.authenticate.AuthenticatorManagerTest,org.apache.doris.mysql.authenticate.MysqlAuthPacketCredentialExtractorTest,org.apache.doris.mysql.authenticate.plugin.AuthenticationPluginAuthenticatorTest test -DfailIfNoTests=false - Behavior changed: Yes (branch-4.1 now preserves the original OIDC auth packet across native auth-switch fallback, uses OAUTH_TOKEN for OIDC access-token requests in fe-core auth flows, and resolves auth plugin SPI factories without relying on the caller thread context classloader) - Does this need documentation: No
…IDC access token auth (apache#62159) apache#60361 Problem Summary: FE authentication plugin loading currently assumes a single plugin root in several runtime paths, which makes external plugin deployment less flexible and inconsistent across callers. In addition, OIDC token-based authentication uses inconsistent credential typing across MySQL authentication and authentication_chain fallback flows, and the client-visible error message handling is not aligned with access-token- specific failures. This change makes plugin root parsing reusable across FE runtime paths, allows configuring multiple authentication or authorization plugin roots with a comma-separated list, normalizes OIDC access token requests to use `OAUTH_TOKEN`, broadens OIDC request detection in fallback authentication flow, and aligns access-token-related failure messages. It also marks `authentication_chain` as mutable so the fallback chain can be adjusted dynamically.
#60361
Problem Summary:
FE authentication plugin loading currently assumes a single plugin root in several runtime paths, which makes
external plugin deployment less flexible and inconsistent across callers.
In addition, OIDC token-based authentication uses inconsistent credential typing across MySQL authentication and
authentication_chain fallback flows, and the client-visible error message handling is not aligned with access-token-
specific failures.
This change makes plugin root parsing reusable across FE runtime paths, allows configuring multiple authentication
or authorization plugin roots with a comma-separated list, normalizes OIDC access token requests to use
OAUTH_TOKEN, broadens OIDC request detection in fallback authentication flow, and aligns access-token-relatedfailure messages. It also marks
authentication_chainas mutable so the fallback chain can be adjusted dynamically.What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)