You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Anubhav Jindal (Code Review)" <ge...@cloudera.org> on 2026/06/12 00:41:59 UTC

[Impala-ASF-CR] IMPALA-14799: Add oauth servers JSON config for multiple identity providers

Anubhav Jindal has uploaded this change for review. ( http://gerrit.cloudera.org:8080/24448


Change subject: IMPALA-14799: Add oauth_servers JSON config for multiple identity providers
......................................................................

IMPALA-14799: Add oauth_servers JSON config for multiple identity providers

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags into the new structure with deprecation
warnings, and verify tokens against all configured JWKS sources.

Co-authored-by: Cursor <cu...@cursor.com>

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
14 files changed, 689 insertions(+), 124 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/1
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 1
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 22:

> Patch Set 21: -Code-Review
> 
> I ran a debug core test, it had some failures in TestImpalaShellJWTAuth and TestImpalaShellOAuthAuth, could you double check about that?

Done


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 22
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 04 Sep 2026 06:53:30 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 23: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 23
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 09 Sep 2026 13:10:24 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 18: Code-Review+1

(6 comments)

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc@1025
PS17, Line 1025:   if (!decoded_token->decoded_jwt_.has_key_id()) {
> Done
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc@1030
PS17, Line 1030:   }
> Done
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.h@38
PS17, Line 38: const std::string& token, std::string* u
> Done. I removed the matched_server_idx_out parameter from both Authenticate
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@81
PS17, Line 81: server_idx).jwt_helper.Verify(decoded_token);
             : 
> Done. I updated the loop condition in Verify() to use next_idx < jwt_helper
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@108
PS17, Line 108: 
> Done
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@125
PS17, Line 125: 
              : 
              : 
> Done. This is an internal-only path, so I replaced the runtime condition wi
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 18
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 12 Aug 2026 22:03:23 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Yida Wu, Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#19).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager, enforce
signature validation for matched servers, add RFC6750 bearer auth response
headers, and apply follow-up review cleanups in JWT helper internals.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
22 files changed, 1,223 insertions(+), 293 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/19
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 19
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 15:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23431/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 15
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Tue, 28 Jul 2026 22:44:11 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#7).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest (11/11 passing)
- OAuthServersManagerTest (4/4 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (2/2 passing)
  - test_jwt_auth_with_oauth_servers
  - test_oauth_auth_with_oauth_servers

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
A tests/custom_cluster/test_shell_oauth_servers_auth.py
16 files changed, 1,119 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/7
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 7
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Yida Wu, Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#21).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager, enforce
signature validation for matched servers, add RFC6750 bearer auth response
headers, and apply follow-up review cleanups in JWT helper internals.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
22 files changed, 1,240 insertions(+), 315 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/21
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 21
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 21:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23889/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 21
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 02 Sep 2026 04:52:47 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 25:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/24002/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 25
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 14 Sep 2026 06:14:20 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity
providers, migrate legacy jwks_* and oauth_* flags with deprecation
warnings, and verify tokens across configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager,
enforce signature validation for matched servers, add RFC6750 bearer
auth response headers, and apply follow-up review cleanups in JWT
helper internals.

Testing:
- Linux build:
  ninja impalad oauth-server-config-test oauth-servers-manager-test
  jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)
- org.apache.impala.customcluster.LdapHS2Test
  #testHiveserver2JwtAndOAuthAuth (1/1 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
Reviewed-on: http://gerrit.cloudera.org:8080/24448
Tested-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Yida Wu <wy...@gmail.com>
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
M tests/custom_cluster/test_shell_jwt_auth.py
M tests/custom_cluster/test_shell_oauth_auth.py
A tests/custom_cluster/test_shell_oauth_servers_auth.py
24 files changed, 1,254 insertions(+), 327 deletions(-)

Approvals:
  Impala Public Jenkins: Verified
  Yida Wu: Looks good to me, approved

-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 30
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 28:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/24062/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 28
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 17 Sep 2026 04:43:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 10:

(7 comments)

gerrit-auto-critic failed. You can reproduce it locally using command:

  python3 bin/jenkins/critique-gerrit-review.py --dryrun

