Skip to content

branch-4.1: [fix](auth) Fix HTTP API authentication framework for admin operations - #62411

Merged
yiguolei merged 10 commits into
apache:branch-4.1from
gavinchou:gavin-pick-60761-branch-4.1
Apr 23, 2026
Merged

branch-4.1: [fix](auth) Fix HTTP API authentication framework for admin operations#62411
yiguolei merged 10 commits into
apache:branch-4.1from
gavinchou:gavin-pick-60761-branch-4.1

Conversation

@gavinchou

Copy link
Copy Markdown
Contributor

Pick #60761 to branch-4.1

gavinchouand others added 9 commits April 13, 2026 02:17
…tions
This commit implements a comprehensive HTTP API authentication system
that distinguishes between public APIs, user APIs, and admin APIs.
Key changes:
FE (Frontend):
- Add userIdentity field to ActionAuthorizationInfo for parameter passing
- Modify RestBaseController.executeCheckPassword() to return authInfo
- Add checkAdminAuth() helper method for admin privilege checks
- Update 17 existing Actions to use authInfo.userIdentity pattern
- Add admin auth checks to 10 Actions that previously lacked them
- Remove dependency on ConnectContext.get() for better testability
BE (Backend):
- Add TPrivilegeType::NONE optimization to skip FE RPC for public APIs
- Update HealthAction to use NONE privilege type (public access)
- Convert StreamLoadAction to inherit from HttpHandlerWithAuth
- Convert StreamLoad2PCAction to use LOAD privilege type
- Convert HttpStreamAction to use LOAD privilege type
- Remove duplicate _exec_env members (inherited from parent)
Testing:
- Add FE unit tests (HttpApiAuthTest.java) with 5 test cases
- Add BE unit tests (http_auth_test.cpp) with 3 new test cases
- Add comprehensive Docker system tests (test_http_api_auth.groovy)
- All tests cover public API, user API, and admin API scenarios
API Classification:
- Public APIs (NONE): /api/health, /metrics - no admin required
- User APIs (LOAD): stream load - require LOAD privilege
- Admin APIs (ADMIN): /_set_config, /backends, etc. - require ADMIN
The implementation is backward compatible via enable_all_http_auth flag
(default: false). When enabled, it enforces proper authentication and
authorization for all HTTP APIs.
Files modified: 38 (27 FE + 8 BE + 3 tests)
Lines changed: +282/-120
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
### What problem does this PR solve?
Issue: HttpAuthTest was failing with double-free error due to incorrect
evhttp_request lifecycle management in tests.
Problem Summary:
1. When on_header returns -1, send_reply has been called internally which
triggers evhttp_request cleanup. The test was then calling
evhttp_request_free again, causing double-free.
2. Added proper comments explaining when to free evhttp_request and when not to.
### Release note
None - internal test fix only.
### Check List (For Author)
- Test: BE Unit Test - HttpAuthTest and HttpClientTest.enable_http_auth passed
- Behavior changed: No - test only changes
- Does this need documentation: No
@Thearas

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@gavinchou

Copy link
Copy Markdown
ContributorAuthor

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 20.88% (19/91) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 69.23% (9/13) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage71.23% (26165/36732)
Line Coverage54.13% (276503/510824)
Region Coverage51.28% (228985/446507)
Branch Coverage52.73% (99116/187961)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 69.23% (9/13) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage71.61% (26303/36732)
Line Coverage54.51% (278457/510824)
Region Coverage51.70% (230861/446507)
Branch Coverage53.16% (99918/187961)

@gavinchougavinchou changed the title [Enhancement](auth) Pick HTTP API authentication framework to branch-4.1branch-4.1: [Enhancement](auth) Pick HTTP API authentication framework to Apr 15, 2026
@gavinchougavinchou changed the title branch-4.1: [Enhancement](auth) Pick HTTP API authentication framework to branch-4.1: [fix](auth) Fix HTTP API authentication framework for admin operationsApr 15, 2026
@gavinchou

Copy link
Copy Markdown
ContributorAuthor

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 22.83% (21/92) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 31.52% (29/92) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 38.46% (5/13) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage53.23% (19968/37514)
Line Coverage36.71% (188132/512493)
Region Coverage33.07% (146374/442592)
Branch Coverage34.14% (63996/187432)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 69.23% (9/13) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage71.41% (26221/36721)
Line Coverage54.32% (277432/510776)
Region Coverage51.72% (230948/446529)
Branch Coverage53.04% (99689/187954)

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Apr 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@yiguolei
yiguolei merged commit a3598ba into apache:branch-4.1Apr 23, 2026
27 of 31 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@gavinchou@Thearas@hello-stephen@yiguolei