To run it, you might need a virtual env with Python3's venv installed.

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/service/impala-server.cc@3237
PS10, Line 3237:     const bool require_oauth_servers = (FLAGS_jwt_token_auth && FLAGS_jwt_validate_signature)
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.cc@784
PS10, Line 784:         jwks_ca_certificate, current_jwks_checksum_, &is_changed, jwks_pull_timeout_secs_);
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config-test.cc
File be/src/util/oauth-server-config-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config-test.cc@136
PS10, Line 136: TEST(OAuthServerConfigTest, BuildOAuthServerConfigsMergesLegacyJwtFlagsFromUsernameClaim) {
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config-test.cc@189
PS10, Line 189:       R"([{"jwksUrl":"https://example.com/oauth-servers-jwks.json","usernameClaim":"sub"}])";
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config.cc@138
PS10, Line 138: Status ParseOAuthServerObject(const rapidjson::Value& obj, OAuthServerConfig* config_out) {
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config.cc@145
PS10, Line 145:   RETURN_IF_ERROR(ReadOptionalStringField(obj, "caCertFilePath", &config.ca_cert_file_path));
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config.cc@146
PS10, Line 146:   RETURN_IF_ERROR(ReadOptionalBoolField(obj, "verifyServerCert", &config.verify_server_cert));
line too long (94 > 90)



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 10
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Jun 2026 09:22:19 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 12:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23005/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 12
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 24 Jun 2026 23:25:42 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 13:

(36 comments)

http://gerrit.cloudera.org:8080/#/c/24448/13//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24448/13//COMMIT_MSG@13
PS13, Line 13: Address follow-up review feedback by adding
Nit: no need to mention addressing review feedback unless its feedback from a prior change.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@184
PS12, Line 184: DEFINE_bool(jwt_token_auth, false,
> Done. Marked --jwt_token_auth as deprecated and updated the help text to di
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@224
PS12, Line 224: DEFINE_bool_hidden(jwt_allow_without_tls, false,
> Done. Marked --jwt_allow_without_tls as deprecated and updated the help tex
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@796
PS12, Line 796:     const AuthenticationHash& hash, const string& token) {
> Done. Moved common bearer-token decode/verify/username logic into OAuthServ
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@807
PS12, Line 807:     connection_context->return_headers.push_back(
> Done. Updated RPC logging to use generic bearer-token validation errors ins
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@819
PS12, Line 819: }
              : 
              : // Performs a step of SPNEGO auth for the
> Done for the generic wording. I kept logs metadata-light (no JWKS/kid) to a
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@833
PS12, Line 833:   }
> Done. Updated this RPC error path to the same generic bearer-token validati
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@843
PS12, Line 843:   if (spnego_status.ok()) {
> Done. Updated cookie generation to always pass HTTP_AUTH_MECH_OAUTH.
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@190
PS13, Line 190: DEFINE_bool(jwt_validate_signature, true,
This flag is dangerous and doesn't make a lot of sense anymore now that multiple oauth servers can be specified.  Delete it entirely.  The JwtHttpTest#testJwtAuthNotVerifySig test will need to be updated since that is the only place where this flag is set to false.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@237
PS13, Line 237: DEFINE_bool(oauth_jwt_validate_signature, true,
This flag is dangerous and doesn't make a lot of sense anymore now that multiple oauth servers can be specified.  Delete it entirely.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@802
PS13, Line 802:     LOG(ERROR) << "Error validating bearer token in Authorization header received from: "
Let's also include the username in this error message if the username is not empty.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/service/impala-server.cc@3237
PS12, Line 3237:     if (FLAGS_jwt_token_auth || FLAGS_oauth_token_auth) {
> Done. Removed the temporary boolean and inlined the condition directly.
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.h
File be/src/util/jwt-util.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.h@100
PS13, Line 100:   std::shared_ptr<JWKSMgr> jwks_mgr_;
This is fine to leave as a std::unique_ptr since jwks_mgr_ is not shared outside of this class.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc@765
PS12, Line 765:   jwks_pull_timeout_secs_ = jwks_pull_timeout_secs;
              :   jwks_update_frequency_secs_ = jwks_update_frequency_secs;
              :   DCHECK_GT(jwks_pull_timeout_secs_, 0);
              :   DCHECK(is_local_file || jwks_update_frequency_secs_ > 0);
              :   std::shared_ptr<JWKSSnapshot> new_jwks = std::make_shared<JWKSSnapshot>();
              :   if (is_local_file) {
> Done. Removed fallback usage of those legacy flags in JWKSMgr::Init() and n
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc@852
PS12, Line 852: Status JWTHelper::Init(const std::string& jwks_file_path) {
              :   return Init(jwks_file_path, fals
> Done. Defaulted JWTHelper ctor/dtor in the header and removed explicit ctor
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@988
PS13, Line 988:   if (jwks_mgr_ == nullptr) return Status::OK();
Add DCHECK(jwks_mgr_ != nullptr) to ensure that Init() was already called.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@991
PS13, Line 991:   if (jwks->IsEmpty()) {
Should this be an error condition if the jwks is empty?  Possibly the init code guards against this situation happening?


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@995
PS13, Line 995:   if (!decoded_token->decoded_jwt_.has_key_id()) return Status::OK();
The "alg" token header parameter is required.  First check if the jwks has any keys with an algorithm that matches the algorithm of the decoded jwt.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-server-config.h@38
PS13, Line 38:   bool validate_token_signature = true;
Delete this struct member.  Token signatures must always be validated.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.h@40
PS12, Line 40:   int32_t jwks_update_frequency_secs = DEFAULT_JWKS_UPDATE_FREQUENCY_SECS;
> Done. Added validate_token_signature to OAuthServerConfig, parse support fo
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc@57
PS12, Line 57: namespace impala {
> Done.
No need to check FLAGS_jwks_file_path or FLAGS_jwks_url.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc@61
PS12, Line 61: bool IsLegacyJwtConfigFlagSpecified() {
> Done.
No need to check FLAGS_oauth_jwks_file_path or FLAGS_oauth_jwks_url.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager-test.cc@145
PS12, Line 145:   size_t matched_server_idx = static_cast<size_t>(-1);
              :   Status status = manager.Verify(decoded_token.get(), &matched_server_idx);
> Done. Updated OAuthServersManagerTest.VerifyFailsWhenOnlyWrongJwksConfigure
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.h@56
PS13, Line 56:   /// Extracts the username using the username claim from the server at 'server_idx'.
             :   Status GetUsername(const JWTHelper::JWTDecodedToken* decoded_token, size_t server_idx,
             :       std::string* username_out) const;
Move this function declaration down into the private section.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h@54
PS12, Line 54:       size_t* matched_server_idx_out) const;
> Done. Updated API contract comment and behavior to preserve matched_server_
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h@66
PS12, Line 66: 
> Done. Renamed internal member from impl_ to jwt_helpers_.
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc@57
PS12, Line 57:   size_t matched_server_idx = 0;
             :   RETURN_IF_ERROR(Verify(decoded_token.get(), &matched_server_idx));
             :   RETURN_IF_ERROR(GetUsername(decoded_token.get(), matched_server_idx, username_out));
             :   if (matched_server_idx_out != nullptr) *matched_server_idx_out = matched_server_idx;
             :   return Status::OK();
             : }
             : 
             : Sta
> Done. Added key preselection via JWTHelper::CanVerify() (kid/algorithm-fami
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@59
PS13, Line 59:   RETURN_IF_ERROR(GetUsername(decoded_token.get(), matched_server_idx, username_out));
Let's get the username first so that output function parameter will be set if verification fails.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@69
PS13, Line 69:   DCHECK(!jwt_helpers_->empty());
Put the two jwt_helpers_ DCHECKS next to each other.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@75
PS13, Line 75:     if (!verifier.validate_token_signature) {
This condition will authorize every token if any of the verifies have validate_token_signature set to false.  Instead, the token signature validation should only be skipped after the jwt_helper that would have verified the token has been located.

In other words, delete this entire "if" code black and skip the call to verifier.jwt_helper.Verify if verifier.validate_token_signature is false.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1160
PS12, Line 1160:   (void)connection;
> Done. Removed JWT/OAuth mode branching from webserver bearer auth and switc
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1169
PS12, Line 1169:     return false;
> Done. Updated webserver logs to generic bearer-token validation error wordi
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1180
PS12, Line 1180:     return Status::Expected("No Authorization header provided.");
               :   }
               : 
> Done for generic wording. I intentionally left out JWKS/kid details to avoi
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1191
PS12, Line 1191:                << GetRemoteAddress(request_info).ToString() << " Error: " << status;
               :     return status;
> Done. Updated this webserver error path to the same generic bearer-token va
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc@1160
PS13, Line 1160:   (void)connection;
Delete this line.  If possible, remove the struct sq_connection* connection function parameter too.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc@1166
PS13, Line 1166:     LOG(ERROR) << "Error validating bearer token in Authorization header from "
Need to also set the "WWW-Authenticate" http response header per https://datatracker.ietf.org/doc/html/rfc6750#section-3.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 13
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Tue, 14 Jul 2026 19:05:44 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 14:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23260/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 14
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 15 Jul 2026 23:47:45 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 20:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23755/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 20
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 25 Aug 2026 07:05:09 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 19:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23735/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 19
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 24 Aug 2026 06:34:20 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 21:

(2 comments)

Done

http://gerrit.cloudera.org:8080/#/c/24448/20/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/20/be/src/util/webserver.cc@763
PS20, Line 763:   if (use_jwt_ || use_oauth_) {
> We can remove this comment since we are using the unified interface now. An
Done


http://gerrit.cloudera.org:8080/#/c/24448/20/be/src/util/webserver.cc@782
PS20, Line 782:           // imperfect because OAuthTokenAuth() uses unified verification and
              :           // doesn't return which provider matched. A follow-up should retu
> This comment is a bit confusing because it mixes the metrics logic with the
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 21
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 02 Sep 2026 04:32:16 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 29:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/14072/ DRY_RUN=false


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 29
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 17 Sep 2026 15:43:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 18:

(7 comments)

Done

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc@1025
PS17, Line 1025:   if (!decoded_token->decoded_jwt_.has_key_id()) {
> Please add a comment here explaining that if the decoded_jwt_ does not have
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc@1030
PS17, Line 1030:   }
> Please add a comment here explaining that the decoded_jwt_ contains a speci
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.h@38
PS17, Line 38: const std::string& token, std::string* u
> The matched_server_idx_out parameter is only used in test code.  While test
Done. I removed the matched_server_idx_out parameter from both AuthenticateBearerToken() and Verify() to keep test-only behavior out of production APIs


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@30
PS17, Line 30: string OAuthServersManager::BearerAuthFailureHeader(const Status& status) {
             :   const string error_message =
             :       status.GetDetail().empty() ? status.msg().msg() : status.GetDetail();
             :   return Substitute("WWW-Authenticate: Bearer error=\"invalid_token\","
             :       "error_description=\"$0 \"", error_message);
             : }
> Please add a test to oauth-servers-manager-test.cc for this function.
Done. I added OAuthServersManagerTest.BearerAuthFailureHeaderIncludesStatusMessage


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@81
PS17, Line 81: server_idx).jwt_helper.Verify(decoded_token);
             : 
> Since line 84 handles the case where `matched_server_idx == size()`, I thin
Done. I updated the loop condition in Verify() to use next_idx < jwt_helpers_->size()


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@108
PS17, Line 108: 
> Should be i < jwt_helpers_->size()
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@125
PS17, Line 125: 
              : 
              : 
> I don't think this condition will ever be true?  If it can be true, would a
Done. This is an internal-only path, so I replaced the runtime condition with DCHECK_LT(server_idx, jwt_helpers_->size()) and removed the branch.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 18
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Mon, 10 Aug 2026 22:57:03 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 12:

(37 comments)

http://gerrit.cloudera.org:8080/#/c/24448/10//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24448/10//COMMIT_MSG@37
PS10, Line 37: 
> Done
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@796
PS10, Line 796: bool OAuthTokenAuth(ThriftServer::ConnectionContext* connection_context,
> Done. Removed JWTTokenAuth() and now both JWT and OAuth HTTP auth paths use
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@824
PS10, Line 824: error_description=\"$0 \"", status.GetDetail()));
              :       return false;
              :     }
              :   }
              : 
              :   string username;
              :   status = oauth_servers_mgr->GetUsername(
              :    
> Done. Auth now consistently goes through oauth_servers_mgr. For JWT/OAuth, 
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@874
PS10, Line 874:     if (*is_complete) {
              :       if (username.empty()) {
              :         spnego_status = kudu::Status::RuntimeError(
              :             "SPNEGO indicated complete, but got empty principal");
              :         // Crash in debug builds, but fall through to treating as an error in release.
              :         LOG(DFATAL) << "Got no authenticated principal for SPNEGO-authenticated "
              :                     << " connection from "
              :    
> Addressed with the same fix as above.
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@184
PS12, Line 184: DEFINE_bool(jwt_token_auth, false,
This flag also needs to be deprecated.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@224
PS12, Line 224: DEFINE_bool_hidden(jwt_allow_without_tls, false,
This flag needs to be marked deprecated too.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@796
PS12, Line 796: bool OAuthTokenAuth(ThriftServer::ConnectionContext* connection_context,
This function contains a lot of code in common with Webserver::OAuthTokenAuth().  Move the common code into a single function.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@797
PS12, Line 797: bool use_jwt_auth
This function should not need to know whether it's handling JWT or OAuth.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@807
PS12, Line 807:     LOG(ERROR) << "Error decoding " << token_kind << " token received from: "
Make this message more generic by having it say something like, "Error decoding bearer token in Authorization header".


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@819
PS12, Line 819:       LOG(ERROR) << "Error verifying " << token_kind << " token received from: "
              :                  << TNetworkAddressToString(connection_context->network_address)
              :                  << " Error: " << status;
Same comment as line 807.  Possibly also include the token's JWKS and key id in this log message.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@833
PS12, Line 833:     LOG(ERROR) << "Error extracting username from " << token_kind
Same comment as line 807.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@843
PS12, Line 843:       Substitute("Set-Cookie: $0", GenerateCookie(username, hash, auth_mech)));
The call to GenerateCookie() should always pass HTTP_AUTH_MECH_OAUTH as the auth mech.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/service/impala-server.cc@3237
PS10, Line 3237: const bool require_oauth_servers = FLAGS_jwt_token_auth || FLAGS_oauth_token_auth;
> Done. Startup now initializes oauth_servers_mgr when either JWT or OAuth to
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/service/impala-server.cc@3237
PS12, Line 3237:     const bool require_oauth_servers = FLAGS_jwt_token_auth || FLAGS_oauth_token_auth;
Unnecessary variable declaration.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.h
File be/src/util/jwt-util.h:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.h@40
PS10, Line 40:   JWTHelper();
             :   ~JWTHelper();
             :   JWTHelper(const JWTHelper&) = delete;
             :   JWTHelper& operator=(const JWTHelper&) = delete;
             : 
             :   /// Opaque types for storing the JWT decode
> Kept only what is needed for safe ownership/lifetime. The current JWTHelper
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.cc@803
PS10, Line 803:   std::shared_ptr<JWKSSnapshot> new_jwks;
              :   int64_t timeout_millis = jwks_update_f
> Done. Removed the redundant DCHECK in JWKSMgr::UpdateJWKSThread() and rely 
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc@765
PS12, Line 765:   jwks_pull_timeout_secs_ = jwks_pull_timeout_secs >= 0
              :       ? jwks_pull_timeout_secs
              :       : FLAGS_jwks_pulling_timeout_s;
              :   jwks_update_frequency_secs_ = jwks_update_frequency_secs >= 0
              :       ? jwks_update_frequency_secs
              :       : FLAGS_jwks_update_frequency_s;
Now that legacy JWT and OAuth flags are managed by OAuthServersManager, there is no need to check the jwks_pulling_timeout_s and jwks_update_frequency_secs flags.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc@852
PS12, Line 852: JWTHelper::JWTHelper() = default;
              : JWTHelper::~JWTHelper() = default;
Set the ctor/dtor to the default implementation in the header file and delete these lines.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.h@40
PS12, Line 40:   std::string username_claim = "username";
I realize now that OAuthServerConfig needs to have a "validateTokenSignature" struct member.  The Jira has been updated to reflect the addition of this new field.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc@57
PS12, Line 57:   return !FLAGS_jwks_file_path.empty() || !FLAGS_jwks_url.empty();
Need to check jwt_token_auth flag only.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc@61
PS12, Line 61:   return !FLAGS_oauth_jwks_file_path.empty() || !FLAGS_oauth_jwks_url.empty();
Need to check oauth_token_auth flag only.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager-test.cc@55
PS10, Line 55: 
> Done. Added VerifyFailsWhenNoServersConfigured() coverage.
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager-test.cc@145
PS12, Line 145:   size_t matched_server_idx = 0;
              :   Status status = manager.Verify(decoded_token.get(), &matched_server_idx);
Initialize matched_server_idx to -1 and then check that matched_server_idx is still set to -1 after the call to manager.Verify().


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h@54
PS12, Line 54:   /// index of the server that verified the token in 'matched_server_idx_out'.
Please also note that on failure, the value of matched_server_idx_out is not modified.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h@66
PS12, Line 66: impl_
Nit: The variable name impl_ is not very descriptive.  Please rename it to something plural like jwt_helpers_.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.h@67
PS10, Line 67: };
> Done. impl_ is now std::unique_ptr<OAuthServersImpl>
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc@36
PS10, Line 36:   impl_ = std::make_unique<OAuthServersImpl>();
> Done. Inlined InitWithConfigs() logic into Init() and removed the extra met
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc@64
PS10, Line 64:   }
             :   return last_error;
             : }
> Yes. The validation is already enforced during config parsing/construction 
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc@40
PS12, Line 40:     auto jwt_helper = std::make_unique<JWTHelper>();
Why the switch to using a std::unique_ptr for the JWTHelper instance?  The simpler implementation that used the JWTHelper instance directly should be sufficient.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc@45
PS12, Line 45:     impl_->emplace_back(std::move(config), std::move(jwt_helper));
There is no need to keep the OAuthServerConfig object around once the JWTHelper is constructed.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc@57
PS12, Line 57:   for (size_t i = 0; i < impl_->size(); ++i) {
             :     Status status = impl_->at(i).second->Verify(decoded_token);
             :     if (status.ok()) {
             :       *matched_server_idx_out = i;
             :       return Status::OK();
             :     }
             :     last_error = status;
             :   }
Verifying decoded_token is a cryptographical operation and thus could potentially be heavy.  Instead of verifying decoded_token against every JWTHelper, first locate the JWTHelper with the public key that matches decoded_token's public key/key type and verify against that.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc@1158
PS10, Line 1158: bool Webserver::OAuthTokenAuth(const std::string& token,
> Done. Removed Webserver::JWTTokenAuth() and now both JWT/OAuth paths use We
Done


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1160
PS12, Line 1160:     bool use_jwt_auth) {
This function should not need to know whether it's handling JWT or OAuth.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1169
PS12, Line 1169:     LOG(ERROR) << "Error decoding " << token_kind << " token in Authorization header, "
Make this message more generic by having it say something like, "Error decoding bearer token in Authorization header".


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1180
PS12, Line 1180:       LOG(ERROR) << "Error verifying " << token_kind
               :                  << " token in Authorization header, "
               :                  << "Error: " << status;
Same comment as line 1169.  Possibly also include the token's JWKS and key id in this log message.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1191
PS12, Line 1191:     LOG(ERROR) << "Cannot retrieve username from " << token_kind
               :                << " token in Authorization header, "
Same comment as line 1169.


http://gerrit.cloudera.org:8080/#/c/24448/10/tests/custom_cluster/test_shell_oauth_servers_auth.py
File tests/custom_cluster/test_shell_oauth_servers_auth.py:

http://gerrit.cloudera.org:8080/#/c/24448/10/tests/custom_cluster/test_shell_oauth_servers_auth.py@62
PS10, Line 62:     impalad_args=JWT_IMPALAD_ARGS,
> Done. Added legacy OAuth flags custom-cluster test coverage.
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 12
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Fri, 26 Jun 2026 20:28:47 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 9:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/22937/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 9
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Jun 2026 09:35:44 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers JSON config for multiple identity providers

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers JSON config for multiple identity providers
......................................................................


Patch Set 1:

(4 comments)

gerrit-auto-critic failed. You can reproduce it locally using command:

  python3 bin/jenkins/critique-gerrit-review.py --dryrun

To run it, you might need a virtual env with Python3's venv installed.

http://gerrit.cloudera.org:8080/#/c/24448/1/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/1/be/src/service/impala-server.cc@3237
PS1, Line 3237:     const bool require_oauth_servers = (FLAGS_jwt_token_auth && FLAGS_jwt_validate_signature)
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/1/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/1/be/src/util/oauth-server-config.cc@104
PS1, Line 104: Status ParseOAuthServerObject(const rapidjson::Value& obj, OAuthServerConfig* config_out) {
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/1/be/src/util/oauth-server-config.cc@109
PS1, Line 109:   RETURN_IF_ERROR(ReadOptionalStringField(obj, "caCertFilePath", &config.ca_cert_file_path));
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/1/be/src/util/oauth-server-config.cc@110
PS1, Line 110:   RETURN_IF_ERROR(ReadOptionalBoolField(obj, "verifyServerCert", &config.verify_server_cert));
line too long (94 > 90)



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 1
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Fri, 12 Jun 2026 00:44:16 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers JSON config

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#3).

Change subject: IMPALA-14799: Add oauth_servers JSON config
......................................................................

IMPALA-14799: Add oauth_servers JSON config

Introduce --oauth_servers to configure multiple JWT/OAuth identity
providers, migrate legacy jwks_* and oauth_* flags into the new
structure with deprecation warnings, and verify tokens against all
configured JWKS sources.

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
14 files changed, 689 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/3
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 3
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Yida Wu, Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#28).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity
providers, migrate legacy jwks_* and oauth_* flags with deprecation
warnings, and verify tokens across configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager,
enforce signature validation for matched servers, add RFC6750 bearer
auth response headers, and apply follow-up review cleanups in JWT
helper internals.

Testing:
- Linux build:
  ninja impalad oauth-server-config-test oauth-servers-manager-test
  jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)
- org.apache.impala.customcluster.LdapHS2Test
  #testHiveserver2JwtAndOAuthAuth (1/1 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
M tests/custom_cluster/test_shell_jwt_auth.py
M tests/custom_cluster/test_shell_oauth_auth.py
A tests/custom_cluster/test_shell_oauth_servers_auth.py
24 files changed, 1,254 insertions(+), 327 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/28
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 28
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 20:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24448/20/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/20/be/src/util/webserver.cc@763
PS20, Line 763:   // Try authenticating with JWT token first, if enabled.
We can remove this comment since we are using the unified interface now. And the order in which the tokens are checked belongs in the documentation for the OAuthServersManager implementation


http://gerrit.cloudera.org:8080/#/c/24448/20/be/src/util/webserver.cc@782
PS20, Line 782:           // Preserve existing JWT-first compatibility semantics when both modes
              :           // are enabled while avoiding duplicate token verification calls.
This comment is a bit confusing because it mixes the metrics logic with the authentication logic. Can we simply show that there is a bug here in the comment like:
// When both modes are enabled, this can incorrectly attribute successes to JWT because OAuthTokenAuth() may use OAuth internally. A follow-up should return the exact provider from OAuthTokenAuth() to fix these metrics.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 20
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 28 Aug 2026 15:24:22 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 21: -Code-Review

I ran a debug core test, it had some failures in TestImpalaShellJWTAuth and TestImpalaShellOAuthAuth, could you double check about that?


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 21
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 04 Sep 2026 03:19:44 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 20:

(1 comment)

Done

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         const bool token_authenticated =
              :             OAuthTokenAuth(bearer_token, request_info, &response_headers);
              :         if (token_authenticated) {
              :           authenticated = true;
              :           check_csrf_protection = false;
              :           // Preserve existing JWT-first compatibility semantics when both modes
              :           // are enabled while avoiding duplicate token verification calls.
              :           if (use_jwt_) {
              :             total_jwt_token_auth_success_->Increment(1);
              :           } else if (use_oauth_) {
              :             total_oauth_token_auth_success_->Increment(1);
              :           }
              :           // TODO: cookies are not added, but are not needed right now
              :         } else if (use_jwt_) {
              :           LOG(INFO) << "Invalid JWT token provided";
              :           total_jwt_token_auth_failure_->Increment(1);
              :         } else if (use_oauth_) {
              :           LOG(INFO) << "Invalid OAuth token provided";
              :           total_oauth_token_auth_failure_->Increment(1);
              :         }
              :       }
              :     }
              :   }
              : 
              :   if (!authenticated && auth_mode_ == AuthMode::NONE) {
              :     // Wi
> I don't think we need to keep this two block structure just to preserve the
you’re absolutely right. In the both-enabled path we could end up calling OAuthTokenAuth() twice for the same bearer token, which is redundant and could duplicate the failure header. I updated the flow to call it once per request and then apply metrics/logging based on the compatibility-mode semantics



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 20
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 25 Aug 2026 06:52:28 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 19:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         if (use_jwt_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_jwt_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated && use_oauth_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_oauth_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated) {
              :           if (use_jwt_) {
              :             LOG(INFO) << "Invalid JWT token provided";
              :             total_jwt_token_auth_failure_->Increment(1);
              :           }
              :           if (use_oauth_) {
              :             LOG(INFO) << "Invalid OAuth token provided";
              :             total_oauth_token_auth_failure_->Increment(1);
              :           }
              :         }
> I kept the current structure intentionally so JWT and OAuth compatibility p
Since OAuthTokenAuth() now verifies the token against the unified OAuthServersManager and returns a simple boolean, how does the caller actually know which configuration (JWT or OAuth) successfully validated the token if both use_jwt_ and use_oauth_ are true here?



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 19
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 24 Aug 2026 06:23:52 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 17:

(13 comments)

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/rpc/authentication.cc@794
PS16, Line 794:     connection_context->return_headers.push_back(
              :         OAuthServersManager::BearerAuthFailureHeader(status));
              :     return false;
              :   }
              :   connection_context->username = username;
> Done. I moved WWW-Authenticate bearer failure header construction into OAut
Done


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/jwt-util.cc@1001
PS16, Line 1001:   JWKSSnapshotPtr jwks = GetJWKS();
> Done. CanVerify() now uses UNLIKELY and checks both empty and short algorit
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc@1025
PS17, Line 1025:   if (!decoded_token->decoded_jwt_.has_key_id()) {
Please add a comment here explaining that if the decoded_jwt_ does not have a key id specified, then we cannot know exactly which JWTHelper to use, and this JWTHelper is a candidate for validating the JWT since it has at least one key with the same algorithm as the JWT.


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/jwt-util.cc@1030
PS17, Line 1030:   const JWTPublicKey* pub_key = nullptr;
Please add a comment here explaining that the decoded_jwt_ contains a specific key id, and this JWTHelper can validate the JWT if its JWKS contains a key with the same id.


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc@168
PS16, Line 168:   config.verify_server_cert = FLAGS_jwks_verify_server_certificate;
> Done. I replaced the DCHECK_OK path by making BuildLegacyJwtServerConfig() 
Done


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc@182
PS16, Line 182:   if (!jwks_file_path.empty() && !jwks_url.empty()) jwks_url.clear();
> Done. I applied the same fix for legacy OAuth config: BuildLegacyOAuthServe
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.h@38
PS17, Line 38: size_t* matched_server_idx_out = nullptr
The matched_server_idx_out parameter is only used in test code.  While test-only code in main code is not necessarily bad, it is a design smell.  Please look into eliminating the function parameter both here and on the Verify() function.


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc@58
PS16, Line 58: Status OAuthServersManager::AuthenticateBearerToken(const string& token,
             :     string* username_out, size_t* matched_server_idx_out) const {
             :   DCHECK(jwt_helpers_);
             :   DCHECK(username_out != nullptr);
             :   username_out->clear();
             :   JWTHelper::UniqueJWTDecodedToken decoded_token;
             :   RETURN_IF_ERROR(JWTHelper::Decode(token, decoded_token));
             : 
> Done. I removed the pre-verification FindMatchingServer()/username prefetch
Done


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc@75
PS16, Line 75:   DCHECK(!jwt_helpers_->empty());
> Done. Username is now only extracted on successful verification in Verify()
Done


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@30
PS17, Line 30: string OAuthServersManager::BearerAuthFailureHeader(const Status& status) {
             :   const string error_message =
             :       status.GetDetail().empty() ? status.msg().msg() : status.GetDetail();
             :   return Substitute("WWW-Authenticate: Bearer error=\"invalid_token\","
             :       "error_description=\"$0 \"", error_message);
             : }
Please add a test to oauth-servers-manager-test.cc for this function.


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@81
PS17, Line 81: ;) {
             : 
Since line 84 handles the case where `matched_server_idx == size()`, I think this should be: `next_idx < jwt_helpers_->size()`


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@108
PS17, Line 108: i < size()
Should be i < jwt_helpers_->size()


http://gerrit.cloudera.org:8080/#/c/24448/17/be/src/util/oauth-servers-manager.cc@125
PS17, Line 125:   if (server_idx >= size()) {
              :     return Status(Substitute("Invalid OAuth server index $0", server_idx));
              :   }
I don't think this condition will ever be true?  If it can be true, would a DCHECK be sufficient?

If this condition can be true, then it should be modified to something like the following and have a ctest test added for it in oauth-servers-manager-test.cc:
if (UNLIKELY(server_idx >= jwt_helpers_->size())) {



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 17
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Mon, 10 Aug 2026 19:07:00 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#13).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Address follow-up review feedback by adding validateTokenSignature support per
OAuth server config, unifying bearer token authentication logic through
OAuthServersManager for RPC and webserver paths, and tightening manager
selection behavior to prefer matching keys before cryptographic verification.

Testing:
- Incremental Linux build: ninja impalad oauth-server-config-test
  oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
18 files changed, 1,167 insertions(+), 252 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/13
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 13
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 13:

(24 comments)

Done

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@184
PS12, Line 184: DEFINE_bool(jwt_token_auth, false,
> This flag also needs to be deprecated.
Done. Marked --jwt_token_auth as deprecated and updated the help text to direct users to --oauth_token_auth with --oauth_servers


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@224
PS12, Line 224: DEFINE_bool_hidden(jwt_allow_without_tls, false,
> This flag needs to be marked deprecated too.
Done. Marked --jwt_allow_without_tls as deprecated and updated the help text to direct users to --oauth_allow_without_tls


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@796
PS12, Line 796:     const AuthenticationHash& hash, const string& token) {
> This function contains a lot of code in common with Webserver::OAuthTokenAu
Done. Moved common bearer-token decode/verify/username logic into OAuthServersManager::AuthenticateBearerToken() and now both RPC and webserver paths call this shared function.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@797
PS12, Line 797: =
> This function should not need to know whether it's handling JWT or OAuth.
Done. Removed JWT/OAuth mode branching from the RPC bearer-token auth function and switched to a single unified bearer-token flow


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@807
PS12, Line 807:     connection_context->return_headers.push_back(
> Make this message more generic by having it say something like, "Error deco
Done. Updated RPC logging to use generic bearer-token validation errors instead of token-type-specific wording.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@819
PS12, Line 819: }
              : 
              : // Performs a step of SPNEGO auth for the
> Same comment as line 807.  Possibly also include the token's JWKS and key i
Done for the generic wording. I kept logs metadata-light (no JWKS/kid) to avoid leaking token/key identifiers in error paths.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@833
PS12, Line 833:   }
> Same comment as line 807.
Done. Updated this RPC error path to the same generic bearer-token validation wording.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/rpc/authentication.cc@843
PS12, Line 843:   if (spnego_status.ok()) {
> The call to GenerateCookie() should always pass HTTP_AUTH_MECH_OAUTH as the
Done. Updated cookie generation to always pass HTTP_AUTH_MECH_OAUTH.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/service/impala-server.cc@3237
PS12, Line 3237:     if (FLAGS_jwt_token_auth || FLAGS_oauth_token_auth) {
> Unnecessary variable declaration.
Done. Removed the temporary boolean and inlined the condition directly.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc@765
PS12, Line 765:   jwks_pull_timeout_secs_ = jwks_pull_timeout_secs;
              :   jwks_update_frequency_secs_ = jwks_update_frequency_secs;
              :   DCHECK_GT(jwks_pull_timeout_secs_, 0);
              :   DCHECK(is_local_file || jwks_update_frequency_secs_ > 0);
              :   std::shared_ptr<JWKSSnapshot> new_jwks = std::make_shared<JWKSSnapshot>();
              :   if (is_local_file) {
> Now that legacy JWT and OAuth flags are managed by OAuthServersManager, the
Done. Removed fallback usage of those legacy flags in JWKSMgr::Init() and now use timeout/frequency values supplied by manager-driven config.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/jwt-util.cc@852
PS12, Line 852: Status JWTHelper::Init(const std::string& jwks_file_path) {
              :   return Init(jwks_file_path, fals
> Set the ctor/dtor to the default implementation in the header file and dele
Done. Defaulted JWTHelper ctor/dtor in the header and removed explicit ctor/dtor definitions from the .cc file.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.h@40
PS12, Line 40:   int32_t jwks_update_frequency_secs = DEFAULT_JWKS_UPDATE_FREQUENCY_SECS;
> I realize now that OAuthServerConfig needs to have a "validateTokenSignatur
Done. Added validate_token_signature to OAuthServerConfig, parse support for validateTokenSignature in --oauth_servers, and mapping from legacy signature-validation flags


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc@57
PS12, Line 57: namespace impala {
> Need to check jwt_token_auth flag only.
Done.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-server-config.cc@61
PS12, Line 61: bool IsLegacyJwtConfigFlagSpecified() {
> Need to check oauth_token_auth flag only.
Done.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager-test.cc@145
PS12, Line 145:   size_t matched_server_idx = static_cast<size_t>(-1);
              :   Status status = manager.Verify(decoded_token.get(), &matched_server_idx);
> Initialize matched_server_idx to -1 and then check that matched_server_idx 
Done. Updated OAuthServersManagerTest.VerifyFailsWhenOnlyWrongJwksConfigured to initialize with -1 and assert that it remains unchanged on failure.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h@54
PS12, Line 54:       size_t* matched_server_idx_out) const;
> Please also note that on failure, the value of matched_server_idx_out is no
Done. Updated API contract comment and behavior to preserve matched_server_idx_out on verify failure.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.h@66
PS12, Line 66: 
> Nit: The variable name impl_ is not very descriptive.  Please rename it to 
Done. Renamed internal member from impl_ to jwt_helpers_.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc@40
PS12, Line 40:     OAuthServerVerifier verifier;
> Why the switch to using a std::unique_ptr for the JWTHelper instance?  The 
Done. Switched manager storage to hold JWTHelper directly (no std::unique_ptr<JWTHelper> wrapper)


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc@45
PS12, Line 45:     verifier.username_claim = std::move(config.username_claim);
> There is no need to keep the OAuthServerConfig object around once the JWTHe
Done. Removed persistent storage of full OAuthServerConfig from manager internals.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/oauth-servers-manager.cc@57
PS12, Line 57:   size_t matched_server_idx = 0;
             :   RETURN_IF_ERROR(Verify(decoded_token.get(), &matched_server_idx));
             :   RETURN_IF_ERROR(GetUsername(decoded_token.get(), matched_server_idx, username_out));
             :   if (matched_server_idx_out != nullptr) *matched_server_idx_out = matched_server_idx;
             :   return Status::OK();
             : }
             : 
             : Sta
> Verifying decoded_token is a cryptographical operation and thus could poten
Done. Added key preselection via JWTHelper::CanVerify() (kid/algorithm-family check) before signature verification, so cryptographic verify is only attempted on matching helper candidates.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1160
PS12, Line 1160:   (void)connection;
> This function should not need to know whether it's handling JWT or OAuth.
Done. Removed JWT/OAuth mode branching from webserver bearer auth and switched to the same manager-backed bearer-token flow used in RPC


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1169
PS12, Line 1169:     return false;
> Make this message more generic by having it say something like, "Error deco
Done. Updated webserver logs to generic bearer-token validation error wording


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1180
PS12, Line 1180:     return Status::Expected("No Authorization header provided.");
               :   }
               : 
> Same comment as line 1169.  Possibly also include the token's JWKS and key 
Done for generic wording. I intentionally left out JWKS/kid details to avoid logging token key identifiers.


http://gerrit.cloudera.org:8080/#/c/24448/12/be/src/util/webserver.cc@1191
PS12, Line 1191:                << GetRemoteAddress(request_info).ToString() << " Error: " << status;
               :     return status;
> Same comment as line 1169.
Done. Updated this webserver error path to the same generic bearer-token validation wording.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 13
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Mon, 06 Jul 2026 21:56:52 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#10).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest (11/11 passing)
- OAuthServersManagerTest (4/4 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (2/2 passing)
  - test_jwt_auth_with_oauth_servers
  - test_oauth_auth_with_oauth_servers
- Manual end-to-end validation on a Linux Impala test cluster:
  - rebuilt and restarted required local services (HDFS, Hive Metastore,
    HiveServer2) before running auth scenarios
  - verified impala-shell JWT auth and OAuth auth both succeed with
    --oauth_servers using jwksFilePath and execute query smoke checks
  - validated impalad logs contain the effective username and oauth_servers
    configuration usage for successful authentication paths

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
Co-authored-by: Cursor <cu...@cursor.com>
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
A tests/custom_cluster/test_shell_oauth_servers_auth.py
16 files changed, 1,073 insertions(+), 128 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/10
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 10
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 21: Code-Review+1

Looks great to me. +1 from me. If no one else has any questions, I'll +2 this


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 21
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 02 Sep 2026 21:33:00 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 29: Code-Review+2

Carry +2.
Please file a follow-up Jira for the JWT/Oauth logging and metrics issue


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 29
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 17 Sep 2026 20:48:07 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#17).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager, enforce
signature validation for matched servers, add RFC6750 bearer auth response
headers, and apply follow-up review cleanups in JWT helper internals.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
22 files changed, 1,226 insertions(+), 293 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/17
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 17
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 18:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23575/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 18
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Mon, 10 Aug 2026 23:06:41 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#18).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager, enforce
signature validation for matched servers, add RFC6750 bearer auth response
headers, and apply follow-up review cleanups in JWT helper internals.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
22 files changed, 1,223 insertions(+), 293 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/18
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 18
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 18:

(5 comments)

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc@a185
PS18, Line 185: 
              : 
              : 
              : 
              : 
Should we say jwt_validate_signature DEPRECATED instead of removing?


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc@a231
PS18, Line 231: 
              : 
              : 
              : 
              : 
              : 
Should we say oauth_jwt_validate_signature DEPRECATED instead of removing?


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/oauth-server-config.h@32
PS18, Line 32: 4400
Curious that why this is 4400 for update frequency, it doesn't seem like a standard value


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         if (use_jwt_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_jwt_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated && use_oauth_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_oauth_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated) {
              :           if (use_jwt_) {
              :             LOG(INFO) << "Invalid JWT token provided";
              :             total_jwt_token_auth_failure_->Increment(1);
              :           }
              :           if (use_oauth_) {
              :             LOG(INFO) << "Invalid OAuth token provided";
              :             total_oauth_token_auth_failure_->Increment(1);
              :           }
              :         }
Another question is that if it possible both use_jwt_ and use_oauth_ be true? If yes, and they are using the same OAuthTokenAuth(), how can we confirm which is used if OAuthTokenAuth() doesn't return anything? If no, can we add a DCHECK somewhere to say use_jwt_ and use_oauth_ can't be true at the same time?


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         if (use_jwt_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_jwt_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated && use_oauth_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_oauth_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated) {
              :           if (use_jwt_) {
              :             LOG(INFO) << "Invalid JWT token provided";
              :             total_jwt_token_auth_failure_->Increment(1);
              :           }
              :           if (use_oauth_) {
              :             LOG(INFO) << "Invalid OAuth token provided";
              :             total_oauth_token_auth_failure_->Increment(1);
              :           }
              :         }
How about we refactoring this using less checks like this since using the same OAuthTokenAuth() now:
if (use_jwt_ || use_oauth_) {
  if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
    authenticated = true;
    check_csrf_protection = false;
    if (use_jwt_) total_jwt_token_auth_success_->Increment(1);
    if (use_oauth_) total_oauth_token_auth_success_->Increment(1);
  } else {
    if (use_jwt_) {
      LOG(INFO) << "Invalid JWT token provided";
      total_jwt_token_auth_failure_->Increment(1);
    }
    if (use_oauth_) {
      LOG(INFO) << "Invalid OAuth token provided";
      total_oauth_token_auth_failure_->Increment(1);
    }
  }
}



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 18
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 21 Aug 2026 04:38:57 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 11:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23003/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 11
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 24 Jun 2026 22:09:43 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#5).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest
- OAuthServersManagerTest
- tests/custom_cluster/test_shell_oauth_servers_auth.py

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
A tests/custom_cluster/test_shell_oauth_servers_auth.py
16 files changed, 1,119 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/5
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 5
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 8:

(33 comments)

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h
File be/src/runtime/exec-env.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h@110
PS8, Line 110:   OAuthServersManager* GetOAuthServersManager() { return oauth_servers_mgr_.get(); }
Nit: The original names GetJWTHelperInstance() and GetOAuthHelperInstance() did not exactly meet coding standards.  Instead, name this function oauth_servers_mgr() to match the getters like in lines 141-151.  Also, move this function down by those getters instead of being in this one-off location and have it return std::shared_ptr<OAuthServersManager>

std::shared_ptr<OAuthServersManager> oauth_servers_mgr() { return oauth_servers_mgr_; }


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h@299
PS8, Line 299: std::unique_ptr<
Make this a std::shared_ptr to avoid use-after-free issues.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.cc
File be/src/runtime/exec-env.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.cc@578
PS8, Line 578:   oauth_servers_mgr_.reset(new OAuthServersManager());
oauth_servers_mgr_ should be initialized as part of the constructor definition (lines 235-260).


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/service/impala-server.cc@3240
PS8, Line 3240:       vector<OAuthServerConfig> oauth_server_configs;
              :       RETURN_IF_ERROR(BuildOAuthServerConfigs(&oauth_server_configs));
              :       RETURN_IF_ERROR(ExecEnv::GetInstance()->GetOAuthServersManager()->Init(
              :           oauth_server_configs, /*require_jwks=*/true));
This coding structure is sub-optimal since it requires initializing a throwaway vector who's contents are all deep copied in the Init() function.  A better way would be for the Init() function to declare a vector<OAuthServerConfig>, call BuildOAuthServerConfigs(), and std::move() the contents of the vector.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@771
PS8, Line 771:   if (pull_timeout_secs <= 0) {
             :     LOG(WARNING) << "Invalid JWKS pull timeout: " << pull_timeout_secs
             :                  << ", use default value 10.";
             :     pull_timeout_secs = 10;
             :   }
The flag validators for FLAGS_jwks_pulling_timeout_s take care of ensuring its value is greater than 0.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@785
PS8, Line 785:     if (update_frequency_secs <= 0) {
             :       LOG(WARNING) << "Invalid JWKS update frequency: " << update_frequency_secs
             :                    << ", use default value 60.";
             :       update_frequency_secs = 60;
             :     }
The flag validators for FLAGS_jwks_update_frequency_s take care of ensuring its value is greater than 0.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@812
PS8, Line 812:   int32_t update_frequency_secs = jwks_update_frequency_secs_ >= 0 ?
             :       jwks_update_frequency_secs_ : FLAGS_jwks_update_frequency_s;
             :   if (update_frequency_secs <= 0) update_frequency_secs = 60;
             :   int32_t pull_timeout_secs = jwks_pull_timeout_secs_ >= 0 ?
             :       jwks_pull_timeout_secs_ : FLAGS_jwks_pulling_timeout_s;
             :   if (pull_timeout_secs <= 0) pull_timeout_secs = 10;
             :   int64_t timeout_millis = update_frequency_secs * 1000;
The logic in JWKSMgr::Init should take care of ensuring jwks_update_frequency_secs_ and jwks_pull_timeout_secs_ are both greater than 0.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@869
PS8, Line 869: 
             : JWTHelper* CreateJWTHelper() {
             :   return new JWTHelper();
             : }
             : 
             : void DestroyJWTHelper(JWTHelper* helper) {
             :   delete helper;
             : }
These functions are not needed.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config-test.cc
File be/src/util/oauth-server-config-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config-test.cc@164
PS8, Line 164: TEST(OAuthServerConfigTest, BuildOAuthServerConfigsMergesLegacyOAuthFlags) {
Please add another test that combines all three sets of flags (oauth_servers, legacy JWT, and legacy OAuth).


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@17
PS8, Line 17: 
            : #ifndef IMPALA_UTIL_OAUTH_SERVER_CONFIG_H
            : #define IMPALA_UTIL_OAUTH_SERVER_CONFIG_H
Use the newer #pragma once directive instead of macro guards.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@37
PS8, Line 37:   std::string jwks_file_path;
            :   std::string jwks_url;
Instead of having separate fields for jwks file path and url, please consider a single field that accepts either a file://, http://, or https:// url.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@35
PS8, Line 35:   std::string ca_cert_file_path;
            :   bool verify_server_cert = true;
            :   std::string jwks_file_path;
            :   std::string jwks_url;
            :   int32_t jwks_pull_timeout_secs = DEFAULT_JWKS_PULL_TIMEOUT_SECS;
            :   int32_t jwks_update_frequency_secs = DEFAULT_JWKS_UPDATE_FREQUENCY_SECS;
            :   std::string username_claim = "username";
Since this is security related, I would prefer for all these fields to be declared const and set by the constructor.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@48
PS8, Line 48:   /// Returns the JWKS URI to use. If both file and URL are set, the file takes precedence
            :   /// (matching legacy Impala behavior).
            :   Status GetJwksUri(std::string* jwks_uri, bool* is_local_file) const;
Since defining both the JWKS file path and url is legacy behavior, let's keep that out of this new struct and move it to oauth-server-config.cc in the BuildLegacyJwtServerConfig() and BuildLegacyOAuthServerConfig() functions.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@53
PS8, Line 53: /// Parses the --oauth_servers JSON array into 'configs_out'.
            : Status ParseOAuthServersJson(
            :     const std::string& oauth_servers_json, std::vector<OAuthServerConfig>* configs_out);
It's a design smell if a function is exposed only for testing purposes.  C++, much more so than in other languages, does have cases where functions do have to be exposed for testing.  In those cases, declaring namespace test is the preferred way as it avoids polluting the impala namespace (e.g. https://github.com/apache/impala/blob/0b8294b1a5b0ad4a817dee13b7fbb2ee53f534e2/be/src/service/query-profile-ai-analysis.h#L48).

In this specific case, BuildOAuthServerConfigs() is a small wrapper around ParseOAuthServersJson(), and it would be fine to call BuildOAuthServerConfigs() from the CTest tests.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@62
PS8, Line 62: void WarnOnDeprecatedOAuthFlags();
I don't think this function needs to be in the global namespace but rather should be in the anonymous inner namespace.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.cc@31
PS8, Line 31: DECLARE_string(oauth_servers);
Remove, no need to DECLARE_ in the same file where the flag is defined.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager-test.cc@120
PS8, Line 120: TEST(OAuthServersManagerTest, VerifyFailsWhenNoServersConfigured) {
Please add a test that asserts token validation fails when only the testdata/jwt/jwks_rs256.json JWKS is configured.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@17
PS8, Line 17: 
            : #ifndef IMPALA_UTIL_OAUTH_SERVERS_MANAGER_H
            : #define IMPALA_UTIL_OAUTH_SERVERS_MANAGER_H
Use the newer #pragma once directive instead of macro guards.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@40
PS8, Line 40: bool require_jwks
Remove this function parameter since it is `true` in all the main code where this function is called.  The only place I found where it was `false` was in the CTest tests.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@41
PS8, Line 41: 
            :   bool empty() const;
            :   size_t size() const;
            : 
            :   const OAuthServerConfig& config(size_t index) const;
Nit: these simple one-line functions can have their function bodies placed here in the header file instead of separately defining them in the .cc file.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@53
PS8, Line 53: static 
Why is this function declared static instead of being a class member function?


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@35
PS8, Line 35: JWTHelper*
No need to use JWTHelper*, use JWTHelper instead.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@32
PS8, Line 32: struct OAuthServersManager::OAuthServersImpl {
            :   struct OAuthServer {
            :     OAuthServerConfig config;
            :     JWTHelper* jwt_helper = nullptr;
            :   };
            : 
            :   std::vector<OAuthServer> servers;
            : };
This struct is not necessary.  Instead, in the private section of the OAuthServersManager class declaration in the header file, simply put:
using OAuthServersImpl = std::vector<std::pair<OAuthServerConfig, JWTHelper*>>;


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@41
PS8, Line 41: OAuthServersManager::OAuthServersManager()
            :   : impl_(new OAuthServersImpl()) {}
Delete this constructor implementation, and, in the Init() function, do this instead to make it clear when impl_ has truly been initialized:
impl_ = make_unique<OAuthServersImpl>();


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@50
PS8, Line 50:     impl_.reset();
No need to reset impl_, it will be automatically reset when it goes out of scope after this destructor runs.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@55
PS8, Line 55:   return impl_->servers.empty();
Add DCHECK(impl_) to ensure that Init() has been called.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@59
PS8, Line 59:   return impl_->servers.size();
Add DCHECK(impl_) to ensure that Init() has been called.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@63
PS8, Line 63:   return impl_->servers[index].config;
Add DCHECK(impl_) to ensure that Init() has been called.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@88
PS8, Line 88: GetJwksUri
This function duplicates the validation performed in HasJwksSource().


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@93
PS8, Line 93:     if (!is_local_file && TestInfo::is_test()) sleep(1);
Is this sleep necessary?  If so, add a comment explaining why or remove the need for sleeping by a deterministic check (for example, if there is a need to wait until a certain point in the startup process).


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1167
PS8, Line 1167: OAuthServersManager*
Needs to be changed to std::shared_ptr<OAuthServersManager>


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1177
PS8, Line 1177:   } else if (!oauth_servers_mgr->empty()) {
              :     matched_server_idx = 0;
Useless condition, matched_server_idx will already be 0 here.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1219
PS8, Line 1219:   } else if (!oauth_servers_mgr->empty()) {
              :     matched_server_idx = 0;
Useless condition, matched_server_idx will already be 0 here.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 8
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 17 Jun 2026 23:09:40 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 17:

(6 comments)

Done

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/rpc/authentication.cc@794
PS16, Line 794:     connection_context->return_headers.push_back(
              :         OAuthServersManager::BearerAuthFailureHeader(status));
              :     return false;
              :   }
              :   connection_context->username = username;
> Nit: would be nice to have this header generation handled in OAuthServersMa
Done. I moved WWW-Authenticate bearer failure header construction into OAuthServersManager::BearerAuthFailureHeader() and now both RPC and webserver auth paths use this shared helper.


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/jwt-util.cc@1001
PS16, Line 1001:   JWKSSnapshotPtr jwks = GetJWKS();
> Wrap this call with UNLIKELY and add a check for the string length:
Done. CanVerify() now uses UNLIKELY and checks both empty and short algorithm values before prefix parsing.


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc@168
PS16, Line 168:   config.verify_server_cert = FLAGS_jwks_verify_server_certificate;
> This line will not throw an error when compiled in release mode.
Done. I replaced the DCHECK_OK path by making BuildLegacyJwtServerConfig() return Status and propagating SetJwksSource() errors with RETURN_IF_ERROR.


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc@182
PS16, Line 182:   if (!jwks_file_path.empty() && !jwks_url.empty()) jwks_url.clear();
> This line will not throw an error when compiled in release mode.
Done. I applied the same fix for legacy OAuth config: BuildLegacyOAuthServerConfig() now returns Status and propagates SetJwksSource() failures instead of relying on DCHECK.


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc@58
PS16, Line 58: Status OAuthServersManager::AuthenticateBearerToken(const string& token,
             :     string* username_out, size_t* matched_server_idx_out) const {
             :   DCHECK(jwt_helpers_);
             :   DCHECK(username_out != nullptr);
             :   username_out->clear();
             :   JWTHelper::UniqueJWTDecodedToken decoded_token;
             :   RETURN_IF_ERROR(JWTHelper::Decode(token, decoded_token));
             : 
> This code is not very efficient.  FindMatchingServer() is called below from
Done. I removed the pre-verification FindMatchingServer()/username prefetch path from AuthenticateBearerToken().


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc@75
PS16, Line 75:   DCHECK(!jwt_helpers_->empty());
> I realized today that Verify() can only return the username when either the
Done. Username is now only extracted on successful verification in Verify(), we no longer attempt username extraction on failed auth.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 17
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Tue, 04 Aug 2026 22:12:26 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 14:

(15 comments)

Done

http://gerrit.cloudera.org:8080/#/c/24448/13//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24448/13//COMMIT_MSG@13
PS13, Line 13: Remove deprecated JWT/OAuth signature-toggl
> Nit: no need to mention addressing review feedback unless its feedback from
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@190
PS13, Line 190:     "(DEPRECATED) File path of the pre-installed JSON Web Key Set (JWKS) for JWT "
> This flag is dangerous and doesn't make a lot of sense anymore now that mul
Done. I removed --jwt_validate_signature entirely and updated JwtHttpTest so it no longer uses that flag.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@237
PS13, Line 237: // Enables retrieving the OAuth JWKS from the specified URL without verifying the
> This flag is dangerous and doesn't make a lot of sense anymore now that mul
Done. I removed --oauth_jwt_validate_signature entirely.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@802
PS13, Line 802:   }
> Let's also include the username in this error message if the username is no
Done. The error log now appends username when one was extracted.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.h
File be/src/util/jwt-util.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.h@100
PS13, Line 100:   std::unique_ptr<JWKSMgr> jwks_mgr_;
> This is fine to leave as a std::unique_ptr since jwks_mgr_ is not shared ou
Done. jwks_mgr_ is now std::unique_ptr<JWKSMgr> again.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@988
PS13, Line 988: Status JWTHelper::CanVerify(
> Add DCHECK(jwks_mgr_ != nullptr) to ensure that Init() was already called.
Add DCHECK(jwks_mgr_ != nullptr) to ensure that Init() was already called.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@991
PS13, Line 991:   DCHECK(decoded_token != nullptr);
> Should this be an error condition if the jwks is empty?  Possibly the init 
I kept this as a non-error in CanVerify(). An empty JWKS is treated as “cannot verify with this helper” so multi-server matching can continue, the overall verify path still returns a hard failure (Verification failed, no matching key) if no helper can verify.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@995
PS13, Line 995: 
> The "alg" token header parameter is required.  First check if the jwks has 
Done. CanVerify() now requires a non-empty alg, validates algorithm family first, and only considers helpers with matching JWKS key families.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-server-config.h@38
PS13, Line 38:   int32_t jwks_pull_timeout_secs = DEFAULT_JWKS_PULL_TIMEOUT_SECS;
> Delete this struct member.  Token signatures must always be validated.
Done. Removed validate_token_signature from OAuthServerConfig and removed all related parsing/mapping logic.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.h@56
PS13, Line 56:  private:
             :   struct OAuthServerVerifier {
             :     JWTHelper jwt_helper;
> Move this function declaration down into the private section.
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@59
PS13, Line 59:   bool found_username_server = false;
> Let's get the username first so that output function parameter will be set 
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@69
PS13, Line 69:   }
> Put the two jwt_helpers_ DCHECKS next to each other.
Done. Grouped DCHECK(jwt_helpers_) and DCHECK(!jwt_helpers_->empty()) together.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@75
PS13, Line 75: 
> This condition will authorize every token if any of the verifies have valid
Done. I removed that bypass path entirely by removing validate_token_signature support and requiring signature verification for matched helpers.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc@1160
PS13, Line 1160:   }
> Delete this line.  If possible, remove the struct sq_connection* connection
Done. Removed the unused line and removed the sq_connection* parameter from Webserver::OAuthTokenAuth().


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc@1166
PS13, Line 1166:   DCHECK(response_headers != nullptr);
> Need to also set the "WWW-Authenticate" http response header per https://da
Done. Added WWW-Authenticate: Bearer error="invalid_token", error_description="..." on bearer-token auth failures in webserver auth flow.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 14
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 15 Jul 2026 23:33:38 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 24:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/14006/ DRY_RUN=false


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 24
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 09 Sep 2026 21:43:06 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 20: Code-Review+1

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc@a185
PS18, Line 185: 
              : 
              : 
              : 
              : 
> We intentionally removed this flag instead of deprecating it because per th
Done


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc@a231
PS18, Line 231: 
              : 
              : 
              : 
              : 
              : 
> Same reasoning here: we intentionally removed this flag (instead of depreca
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 20
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 27 Aug 2026 19:50:23 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Yida Wu, Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#25).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager, enforce
signature validation for matched servers, add RFC6750 bearer auth response
headers, and apply follow-up review cleanups in JWT helper internals.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)
- org.apache.impala.customcluster.LdapHS2Test#testHiveserver2JwtAndOAuthAuth
  (1/1 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
M tests/custom_cluster/test_shell_jwt_auth.py
M tests/custom_cluster/test_shell_oauth_auth.py
A tests/custom_cluster/test_shell_oauth_servers_auth.py
24 files changed, 1,254 insertions(+), 326 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/25
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 25
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 27:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/14032/ DRY_RUN=false


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 27
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 14 Sep 2026 22:03:15 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 27: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 27
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 15 Sep 2026 02:41:33 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anonymous Coward (Code Review)" <ge...@cloudera.org>.
Anonymous Coward (934) has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 30:

Filed https://issues.apache.org/jira/browse/IMPALA-15372


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 30
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anonymous Coward (934)
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 18 Sep 2026 06:04:26 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 9:

(8 comments)

gerrit-auto-critic failed. You can reproduce it locally using command:

  python3 bin/jenkins/critique-gerrit-review.py --dryrun

To run it, you might need a virtual env with Python3's venv installed.

http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/service/impala-server.cc@3237
PS9, Line 3237:     const bool require_oauth_servers = (FLAGS_jwt_token_auth && FLAGS_jwt_validate_signature)
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/jwt-util.cc@784
PS9, Line 784:         jwks_ca_certificate, current_jwks_checksum_, &is_changed, jwks_pull_timeout_secs_);
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-server-config-test.cc
File be/src/util/oauth-server-config-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-server-config-test.cc@136
PS9, Line 136: TEST(OAuthServerConfigTest, BuildOAuthServerConfigsMergesLegacyJwtFlagsFromUsernameClaim) {
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-server-config-test.cc@189
PS9, Line 189:       R"([{"jwksUrl":"https://example.com/oauth-servers-jwks.json","usernameClaim":"sub"}])";
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-server-config.cc@138
PS9, Line 138: Status ParseOAuthServerObject(const rapidjson::Value& obj, OAuthServerConfig* config_out) {
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-server-config.cc@145
PS9, Line 145:   RETURN_IF_ERROR(ReadOptionalStringField(obj, "caCertFilePath", &config.ca_cert_file_path));
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-server-config.cc@146
PS9, Line 146:   RETURN_IF_ERROR(ReadOptionalBoolField(obj, "verifyServerCert", &config.verify_server_cert));
line too long (94 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/9/be/src/util/oauth-servers-manager-test.cc@104
PS9, Line 104:       R"([{"jwksFilePath":"$0","usernameClaim":"sub"},{"jwksFilePath":"$1","usernameClaim":"sub"}])",
line too long (101 > 90)



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 9
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Jun 2026 09:14:37 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 10:

(47 comments)

http://gerrit.cloudera.org:8080/#/c/24448/10//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24448/10//COMMIT_MSG@37
PS10, Line 37: Co-authored-by: Cursor <cu...@cursor.com>
Please don't add the "Co-authored-by" trailer since Impala uses "Assisted-by".


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@824
PS10, Line 824:   if (FLAGS_jwt_validate_signature) {
              :     status = oauth_servers_mgr->GetUsername(
              :         decoded_token.get(), matched_server_idx, &username);
              :   } else {
              :     DCHECK(!FLAGS_jwt_custom_claim_username.empty());
              :     status = JWTHelper::GetCustomClaimUsername(
              :         decoded_token.get(), FLAGS_jwt_custom_claim_username, username);
              :   }
This block of code contains an abstraction leak that is not the best approach.  It would be best to have the oauth_server_mgr take care of everything.  I understand why it was written the way it was though.

Let's do this -- if FLAGS_jwt_validate_signature is true, then skip the call to oauth_servers_mgr->Verify() but perform every other check.  This means that every incoming JWT will need a corresponding OAuthServerConfig instance defining a JWK for that token.  This approach breaks backwards compatibility, but that is ok with the Impala 5 release.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@874
PS10, Line 874:   if (FLAGS_oauth_jwt_validate_signature) {
              :     status = oauth_servers_mgr->GetUsername(
              :         decoded_token.get(), matched_server_idx, &username);
              :   } else {
              :     DCHECK(!FLAGS_oauth_jwt_custom_claim_username.empty());
              :     status = JWTHelper::GetCustomClaimUsername(
              :         decoded_token.get(), FLAGS_oauth_jwt_custom_claim_username, username);
              :   }
Same comment as line 831.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h
File be/src/runtime/exec-env.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h@110
PS8, Line 110:   ~ExecEnv();
> Done. I renamed and relocated the getter as oauth_servers_mgr() alongside t
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h@299
PS8, Line 299: 
> Done. ExecEnv::oauth_servers_mgr_ is now a std::shared_ptr<OAuthServersMana
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.cc
File be/src/runtime/exec-env.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.cc@578
PS8, Line 578: 
> Done. I moved oauth_servers_mgr_ initialization into the ExecEnv constructo
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/service/impala-server.cc@3240
PS8, Line 3240:       RETURN_IF_ERROR(ExecEnv::GetInstance()->oauth_servers_mgr()->Init());
              :     }
              : 
              :     // Initialize the client servers.
> Done. I moved config construction into OAuthServersManager::Init() and now 
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/service/impala-server.cc@3237
PS10, Line 3237: const bool require_oauth_servers = (FLAGS_jwt_token_auth && FLAGS_jwt_validate_signature)
Need to:
* also check FLAGS_oauth_token_auth
* skip the check of OAuthServerConfig


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.h
File be/src/util/jwt-util.h:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.h@40
PS10, Line 40:   JWTHelper();
             :   ~JWTHelper();
             :   JWTHelper(const JWTHelper&) = delete;
             :   JWTHelper& operator=(const JWTHelper&) = delete;
             :   JWTHelper(JWTHelper&&) noexcept;
             :   JWTHelper& operator=(JWTHelper&&) noexcept;
Why were these added?  They shouldn't be necesary.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@771
PS8, Line 771:   DCHECK_GT(jwks_pull_timeout_secs_, 0);
             :   DCHECK(is_local_file || jwks_update_frequency_secs_ > 0);
             :   std::shared_ptr<JWKSSnapshot> new_jwks = std::make_shared<JWKSSnapshot>();
             :   if (is_local_file) {
             :    
> Done. I removed the warning/default fallback path and now rely on validated
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@785
PS8, Line 785:     if (!status.ok()) {
             :       LOG(ERROR) << "Failed to load JWKS: " << status;
             :       return status;
             :     }
             :     D
> Done. I removed the warning/default fallback for update frequency and use r
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@812
PS8, Line 812:     new_jwks = std::make_shared<JWKSSnapshot>();
             :     bool is_changed = false;
             :     Status status =
             :         new_jwks->LoadKeysFromUrl(jwks_uri_, jwks_verify_server_certificate_,
             :             jwks_ca_certificate_, current_jwks_checksum_, &is_changed,
             :             jwks_pull_timeout_secs_);
             :     if (!status.ok()) {
> Done. JWKSMgr::Init() now resolves these values once and UpdateJWKSThread()
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@869
PS8, Line 869:   jwks_mgr_.reset(new JWKSMgr());
             :   RETURN_IF_ERROR(jwks_mgr_->Init(jwks_uri, jwks_verify_server_certificate,
             :       jwks_ca_certificate, is_local_file, jwks_pull_timeout_secs,
             :       jwks_update_frequency_secs));
             :   if (!initialized_) initialized_ = true;
             :   return Status::OK();
             : }
             : 
> Done. I removed CreateJWTHelper() / DestroyJWTHelper() and switched manager
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.cc@803
PS10, Line 803:   DCHECK_GT(jwks_update_frequency_secs_, 0);
              :   DCHECK_GT(jwks_pull_timeout_secs_, 0);
I believe the DCHECKS in JWKSMgr::Init take care of this validation which means these DCHECKS are duplicates that can be removed.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config-test.cc
File be/src/util/oauth-server-config-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config-test.cc@164
PS8, Line 164:   FLAGS_jwks_url = "https://example.com/jwks.json";
> Done. Added BuildOAuthServerConfigsCombinesJsonLegacyJwtAndLegacyOAuth.
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config.h@42
PS10, Line 42:   /// Returns true if this server has a JWKS source configured.
             :   bool HasJwksSource() const {
             :     return !jwks_uri.empty();
             :   }
This function should be deleted since it will never return `false` because the SetJwksSource() function in oauth-server-config.cc requires either the JWKS uri or path to be set.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@17
PS8, Line 17: 
            : #pragma once
            : 
> Done. Converted oauth-server-config.h to #pragma once.
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@37
PS8, Line 37:   bool is_local_jwks = false;
            :   int32_t jwks_pull_tim
> Done. Replaced separate jwks_file_path / jwks_url with jwks_uri plus is_loc
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@35
PS8, Line 35:   bool verify_server_cert = true;
            :   std::string jwks_uri;
            :   bool is_local_jwks = false;
            :   int32_t jwks_pull_timeout_secs = DEFAULT_JWKS_PULL_TIMEOUT_SECS;
            :   int32_t jwks_update_frequency_secs = DEFAULT_JWKS_UPDATE_FREQUENCY_SECS;
            :   std::string username_claim = "username";
            : 
> I did not convert OAuthServerConfig to fully constructor-only immutable fie
Please convert OAuthServerConfig to constructor-only immutable fields.  It's better to do it right the first time.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@48
PS8, Line 48: /// Builds the full list of OAuth server configs from --oauth_servers plus any legacy
            : /// jwks_* / oauth_* startup flags.
            : Status BuildOAuthServerConfigs(std::vector<OAuthServerConfig>* configs
> Done. Legacy file-vs-url preference behavior is now contained in legacy bui
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@53
PS8, Line 53: 
            : 
            : 
> Done. I removed ParseOAuthServersJson() from the header and updated tests t
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@62
PS8, Line 62: 
> Done. Deprecated-flag warning helper path is now kept internal (anonymous n
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.cc@31
PS8, Line 31: DECLARE_string(jwks_file_path);
> Done. Removed redundant DECLARE_string(oauth_servers)
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager-test.cc@120
PS8, Line 120:   google::FlagSaver flag_saver;
> Done. Added VerifyFailsWhenOnlyWrongJwksConfigured.
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager-test.cc@55
PS10, Line 55: 
The VerifyFailsWhenNoServersConfigured() test from patchset 8 should also be included in this file.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.h@67
PS10, Line 67:   std::shared_ptr<OAuthServersImpl> impl_;
This should be a std::unique_ptr<OAuthServersImpl> since the impl_ class member variable is never directly returned.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@17
PS8, Line 17: 
            : #pragma once
            : 
> Done. Converted oauth-servers-manager.h to #pragma once.
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@40
PS8, Line 40: 
> Done. Removed require_jwks parameter from manager init and adjusted tests t
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@41
PS8, Line 41:   }
            : 
            :   size_t size() const {
            :     DCHECK(impl_);
            :     return impl_->size();
> Done. Inlined one-line methods (empty(), size(), config()) in the header.
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@53
PS8, Line 53: /// Ver
> Done. Converted GetUsername() from static helper to class member method.
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@35
PS8, Line 35: 
> Done. Manager now stores JWTHelper objects, not pointers.
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@32
PS8, Line 32:   RETURN_IF_ERROR(BuildOAuthServerConfigs(&configs));
            :   return InitWithConfigs(std::move(configs));
            : }
            : 
            : Status OAuthServersManager::InitWithConfigs(vector<OAuthServerConfig>&& configs) {
            :   impl_ = std::make_shared<OAuthServersImpl>();
            :   impl_->reserve(configs.size());
            :   
> Done (adapted with comment 18). I removed the extra struct and now use a pr
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@41
PS8, Line 41:   for (OAuthServerConfig& config : configs) {
            :     if (!config.HasJwksSource()) con
> Done (using shared ownership from related comments). I removed the construc
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@50
PS8, Line 50:     impl_->emplace_back(std::move(config), std::move(jwt_helper));
> Done. Removed manual reset/destructor cleanup path.
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@55
PS8, Line 55:   }
> Done. Added DCHECK(impl_) checks in manager accessors/paths.
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@59
PS8, Line 59: Status OAuthServersManager::Verify(const JWTHelper::JWTDecodedToken* decoded_token,
> Done. Added corresponding DCHECK(impl_).
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@63
PS8, Line 63:   DCHECK(matched_server_idx_out != nullptr);
> Done. Added corresponding DCHECK(impl_).
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@88
PS8, Line 88: ername_cla
> Done. Removed duplicate validation path and rely on HasJwksSource() flow.
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@93
PS8, Line 93: 
> Done. Removed the test-only sleep from manager initialization.
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc@36
PS10, Line 36: Status OAuthServersManager::InitWithConfigs(vector<OAuthServerConfig>&& configs) {
This InitWithConfigs function is unnecessary since it is only called once.  Move its code into OAuthServersManager::Init and remove the function.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc@64
PS10, Line 64:   if (impl_->empty()) {
             :     return Status("No OAuth servers are configured for token verification");
             :   }
Is this check already performed elsewhere?


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1167
PS8, Line 1167: 
> Done. Updated Webserver auth paths to use std::shared_ptr<OAuthServersManag
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1177
PS8, Line 1177:     }
              :   }
> Done. Removed redundant matched_server_idx reset/condition in JWT web auth 
Done


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1219
PS8, Line 1219: 
              :   string username;
> Done. Removed redundant matched_server_idx reset/condition in OAuth web aut
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc@1181
PS10, Line 1181:   if (FLAGS_jwt_validate_signature) {
               :     status = oauth_servers_mgr->GetUsername(decoded_token.get(), matched_server_idx,
               :         &username);
               :   } else {
               :     DCHECK(!FLAGS_jwt_custom_claim_username.empty());
               :     status = JWTHelper::GetCustomClaimUsername(
               :         decoded_token.get(), FLAGS_jwt_custom_claim_username, username);
               :   }
Same comment as https://gerrit.cloudera.org/c/24448/10/be/src/rpc/authentication.cc#831.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc@1221
PS10, Line 1221:   if (FLAGS_oauth_jwt_validate_signature) {
               :     status = oauth_servers_mgr->GetUsername(decoded_token.get(), matched_server_idx,
               :         &username);
               :   } else {
               :     DCHECK(!FLAGS_oauth_jwt_custom_claim_username.empty());
               :     status = JWTHelper::GetCustomClaimUsername(
               :         decoded_token.get(), FLAGS_oauth_jwt_custom_claim_username, username);
               :   }
Same comment as https://gerrit.cloudera.org/c/24448/10/be/src/rpc/authentication.cc#831.


http://gerrit.cloudera.org:8080/#/c/24448/10/tests/custom_cluster/test_shell_oauth_servers_auth.py
File tests/custom_cluster/test_shell_oauth_servers_auth.py:

http://gerrit.cloudera.org:8080/#/c/24448/10/tests/custom_cluster/test_shell_oauth_servers_auth.py@62
PS10, Line 62:   def test_jwt_auth_with_oauth_servers(self, vector):
Add a similar test that sets the legacy oauth_ flags.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 10
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Jun 2026 22:10:25 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Yida Wu, Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#22).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager, enforce
signature validation for matched servers, add RFC6750 bearer auth response
headers, and apply follow-up review cleanups in JWT helper internals.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
M tests/custom_cluster/test_shell_jwt_auth.py
M tests/custom_cluster/test_shell_oauth_auth.py
A tests/custom_cluster/test_shell_oauth_servers_auth.py
24 files changed, 1,244 insertions(+), 319 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/22
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 22
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 22: Code-Review+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 22
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 09 Sep 2026 04:07:26 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 22: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 22
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 09 Sep 2026 13:10:00 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 23:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/13998/ DRY_RUN=false


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 23
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 09 Sep 2026 13:10:25 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 19:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         if (use_jwt_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_jwt_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated && use_oauth_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_oauth_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated) {
              :           if (use_jwt_) {
              :             LOG(INFO) << "Invalid JWT token provided";
              :             total_jwt_token_auth_failure_->Increment(1);
              :           }
              :           if (use_oauth_) {
              :             LOG(INFO) << "Invalid OAuth token provided";
              :             total_oauth_token_auth_failure_->Increment(1);
              :           }
              :         }
> Good question. In the current flow, if both are enabled we intentionally tr
If my understanding is correct, the problem is that, the if use_jwt_ block succeeding doesn't actually guarantee that a JWT config was used as it can fall back to OAuth internally. Therefore, the separated metrics and logging based purely on use_jwt_ and use_oauth_ can be incorrect here.
I also think this is too confusing because the two calls to OAuthTokenAuth() are now completely identical. The only difference is which metrics and logging get triggered around them. Previously this structure made sense because JWT and OAuth were calling different interfaces, but now that they are using the same one, we probably need a better way to know what was actually used inside OAuthTokenAuth() to ensure the accuracy of the metrics.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 19
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 25 Aug 2026 04:44:23 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 19:

(1 comment)

Done

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         if (use_jwt_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_jwt_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated && use_oauth_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_oauth_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated) {
              :           if (use_jwt_) {
              :             LOG(INFO) << "Invalid JWT token provided";
              :             total_jwt_token_auth_failure_->Increment(1);
              :           }
              :           if (use_oauth_) {
              :             LOG(INFO) << "Invalid OAuth token provided";
              :             total_oauth_token_auth_failure_->Increment(1);
              :           }
              :         }
> If my understanding is correct, the problem is that, the if use_jwt_ block 
Good point. Your understanding is correct that, with unified OAuthServersManager verification, the mode-specific JWT/OAuth counters in this block reflect the caller path/compatibility mode rather than exact underlying provider identity when both flags are enabled. We kept this behavior intentionally to preserve JWT-first then OAuth-fallback compatibility semantics in this change. If we want precise provider attribution in metrics/logging, that would require a follow-up API extension to return provider/source metadata from the verifier.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 19
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 25 Aug 2026 05:40:29 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 16:

(8 comments)

Done

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/rpc/authentication.cc@790
PS14, Line 790:     LOG(ERROR) << "Error validating bearer token in Authorization header received from: "
> Nit: this variable declaration is not really necessary since its only used 
I inlined that expression into the log statement and removed the extra variable.


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@852
PS14, Line 852: void JWTHelper::TokenDeleter::operator()(JWTHelper::JWTDecodedToken* token) const {
              :   if (token != nullptr) delete token;
              : };
              : 
> Nit: since there is no code here, remove these lines and set the constructo
I defaulted the ctor/dtor/move members directly in jwt-util.h and removed the out-of-line defaults from jwt-util.cc


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@1006
PS14, Line 1006: 
> Nit: add the `const` keyword to this variable declaration.
Done. Added const to the variable declaration


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@1009
PS14, Line 1009:     key_map = jwks->GetAllHSKeys();
               :   } else if (prefix == RS_ALGORITHM_PREFIX || prefix == PS_ALGORITHM_PREFIX) {
               :     key_map = jwks->GetAllRSAPublicKeys();
               :   } else if (prefix == ES_ALGORITHM_PREFIX) {
               :     key_map = jwks->GetAllECPu
> Even though existing code uses magic strings for the algorithm prefixes, pl
Done. Replaced the literal prefixes with named constants for algorithm-family checks.


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.h@53
PS14, Line 53:   /// failure, 'matched_server_idx_out' is not modified.
> This function is only called from within OAuthServersManager.  Move it to t
Done. Moved Verify() to the private section of OAuthServersManager


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc@51
PS14, Line 51: Status OAuthServersManager::AuthenticateBearerToken(const string& token,
> There is duplicate code in this function and OAuthServersManager::Verify.
Done. I extracted the shared server-match logic into FindMatchingServer() and reused it from both paths.


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc@55
PS14, Line 55:   JWTHelper::UniqueJWTDecodedToken decoded_token;
> Is this line necessary?
Done. Removed the unnecessary line as part of the shared-logic cleanup in AuthenticateBearerToken()


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/webserver.cc@753
PS14, Line 753:   // Random value from cookie that we'll also use as a csrf_token to implement the
              :   // "Double Submit Cookie" and custom header (X-Requested-By) patterns for preventing
              :   // cross-site request forgery (CSRF).
              :   std::string cookie_rand_value;
              :   // With JWTs we can skip CSRF protection because browsers won't send "Authorization:
              :   // Bearer" headers automatically.
              :   bo
> What is the reason for this code?  The WWW-Authenticate header is only adde
Done. Removed that dead header-removal block from the success path in webserver auth flow.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 16
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 29 Jul 2026 21:27:40 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#14).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Remove deprecated JWT/OAuth signature-toggle flags, always enforce signature
validation through oauth_servers-backed JWKS selection, include username context
in bearer-auth failures, and add RFC6750 WWW-Authenticate response headers.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
Co-authored-by: Cursor <cu...@cursor.com>
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
22 files changed, 1,224 insertions(+), 293 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/14
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 14
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 10:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/22938/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 10
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Jun 2026 09:41:15 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#11).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest (11/11 passing)
- OAuthServersManagerTest (4/4 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (2/2 passing)
  - test_jwt_auth_with_oauth_servers
  - test_oauth_auth_with_oauth_servers
- Manual end-to-end validation on a Linux Impala test cluster:
  - rebuilt and restarted required local services (HDFS, Hive Metastore,
    HiveServer2) before running auth scenarios
  - verified impala-shell JWT auth and OAuth auth both succeed with
    --oauth_servers using jwksFilePath and execute query smoke checks
  - validated impalad logs contain the effective username and oauth_servers
    configuration usage for successful authentication paths

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
A tests/custom_cluster/test_shell_oauth_servers_auth.py
17 files changed, 1,090 insertions(+), 218 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/11
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 11
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#4).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest
- OAuthServersManagerTest
- tests/custom_cluster/test_shell_oauth_servers_auth.py

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Co-authored-by: Cursor <cu...@cursor.com>
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
A tests/custom_cluster/test_shell_oauth_servers_auth.py
16 files changed, 1,119 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/4
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 4
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#8).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest (11/11 passing)
- OAuthServersManagerTest (4/4 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (2/2 passing)
  - test_jwt_auth_with_oauth_servers
  - test_oauth_auth_with_oauth_servers
- Manual end-to-end validation on a Linux Impala test cluster:
  - rebuilt and restarted required local services (HDFS, Hive Metastore,
    HiveServer2) before running auth scenarios
  - verified impala-shell JWT auth and OAuth auth both succeed with
    --oauth_servers using jwksFilePath and execute query smoke checks
  - validated impalad logs contain the effective username and oauth_servers
    configuration usage for successful authentication paths

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
A tests/custom_cluster/test_shell_oauth_servers_auth.py
16 files changed, 1,119 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/8
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 8
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 16:

Build Failed 

https://jenkins.impala.io/job/gerrit-code-review-checks/23452/ : Initial code review checks failed. See linked job for details on the failure.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 16
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 29 Jul 2026 21:22:29 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 22:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23919/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 22
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 04 Sep 2026 07:06:42 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 16:

(14 comments)

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/rpc/authentication.cc@790
PS14, Line 790:     LOG(ERROR) << "Error validating bearer token in Authorization header received from: "
> I inlined that expression into the log statement and removed the extra vari
Done


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/rpc/authentication.cc@794
PS16, Line 794:     const string error_message =
              :         status.GetDetail().empty() ? status.msg().msg() : status.GetDetail();
              :     connection_context->return_headers.push_back(
              :         Substitute("WWW-Authenticate: Bearer error=\"invalid_token\",\
              : error_description=\"$0 \"", error_message));
Nit: would be nice to have this header generation handled in OAuthServersManager so this logic is contained in one place instead of being duplicated in be/src/util/webserver.cc.


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@852
PS14, Line 852: void JWTHelper::TokenDeleter::operator()(JWTHelper::JWTDecodedToken* token) const {
              :   if (token != nullptr) delete token;
              : };
              : 
> I defaulted the ctor/dtor/move members directly in jwt-util.h and removed t
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@1006
PS14, Line 1006: 
> Done. Added const to the variable declaration
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@1009
PS14, Line 1009:     key_map = jwks->GetAllHSKeys();
               :   } else if (prefix == RS_ALGORITHM_PREFIX || prefix == PS_ALGORITHM_PREFIX) {
               :     key_map = jwks->GetAllRSAPublicKeys();
               :   } else if (prefix == ES_ALGORITHM_PREFIX) {
               :     key_map = jwks->GetAllECPu
> Done. Replaced the literal prefixes with named constants for algorithm-fami
Done


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/jwt-util.cc@1001
PS16, Line 1001:   if (algorithm.empty()) {
Wrap this call with UNLIKELY and add a check for the string length:
if (UNLIKELY(algorithm.empty() || algorithm.length() < 2)) {


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc@168
PS16, Line 168:   DCHECK_OK(SetJwksSource(jwks_file_path, jwks_url, &config));
This line will not throw an error when compiled in release mode.


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-server-config.cc@182
PS16, Line 182:   DCHECK_OK(SetJwksSource(jwks_file_path, jwks_url, &config));
This line will not throw an error when compiled in release mode.


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.h@53
PS14, Line 53:   /// failure, 'matched_server_idx_out' is not modified.
> Done. Moved Verify() to the private section of OAuthServersManager
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc@51
PS14, Line 51: Status OAuthServersManager::AuthenticateBearerToken(const string& token,
> Done. I extracted the shared server-match logic into FindMatchingServer() a
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc@55
PS14, Line 55:   JWTHelper::UniqueJWTDecodedToken decoded_token;
> Done. Removed the unnecessary line as part of the shared-logic cleanup in A
Done


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc@58
PS16, Line 58:   size_t username_server_idx = size();
             :   RETURN_IF_ERROR(FindMatchingServer(decoded_token.get(), 0, &username_server_idx));
             :   if (username_server_idx < size()) {
             :     Status username_status =
             :         GetUsername(decoded_token.get(), username_server_idx, username_out);
             :     if (!username_status.ok()) username_out->clear();
             :   }
             : 
This code is not very efficient.  FindMatchingServer() is called below from the Verify() function, and, if the decoded_token does not specify a key id (which is common), then FindMatchingServer() returns the first OAuth server that has a key that supports the same algorithm as the decoded_token.

Remove this code and update Verify() to return the username.


http://gerrit.cloudera.org:8080/#/c/24448/16/be/src/util/oauth-servers-manager.cc@75
PS16, Line 75: Status OAuthServersManager::Verify(const JWTHelper::JWTDecodedToken* decoded_token,
I realized today that Verify() can only return the username when either the token verification succeeds or the decoded_token has a key id that exactly matches a key id from an OAuth server's JWKS.  The reason is those are the only two cases when we can be absolutely sure the correct username claim is read.

It's not as important as I originally thought to return the user name when token verification fails.  Let's skip implementing the second case (decoded_token key id matches a JWKS key id) and instead ensure a message is logged somewhere (not necessarily here) containing the client IP on failed auth.  I see log messages in be/src/rpc/authentication.cc and be/src/util/webserver.cc, so no new log messages should be needed (unless I am misunderstanding the code).


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/webserver.cc@753
PS14, Line 753:   // Random value from cookie that we'll also use as a csrf_token to implement the
              :   // "Double Submit Cookie" and custom header (X-Requested-By) patterns for preventing
              :   // cross-site request forgery (CSRF).
              :   std::string cookie_rand_value;
              :   // With JWTs we can skip CSRF protection because browsers won't send "Authorization:
              :   // Bearer" headers automatically.
              :   bo
> Done. Removed that dead header-removal block from the success path in webse
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 16
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Mon, 03 Aug 2026 23:08:37 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 17:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23516/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 17
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Tue, 04 Aug 2026 22:28:12 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 19:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         if (use_jwt_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_jwt_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated && use_oauth_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_oauth_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated) {
              :           if (use_jwt_) {
              :             LOG(INFO) << "Invalid JWT token provided";
              :             total_jwt_token_auth_failure_->Increment(1);
              :           }
              :           if (use_oauth_) {
              :             LOG(INFO) << "Invalid OAuth token provided";
              :             total_oauth_token_auth_failure_->Increment(1);
              :           }
              :         }
> Good point. Your understanding is correct that, with unified OAuthServersMa
I don't think we need to keep this two block structure just to preserve the order the metric counters.
Consider what happens on a failing token when both flags are set, the use_jwt_ block runs OAuthTokenAuth(). It fails, authenticated stays false, so we fall into the use_oauth_ block and call OAuthTokenAuth() again on the exact same token.
Since the function doesn't know which mode is calling it, it just fails the same check a second time. And not only this, I think it may also push a second WWW-Authenticate header onto the response, so the client receives a duplicate header on every failed request when both flags are enabled.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 19
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 25 Aug 2026 06:21:29 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 10:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@796
PS10, Line 796: bool JWTTokenAuth(ThriftServer::ConnectionContext* connection_context,
Now that all JWT/OAuth configs (including legacy configs) are in one place in oauth_servers_mgr(), let's get rid of the duplicate JWTTokenAuth function and use only the OAuthTokenAuth function (since that function contains slightly different logic to add a response header).


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc@1158
PS10, Line 1158: bool Webserver::JWTTokenAuth(const std::string& jwt_token,
Now that all JWT/OAuth configs (including legacy configs) are in one place in oauth_servers_mgr(), let's get rid of the duplicate Webserver::JWTTokenAuth function and use only the Webserver::OAuthTokenAuth function (since that function contains slightly different logic to add a response header).



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 10
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 24 Jun 2026 18:02:16 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#12).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest (11/11 passing)
- OAuthServersManagerTest (4/4 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (2/2 passing)
  - test_jwt_auth_with_oauth_servers
  - test_oauth_auth_with_oauth_servers
- Manual end-to-end validation on a Linux Impala test cluster:
  - rebuilt and restarted required local services (HDFS, Hive Metastore,
    HiveServer2) before running auth scenarios
  - verified impala-shell JWT auth and OAuth auth both succeed with
    --oauth_servers using jwksFilePath and execute query smoke checks
  - validated impalad logs contain the effective username and oauth_servers
    configuration usage for successful authentication paths

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
A tests/custom_cluster/test_shell_oauth_servers_auth.py
17 files changed, 1,089 insertions(+), 218 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/12
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 12
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 12:

(16 comments)

http://gerrit.cloudera.org:8080/#/c/24448/10//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24448/10//COMMIT_MSG@37
PS10, Line 37: 
> Please don't add the "Co-authored-by" trailer since Impala uses "Assisted-b
Done


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@796
PS10, Line 796: bool OAuthTokenAuth(ThriftServer::ConnectionContext* connection_context,
> Now that all JWT/OAuth configs (including legacy configs) are in one place 
Done. Removed JWTTokenAuth() and now both JWT and OAuth HTTP auth paths use OAuthTokenAuth(..., use_jwt_auth)


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@824
PS10, Line 824: error_description=\"$0 \"", status.GetDetail()));
              :       return false;
              :     }
              :   }
              : 
              :   string username;
              :   status = oauth_servers_mgr->GetUsername(
              :    
> This block of code contains an abstraction leak that is not the best approa
Done. Auth now consistently goes through oauth_servers_mgr. For JWT/OAuth, verification is conditional on the corresponding signature-validation flag, while decode + username extraction continue through manager-backed config.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/rpc/authentication.cc@874
PS10, Line 874:     if (*is_complete) {
              :       if (username.empty()) {
              :         spnego_status = kudu::Status::RuntimeError(
              :             "SPNEGO indicated complete, but got empty principal");
              :         // Crash in debug builds, but fall through to treating as an error in release.
              :         LOG(DFATAL) << "Got no authenticated principal for SPNEGO-authenticated "
              :                     << " connection from "
              :    
> Same comment as line 831.
Addressed with the same fix as above.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/service/impala-server.cc@3237
PS10, Line 3237: const bool require_oauth_servers = FLAGS_jwt_token_auth || FLAGS_oauth_token_auth;
> Need to:
Done. Startup now initializes oauth_servers_mgr when either JWT or OAuth token auth is enabled, without the extra pre-check.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.h
File be/src/util/jwt-util.h:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.h@40
PS10, Line 40:   JWTHelper();
             :   ~JWTHelper();
             :   JWTHelper(const JWTHelper&) = delete;
             :   JWTHelper& operator=(const JWTHelper&) = delete;
             : 
             :   /// Opaque types for storing the JWT decode
> Why were these added?  They shouldn't be necesary.
Kept only what is needed for safe ownership/lifetime. The current JWTHelper declarations are intentionally minimal for non-copyable behavior and correct destruction with forward-declared internals.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/jwt-util.cc@803
PS10, Line 803:   std::shared_ptr<JWKSSnapshot> new_jwks;
              :   int64_t timeout_millis = jwks_update_f
> I believe the DCHECKS in JWKSMgr::Init take care of this validation which m
Done. Removed the redundant DCHECK in JWKSMgr::UpdateJWKSThread() and rely on initialization-time validation.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-server-config.h@42
PS10, Line 42: 
             : /// Builds the full list of OAuth server configs from --oauth_servers plus any legacy
             : /// jwks_* / oauth_* startup flags.
             : Sta
> This function should be deleted since it will never return `false` because 
Done. Removed the redundant HasJwksSource() exposure; source validation is enforced during config construction.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager-test.cc@55
PS10, Line 55: 
> The VerifyFailsWhenNoServersConfigured() test from patchset 8 should also b
Done. Added VerifyFailsWhenNoServersConfigured() coverage.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.h@67
PS10, Line 67: };
> This should be a std::unique_ptr<OAuthServersImpl> since the impl_ class me
Done. impl_ is now std::unique_ptr<OAuthServersImpl>


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc@36
PS10, Line 36:   impl_ = std::make_unique<OAuthServersImpl>();
> This InitWithConfigs function is unnecessary since it is only called once. 
Done. Inlined InitWithConfigs() logic into Init() and removed the extra method.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/oauth-servers-manager.cc@64
PS10, Line 64:   }
             :   return last_error;
             : }
> Is this check already performed elsewhere?
Yes. The validation is already enforced during config parsing/construction and init flow, redundant check removed.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc@1158
PS10, Line 1158: bool Webserver::OAuthTokenAuth(const std::string& token,
> Now that all JWT/OAuth configs (including legacy configs) are in one place 
Done. Removed Webserver::JWTTokenAuth() and now both JWT/OAuth paths use Webserver::OAuthTokenAuth(..., use_jwt_auth)


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc@1181
PS10, Line 1181:                  << " token in Authorization header, "
               :                  << "Error: " << status;
               :       return false;
               :     }
               :   }
               : 
               :   string username;
               :   s
> Same comment as https://gerrit.cloudera.org/c/24448/10/be/src/rpc/authentic
Addressed with the same manager-centric auth flow update.


http://gerrit.cloudera.org:8080/#/c/24448/10/be/src/util/webserver.cc@1221
PS10, Line 1221:     request_info->remote_user = strdup(username.c_str());
               :     return Status::OK();
               :   }
               : 
               :   return Status::Expected("Failed to authenticate to LDAP.");
               : }
               : 
               : voi
> Same comment as https://gerrit.cloudera.org/c/24448/10/be/src/rpc/authentic
Addressed with the same manager-centric auth flow update.


http://gerrit.cloudera.org:8080/#/c/24448/10/tests/custom_cluster/test_shell_oauth_servers_auth.py
File tests/custom_cluster/test_shell_oauth_servers_auth.py:

http://gerrit.cloudera.org:8080/#/c/24448/10/tests/custom_cluster/test_shell_oauth_servers_auth.py@62
PS10, Line 62:     impalad_args=JWT_IMPALAD_ARGS,
> Add a similar test that sets the legacy oauth_ flags.
Done. Added legacy OAuth flags custom-cluster test coverage.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 12
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Wed, 24 Jun 2026 23:15:28 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 4:

(5 comments)

gerrit-auto-critic failed. You can reproduce it locally using command:

  python3 bin/jenkins/critique-gerrit-review.py --dryrun

To run it, you might need a virtual env with Python3's venv installed.

http://gerrit.cloudera.org:8080/#/c/24448/4/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/4/be/src/service/impala-server.cc@3237
PS4, Line 3237:     const bool require_oauth_servers = (FLAGS_jwt_token_auth && FLAGS_jwt_validate_signature)
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/4/be/src/util/oauth-server-config-test.cc
File be/src/util/oauth-server-config-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/4/be/src/util/oauth-server-config-test.cc@127
PS4, Line 127: TEST(OAuthServerConfigTest, BuildOAuthServerConfigsMergesLegacyJwtFlagsFromUsernameClaim) {
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/4/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/4/be/src/util/oauth-server-config.cc@120
PS4, Line 120: Status ParseOAuthServerObject(const rapidjson::Value& obj, OAuthServerConfig* config_out) {
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/4/be/src/util/oauth-server-config.cc@125
PS4, Line 125:   RETURN_IF_ERROR(ReadOptionalStringField(obj, "caCertFilePath", &config.ca_cert_file_path));
line too long (93 > 90)


http://gerrit.cloudera.org:8080/#/c/24448/4/be/src/util/oauth-server-config.cc@126
PS4, Line 126:   RETURN_IF_ERROR(ReadOptionalBoolField(obj, "verifyServerCert", &config.verify_server_cert));
line too long (94 > 90)



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 4
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Fri, 12 Jun 2026 00:53:11 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 13:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/23112/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 13
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Mon, 06 Jul 2026 22:09:45 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 14:

(23 comments)

http://gerrit.cloudera.org:8080/#/c/24448/13//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/24448/13//COMMIT_MSG@13
PS13, Line 13: Remove deprecated JWT/OAuth signature-toggl
> Done
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@190
PS13, Line 190:     "(DEPRECATED) File path of the pre-installed JSON Web Key Set (JWKS) for JWT "
> Done. I removed --jwt_validate_signature entirely and updated JwtHttpTest s
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@237
PS13, Line 237: // Enables retrieving the OAuth JWKS from the specified URL without verifying the
> Done. I removed --oauth_jwt_validate_signature entirely.
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/rpc/authentication.cc@802
PS13, Line 802:   }
> Done. The error log now appends username when one was extracted.
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/rpc/authentication.cc@790
PS14, Line 790:     const string username_msg = username.empty()
Nit: this variable declaration is not really necessary since its only used once.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.h
File be/src/util/jwt-util.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.h@100
PS13, Line 100:   std::unique_ptr<JWKSMgr> jwks_mgr_;
> Done. jwks_mgr_ is now std::unique_ptr<JWKSMgr> again.
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@988
PS13, Line 988: Status JWTHelper::CanVerify(
> Add DCHECK(jwks_mgr_ != nullptr) to ensure that Init() was already called.
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@991
PS13, Line 991:   DCHECK(decoded_token != nullptr);
> I kept this as a non-error in CanVerify(). An empty JWKS is treated as “can
Makes sense.  let's leave it as-is.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/jwt-util.cc@995
PS13, Line 995: 
> Done. CanVerify() now requires a non-empty alg, validates algorithm family 
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@852
PS14, Line 852: JWTHelper::JWTHelper() = default;
              : JWTHelper::~JWTHelper() = default;
              : JWTHelper::JWTHelper(JWTHelper&&) noexcept = default;
              : JWTHelper& JWTHelper::operator=(JWTHelper&&) noexcept = default;
Nit: since there is no code here, remove these lines and set the constructors to default in jwt-util.h.


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@1006
PS14, Line 1006:   string prefix = algorithm.substr(0, 2);
Nit: add the `const` keyword to this variable declaration.


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/jwt-util.cc@1009
PS14, Line 1009:   if (prefix == "hs") {
               :     key_map = jwks->GetAllHSKeys();
               :   } else if (prefix == "rs" || prefix == "ps") {
               :     key_map = jwks->GetAllRSAPublicKeys();
               :   } else if (prefix == "es") {
Even though existing code uses magic strings for the algorithm prefixes, please avoid magic strings here.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-server-config.h@38
PS13, Line 38:   int32_t jwks_pull_timeout_secs = DEFAULT_JWKS_PULL_TIMEOUT_SECS;
> Done. Removed validate_token_signature from OAuthServerConfig and removed a
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.h@53
PS14, Line 53:   Status Verify(const JWTHelper::JWTDecodedToken* decoded_token,
This function is only called from within OAuthServersManager.  Move it to the private section.


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.h@56
PS13, Line 56:  private:
             :   struct OAuthServerVerifier {
             :     JWTHelper jwt_helper;
> Done
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@59
PS13, Line 59:   bool found_username_server = false;
> Done
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@69
PS13, Line 69:   }
> Done. Grouped DCHECK(jwt_helpers_) and DCHECK(!jwt_helpers_->empty()) toget
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/oauth-servers-manager.cc@75
PS13, Line 75: 
> Done. I removed that bypass path entirely by removing validate_token_signat
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc@51
PS14, Line 51: Status OAuthServersManager::AuthenticateBearerToken(const string& token,
There is duplicate code in this function and OAuthServersManager::Verify.


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/oauth-servers-manager.cc@55
PS14, Line 55:   username_out->clear();
Is this line necessary?


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc@1160
PS13, Line 1160:   }
> Done. Removed the unused line and removed the sq_connection* parameter from
Done


http://gerrit.cloudera.org:8080/#/c/24448/13/be/src/util/webserver.cc@1166
PS13, Line 1166:   DCHECK(response_headers != nullptr);
> Done. Added WWW-Authenticate: Bearer error="invalid_token", error_descripti
Done


http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/14/be/src/util/webserver.cc@753
PS14, Line 753:   auto remove_bearer_auth_header = [&response_headers]() {
              :     auto it = std::remove_if(response_headers.begin(), response_headers.end(),
              :         [](const string& header) {
              :           return header.rfind("WWW-Authenticate: Bearer", 0) == 0;
              :         });
              :     response_headers.erase(it, response_headers.end());
              :   };
What is the reason for this code?  The WWW-Authenticate header is only added if token auth fails, and this code is only called if token auth succeeds, thus it will never remove the WWW-Authenticate response header.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 14
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Tue, 28 Jul 2026 17:08:30 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#15).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Address follow-up review feedback by removing redundant bearer-auth logic,
centralizing server-match selection in OAuthServersManager, and cleaning up
JWT helper matching code and constants.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
Co-authored-by: Cursor <cu...@cursor.com>
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
22 files changed, 1,220 insertions(+), 293 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/15
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 15
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Yida Wu, Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#20).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager, enforce
signature validation for matched servers, add RFC6750 bearer auth response
headers, and apply follow-up review cleanups in JWT helper internals.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
22 files changed, 1,238 insertions(+), 314 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/20
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 20
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 18:

(4 comments)

Done

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc@a185
PS18, Line 185: 
              : 
              : 
              : 
              : 
> I provided direction to delete this flag because it's dangerous since it en
We intentionally removed this flag instead of deprecating it because per the new multi-server oauth_servers design and prior review feedback, token signature validation must always be enforced and this override is no longer safe.


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc@a231
PS18, Line 231: 
              : 
              : 
              : 
              : 
              : 
> See comment on jwt_validate_signature flag.  This flag should also be moved
Same reasoning here: we intentionally removed this flag (instead of deprecating it) so signature validation cannot be disabled in the new oauth_servers-based flow.


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/oauth-server-config.h@32
PS18, Line 32: 4400
> Curious that why this is 4400 for update frequency, it doesn't seem like a 
Good catch. 4400 is not an obvious/default-friendly value. I will follow up by aligning this default with the legacy JWKS update frequency behavior for consistency.


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         if (use_jwt_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_jwt_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated && use_oauth_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_oauth_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated) {
              :           if (use_jwt_) {
              :             LOG(INFO) << "Invalid JWT token provided";
              :             total_jwt_token_auth_failure_->Increment(1);
              :           }
              :           if (use_oauth_) {
              :             LOG(INFO) << "Invalid OAuth token provided";
              :             total_oauth_token_auth_failure_->Increment(1);
              :           }
              :         }
> Another question is that if it possible both use_jwt_ and use_oauth_ be tru
I kept the current structure intentionally so JWT and OAuth compatibility paths remain explicit and metrics/logging semantics stay clear when one or both modes are enabled.

Yes, both can be true by design for migration/backward-compatibility scenarios. We keep separate JWT/OAuth success and failure counters/logs to preserve visibility, so adding a DCHECK to forbid both would break intended compatibility behavior.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 18
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 24 Aug 2026 06:09:41 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 24: Verified-1

Build failed: https://jenkins.impala.io/job/gerrit-verify-dryrun/14006/


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 24
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 10 Sep 2026 02:13:33 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#16).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager, enforce
signature validation for matched servers, add RFC6750 bearer auth response
headers, and apply follow-up review cleanups in JWT helper internals.

Testing:
- Linux build: ninja impalad oauth-server-config-test oauth-servers-manager-test jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
A tests/custom_cluster/test_shell_oauth_servers_auth.py
22 files changed, 1,215 insertions(+), 293 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/16
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 16
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 10:

(33 comments)

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h
File be/src/runtime/exec-env.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h@110
PS8, Line 110:   ~ExecEnv();
> Nit: The original names GetJWTHelperInstance() and GetOAuthHelperInstance()
Done. I renamed and relocated the getter as oauth_servers_mgr() alongside the other getters and changed the return type to std::shared_ptr<OAuthServersManager>


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.h@299
PS8, Line 299: 
> Make this a std::shared_ptr to avoid use-after-free issues.
Done. ExecEnv::oauth_servers_mgr_ is now a std::shared_ptr<OAuthServersManager>


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.cc
File be/src/runtime/exec-env.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/runtime/exec-env.cc@578
PS8, Line 578: 
> oauth_servers_mgr_ should be initialized as part of the constructor definit
Done. I moved oauth_servers_mgr_ initialization into the ExecEnv constructor initializer list and removed the allocation from ExecEnv::Init()


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/service/impala-server.cc
File be/src/service/impala-server.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/service/impala-server.cc@3240
PS8, Line 3240:       RETURN_IF_ERROR(ExecEnv::GetInstance()->oauth_servers_mgr()->Init());
              :     }
              : 
              :     // Initialize the client servers.
> This coding structure is sub-optimal since it requires initializing a throw
Done. I moved config construction into OAuthServersManager::Init() and now call ExecEnv::GetInstance()->oauth_servers_mgr()->Init() directly from ImpalaServer::Start(). Configs are moved into manager storage.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc
File be/src/util/jwt-util.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@771
PS8, Line 771:   DCHECK_GT(jwks_pull_timeout_secs_, 0);
             :   DCHECK(is_local_file || jwks_update_frequency_secs_ > 0);
             :   std::shared_ptr<JWKSSnapshot> new_jwks = std::make_shared<JWKSSnapshot>();
             :   if (is_local_file) {
             :    
> The flag validators for FLAGS_jwks_pulling_timeout_s take care of ensuring 
Done. I removed the warning/default fallback path and now rely on validated values; the code path now uses resolved values with DCHECKs.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@785
PS8, Line 785:     if (!status.ok()) {
             :       LOG(ERROR) << "Failed to load JWKS: " << status;
             :       return status;
             :     }
             :     D
> The flag validators for FLAGS_jwks_update_frequency_s take care of ensuring
Done. I removed the warning/default fallback for update frequency and use resolved validated values directly.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@812
PS8, Line 812:     new_jwks = std::make_shared<JWKSSnapshot>();
             :     bool is_changed = false;
             :     Status status =
             :         new_jwks->LoadKeysFromUrl(jwks_uri_, jwks_verify_server_certificate_,
             :             jwks_ca_certificate_, current_jwks_checksum_, &is_changed,
             :             jwks_pull_timeout_secs_);
             :     if (!status.ok()) {
> The logic in JWKSMgr::Init should take care of ensuring jwks_update_frequen
Done. JWKSMgr::Init() now resolves these values once and UpdateJWKSThread() uses those resolved members with DCHECKs.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/jwt-util.cc@869
PS8, Line 869:   jwks_mgr_.reset(new JWKSMgr());
             :   RETURN_IF_ERROR(jwks_mgr_->Init(jwks_uri, jwks_verify_server_certificate,
             :       jwks_ca_certificate, is_local_file, jwks_pull_timeout_secs,
             :       jwks_update_frequency_secs));
             :   if (!initialized_) initialized_ = true;
             :   return Status::OK();
             : }
             : 
> These functions are not needed.
Done. I removed CreateJWTHelper() / DestroyJWTHelper() and switched manager storage/ownership accordingly.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config-test.cc
File be/src/util/oauth-server-config-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config-test.cc@164
PS8, Line 164:   FLAGS_jwks_url = "https://example.com/jwks.json";
> Please add another test that combines all three sets of flags (oauth_server
Done. Added BuildOAuthServerConfigsCombinesJsonLegacyJwtAndLegacyOAuth.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h
File be/src/util/oauth-server-config.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@17
PS8, Line 17: 
            : #pragma once
            : 
> Use the newer #pragma once directive instead of macro guards.
Done. Converted oauth-server-config.h to #pragma once.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@37
PS8, Line 37:   bool is_local_jwks = false;
            :   int32_t jwks_pull_tim
> Instead of having separate fields for jwks file path and url, please consid
Done. Replaced separate jwks_file_path / jwks_url with jwks_uri plus is_local_jwks.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@35
PS8, Line 35:   bool verify_server_cert = true;
            :   std::string jwks_uri;
            :   bool is_local_jwks = false;
            :   int32_t jwks_pull_timeout_secs = DEFAULT_JWKS_PULL_TIMEOUT_SECS;
            :   int32_t jwks_update_frequency_secs = DEFAULT_JWKS_UPDATE_FREQUENCY_SECS;
            :   std::string username_claim = "username";
            : 
> Since this is security related, I would prefer for all these fields to be d
I did not convert OAuthServerConfig to fully constructor-only immutable fields in this patch because it would require a larger parser/build refactor across legacy migration and tests. I can do that in a follow-up if you want this tightened further.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@48
PS8, Line 48: /// Builds the full list of OAuth server configs from --oauth_servers plus any legacy
            : /// jwks_* / oauth_* startup flags.
            : Status BuildOAuthServerConfigs(std::vector<OAuthServerConfig>* configs
> Since defining both the JWKS file path and url is legacy behavior, let's ke
Done. Legacy file-vs-url preference behavior is now contained in legacy builders; the struct no longer carries both fields.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@53
PS8, Line 53: 
            : 
            : 
> It's a design smell if a function is exposed only for testing purposes.  C+
Done. I removed ParseOAuthServersJson() from the header and updated tests to validate through BuildOAuthServerConfigs().


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.h@62
PS8, Line 62: 
> I don't think this function needs to be in the global namespace but rather 
Done. Deprecated-flag warning helper path is now kept internal (anonymous namespace scope).


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.cc
File be/src/util/oauth-server-config.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-server-config.cc@31
PS8, Line 31: DECLARE_string(jwks_file_path);
> Remove, no need to DECLARE_ in the same file where the flag is defined.
Done. Removed redundant DECLARE_string(oauth_servers)


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager-test.cc
File be/src/util/oauth-servers-manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager-test.cc@120
PS8, Line 120:   google::FlagSaver flag_saver;
> Please add a test that asserts token validation fails when only the testdat
Done. Added VerifyFailsWhenOnlyWrongJwksConfigured.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h
File be/src/util/oauth-servers-manager.h:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@17
PS8, Line 17: 
            : #pragma once
            : 
> Use the newer #pragma once directive instead of macro guards.
Done. Converted oauth-servers-manager.h to #pragma once.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@40
PS8, Line 40: 
> Remove this function parameter since it is `true` in all the main code wher
Done. Removed require_jwks parameter from manager init and adjusted tests to use real config-driven init.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@41
PS8, Line 41:   }
            : 
            :   size_t size() const {
            :     DCHECK(impl_);
            :     return impl_->size();
> Nit: these simple one-line functions can have their function bodies placed 
Done. Inlined one-line methods (empty(), size(), config()) in the header.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.h@53
PS8, Line 53: /// Ver
> Why is this function declared static instead of being a class member functi
Done. Converted GetUsername() from static helper to class member method.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc
File be/src/util/oauth-servers-manager.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@35
PS8, Line 35: 
> No need to use JWTHelper*, use JWTHelper instead.
Done. Manager now stores JWTHelper objects, not pointers.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@32
PS8, Line 32:   RETURN_IF_ERROR(BuildOAuthServerConfigs(&configs));
            :   return InitWithConfigs(std::move(configs));
            : }
            : 
            : Status OAuthServersManager::InitWithConfigs(vector<OAuthServerConfig>&& configs) {
            :   impl_ = std::make_shared<OAuthServersImpl>();
            :   impl_->reserve(configs.size());
            :   
> This struct is not necessary.  Instead, in the private section of the OAuth
Done (adapted with comment 18). I removed the extra struct and now use a private alias in the header: std::vector<std::pair<OAuthServerConfig, JWTHelper>>.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@41
PS8, Line 41:   for (OAuthServerConfig& config : configs) {
            :     if (!config.HasJwksSource()) con
> Delete this constructor implementation, and, in the Init() function, do thi
Done (using shared ownership from related comments). I removed the constructor-based init path and initialize impl_ inside manager init flow.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@50
PS8, Line 50:     impl_->emplace_back(std::move(config), std::move(jwt_helper));
> No need to reset impl_, it will be automatically reset when it goes out of 
Done. Removed manual reset/destructor cleanup path.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@55
PS8, Line 55:   }
> Add DCHECK(impl_) to ensure that Init() has been called.
Done. Added DCHECK(impl_) checks in manager accessors/paths.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@59
PS8, Line 59: Status OAuthServersManager::Verify(const JWTHelper::JWTDecodedToken* decoded_token,
> Add DCHECK(impl_) to ensure that Init() has been called.
Done. Added corresponding DCHECK(impl_).


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@63
PS8, Line 63:   DCHECK(matched_server_idx_out != nullptr);
> Add DCHECK(impl_) to ensure that Init() has been called.
Done. Added corresponding DCHECK(impl_).


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@88
PS8, Line 88: ername_cla
> This function duplicates the validation performed in HasJwksSource().
Done. Removed duplicate validation path and rely on HasJwksSource() flow.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/oauth-servers-manager.cc@93
PS8, Line 93: 
> Is this sleep necessary?  If so, add a comment explaining why or remove the
Done. Removed the test-only sleep from manager initialization.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1167
PS8, Line 1167: 
> Needs to be changed to std::shared_ptr<OAuthServersManager>
Done. Updated Webserver auth paths to use std::shared_ptr<OAuthServersManager> from ExecEnv.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1177
PS8, Line 1177:     }
              :   }
> Useless condition, matched_server_idx will already be 0 here.
Done. Removed redundant matched_server_idx reset/condition in JWT web auth path.


http://gerrit.cloudera.org:8080/#/c/24448/8/be/src/util/webserver.cc@1219
PS8, Line 1219: 
              :   string username;
> Useless condition, matched_server_idx will already be 0 here.
Done. Removed redundant matched_server_idx reset/condition in OAuth web auth path.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 10
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Comment-Date: Thu, 18 Jun 2026 09:36:26 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#9).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest (11/11 passing)
- OAuthServersManagerTest (4/4 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (2/2 passing)
  - test_jwt_auth_with_oauth_servers
  - test_oauth_auth_with_oauth_servers
- Manual end-to-end validation on a Linux Impala test cluster:
  - rebuilt and restarted required local services (HDFS, Hive Metastore,
    HiveServer2) before running auth scenarios
  - verified impala-shell JWT auth and OAuth auth both succeed with
    --oauth_servers using jwksFilePath and execute query smoke checks
  - validated impalad logs contain the effective username and oauth_servers
    configuration usage for successful authentication paths

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
Co-authored-by: Cursor <cu...@cursor.com>
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
A tests/custom_cluster/test_shell_oauth_servers_auth.py
16 files changed, 1,072 insertions(+), 128 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/9
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 9
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers JSON config

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#2).

Change subject: IMPALA-14799: Add oauth_servers JSON config
......................................................................

IMPALA-14799: Add oauth_servers JSON config

Introduce --oauth_servers to configure multiple JWT/OAuth identity
providers, migrate legacy jwks_* and oauth_* flags into the new
structure with deprecation warnings, and verify tokens against all
configured JWKS sources.

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Co-authored-by: Cursor <cu...@cursor.com>
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
14 files changed, 689 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/2
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 2
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#6).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity providers,
migrate legacy jwks_* and oauth_* flags with deprecation warnings, and verify
tokens across all configured JWKS sources.

Harden oauth_servers parsing and legacy migration behavior by rejecting
conflicting JWKS source fields and ensuring legacy flag migration aligns with
deprecation-warning conditions.

Add focused backend unit tests for oauth-server config and OAuth servers
manager behavior, and add a custom-cluster shell auth E2E test that validates
both JWT and OAuth flows when configured via --oauth_servers.

Testing:
- OAuthServerConfigTest
- OAuthServersManagerTest
- tests/custom_cluster/test_shell_oauth_servers_auth.py

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
Co-authored-by: Cursor <cu...@cursor.com>
---
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
A tests/custom_cluster/test_shell_oauth_servers_auth.py
16 files changed, 1,119 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/6
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 6
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 1:

Build Failed 

https://jenkins.impala.io/job/gerrit-code-review-checks/22842/ : Initial code review checks failed. See linked job for details on the failure.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 1
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Fri, 12 Jun 2026 00:53:06 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 4:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/22844/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 4
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Fri, 12 Jun 2026 01:10:57 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Hello Yida Wu, Jason Fehr, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24448

to look at the new patch set (#26).

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................

IMPALA-14799: Add oauth_servers support and tests

Introduce --oauth_servers to configure multiple JWT/OAuth identity
providers, migrate legacy jwks_* and oauth_* flags with deprecation
warnings, and verify tokens across configured JWKS sources.

Consolidate bearer-token verification through OAuthServersManager,
enforce signature validation for matched servers, add RFC6750 bearer
auth response headers, and apply follow-up review cleanups in JWT
helper internals.

Testing:
- Linux build:
  ninja impalad oauth-server-config-test oauth-servers-manager-test
  jwt-util-test
- OAuthServerConfigTest (13/13 passing)
- OAuthServersManagerTest (5/5 passing)
- JwtUtilTest (23/23 passing)
- org.apache.impala.customcluster.JwtHttpTest (8/8 passing)
- tests/custom_cluster/test_shell_oauth_servers_auth.py (3/3 passing)
- org.apache.impala.customcluster.LdapHS2Test
  #testHiveserver2JwtAndOAuthAuth (1/1 passing)

Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Assisted-by: GPT-5.3 (Cursor)
---
M SECURITY.md
M be/src/rpc/authentication.cc
M be/src/runtime/exec-env.cc
M be/src/runtime/exec-env.h
M be/src/service/impala-server.cc
M be/src/util/CMakeLists.txt
M be/src/util/jwt-util-internal.h
M be/src/util/jwt-util.cc
M be/src/util/jwt-util.h
A be/src/util/oauth-server-config-test.cc
A be/src/util/oauth-server-config.cc
A be/src/util/oauth-server-config.h
A be/src/util/oauth-servers-manager-test.cc
A be/src/util/oauth-servers-manager.cc
A be/src/util/oauth-servers-manager.h
M be/src/util/webserver.cc
M be/src/util/webserver.h
M fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
M fe/src/test/java/org/apache/impala/customcluster/JwtWebserverTest.java
M fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
M fe/src/test/java/org/apache/impala/customcluster/LdapWebserverTest.java
M tests/custom_cluster/test_shell_jwt_auth.py
M tests/custom_cluster/test_shell_oauth_auth.py
A tests/custom_cluster/test_shell_oauth_servers_auth.py
24 files changed, 1,254 insertions(+), 326 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/48/24448/26
-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 26
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Anubhav Jindal (Code Review)" <ge...@cloudera.org>.
Anubhav Jindal has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 19:

(1 comment)

Done

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc
File be/src/util/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/util/webserver.cc@777
PS18, Line 777:         if (use_jwt_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_jwt_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated && use_oauth_) {
              :           if (OAuthTokenAuth(bearer_token, request_info, &response_headers)) {
              :             total_oauth_token_auth_success_->Increment(1);
              :             authenticated = true;
              :             check_csrf_protection = false;
              :             // TODO: cookies are not added, but are not needed right now
              :           }
              :         }
              :         if (!authenticated) {
              :           if (use_jwt_) {
              :             LOG(INFO) << "Invalid JWT token provided";
              :             total_jwt_token_auth_failure_->Increment(1);
              :           }
              :           if (use_oauth_) {
              :             LOG(INFO) << "Invalid OAuth token provided";
              :             total_oauth_token_auth_failure_->Increment(1);
              :           }
              :         }
> Since OAuthTokenAuth() now verifies the token against the unified OAuthServ
Good question. In the current flow, if both are enabled we intentionally treat them as compatibility modes and apply precedence in the caller: JWT path is attempted first, then OAuth as fallback if JWT path does not authenticate. So the counters/logs reflect the path semantics in this block (JWT-first then OAuth fallback), not the exact internal OAuthServersManager config identity. Returning exact server/config provenance would require extending the auth API and is out of scope for this change.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 19
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 24 Aug 2026 07:38:27 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 23: Verified-1

Build failed: https://jenkins.impala.io/job/gerrit-verify-dryrun/13998/


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 23
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 09 Sep 2026 17:42:13 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 24: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 24
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 09 Sep 2026 21:43:05 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Jason Fehr (Code Review)" <ge...@cloudera.org>.
Jason Fehr has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 18: -Code-Review

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc
File be/src/rpc/authentication.cc:

http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc@a185
PS18, Line 185: 
              : 
              : 
              : 
              : 
> Should we say jwt_validate_signature DEPRECATED instead of removing?
I provided direction to delete this flag because it's dangerous since it enables a huge security attack vector, and it was no longer used for testing.

That being said, I realize now that this flag should be moved to the startup flags graveyard in global-flags.cc.  If someone has specified this flag with a value of "true", I don't want Impala to fail to start.


http://gerrit.cloudera.org:8080/#/c/24448/18/be/src/rpc/authentication.cc@a231
PS18, Line 231: 
              : 
              : 
              : 
              : 
              : 
> Should we say oauth_jwt_validate_signature DEPRECATED instead of removing?
See comment on jwt_validate_signature flag.  This flag should also be moved to the startup flags graveyard.



-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 18
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 21 Aug 2026 15:34:26 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-14799: Add oauth servers support and tests

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24448 )

Change subject: IMPALA-14799: Add oauth_servers support and tests
......................................................................


Patch Set 29: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24448
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib29ff36600406ba59c10f29d79cc632020f4a3f7
Gerrit-Change-Number: 24448
Gerrit-PatchSet: 29
Gerrit-Owner: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Anubhav Jindal <an...@gmail.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 17 Sep 2026 20:11:49 +0000
Gerrit-HasComments: No