Skip to content

[improvement](fe) add fe_meta_auth_token for FE meta-service internal HTTP auth#65551

Open
CalvinKirs wants to merge 1 commit into
apache:masterfrom
CalvinKirs:fe-meta-auth-token
Open

[improvement](fe) add fe_meta_auth_token for FE meta-service internal HTTP auth#65551
CalvinKirs wants to merge 1 commit into
apache:masterfrom
CalvinKirs:fe-meta-auth-token

Conversation

@CalvinKirs

Copy link
Copy Markdown
Member

What problem does this PR solve?

The FE meta-service endpoints (image/role/check/put/journal_id, etc.) authenticate callers only by the CLIENT_NODE_HOST/CLIENT_NODE_PORT headers — i.e. whether the claimed host:port is a registered FE. That is a plaintext claim with no secret, so any host that knows a valid FE address can impersonate it.

What this PR does

Add an optional cluster token fe_meta_auth_token:

  • Empty (default) — behavior is unchanged: node-host check only. Existing clusters and rolling upgrades are unaffected.
  • SetcheckFromValidFe additionally requires the request to carry a matching token header, on top of the existing node-host check (additive, does not replace the host check).

The token is a static fe.conf item, so a scaling-out FE already holds it before the bootstrap handshake — no chicken-and-egg with the token that /check itself hands out. It must be identical on all FEs.

Additional hardening of the meta-service:

  • /put rejects a port other than the FE HTTP port.
  • /dump always checks the admin password.
  • meta-helper logs header names only, never the token value.

Tests

  • MetaServiceTest: matching / missing / wrong token, no-token-when-unconfigured, unknown-host-rejected-even-with-token, /put port check, /dump auth.
  • HttpURLUtilTest: token header emission (present/absent) and internal URL building.

This supersedes #63782 (rebased onto latest master with a cleaner, switch-free design).

… HTTP auth

The FE meta-service endpoints (image/role/check/put/journal_id, etc.) only
authenticate callers by the CLIENT_NODE_HOST/PORT headers, i.e. whether the
claimed host:port is a registered FE. That is a plaintext claim with no secret,
so any host that knows a valid FE address can impersonate it.

Add an optional cluster token, fe_meta_auth_token:
- When empty (default), behavior is unchanged: node-host check only. Existing
  clusters and rolling upgrades are unaffected.
- When set, checkFromValidFe additionally requires the request to carry a
  matching token header, on top of the existing node-host check (the token
  check is additive, it does not replace the host check).

The token is a static fe.conf item, so a scaling-out FE already holds it before
the bootstrap handshake -- no chicken-and-egg with the token that /check hands
out. Must be identical on all FEs.

Also harden the meta-service: /put rejects a port other than the FE HTTP port,
/dump always checks the admin password, and meta-helper logs header names only
(never the token value).

Tests: MetaServiceTest covers matching/missing/wrong token, no-token-when-
unconfigured, unknown-host-rejected-even-with-token, /put port check, and /dump
auth; HttpURLUtilTest covers token header emission and internal URL building.
@hello-stephen

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?

@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29657 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit d58d9b27bece6b621edd3c914dd425d9c38b12a2, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17764	4306	4282	4282
q2	2094	315	204	204
q3	10204	1429	836	836
q4	4682	471	346	346
q5	7537	841	585	585
q6	184	173	142	142
q7	768	815	619	619
q8	9339	1477	1548	1477
q9	6004	4413	4417	4413
q10	6738	1790	1509	1509
q11	508	337	316	316
q12	709	537	437	437
q13	18163	3346	2808	2808
q14	263	273	239	239
q15	q16	787	790	713	713
q17	923	866	932	866
q18	7049	5866	5559	5559
q19	1257	1216	1084	1084
q20	757	645	544	544
q21	5877	2636	2379	2379
q22	443	355	299	299
Total cold run time: 102050 ms
Total hot run time: 29657 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4494	4488	4440	4440
q2	293	318	221	221
q3	4561	5038	4413	4413
q4	2043	2153	1358	1358
q5	4469	4348	4298	4298
q6	226	178	128	128
q7	1755	2184	1708	1708
q8	2572	2254	2221	2221
q9	8104	8017	7909	7909
q10	4737	4756	4231	4231
q11	568	430	409	409
q12	766	763	567	567
q13	3314	3611	2966	2966
q14	310	300	272	272
q15	q16	710	731	631	631
q17	1361	1354	1425	1354
q18	8064	7386	7227	7227
q19	1146	1089	1048	1048
q20	2208	2218	1941	1941
q21	5264	4607	4454	4454
q22	534	459	394	394
Total cold run time: 57499 ms
Total hot run time: 52190 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 180017 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit d58d9b27bece6b621edd3c914dd425d9c38b12a2, data reload: false

query5	4294	633	497	497
query6	479	218	205	205
query7	4892	584	355	355
query8	349	189	175	175
query9	8799	4046	4038	4038
query10	483	349	301	301
query11	5938	2359	2185	2185
query12	161	100	102	100
query13	1279	606	474	474
query14	6279	5298	4959	4959
query14_1	4286	4267	4260	4260
query15	221	207	179	179
query16	1041	481	444	444
query17	1127	721	586	586
query18	2569	481	356	356
query19	225	196	156	156
query20	111	112	117	112
query21	238	160	135	135
query22	13698	13534	13389	13389
query23	17398	16623	16243	16243
query23_1	16333	16347	16283	16283
query24	7454	1773	1272	1272
query24_1	1331	1281	1296	1281
query25	581	469	392	392
query26	1332	348	218	218
query27	2551	568	400	400
query28	4458	2000	2032	2000
query29	1084	640	509	509
query30	350	262	235	235
query31	1116	1093	994	994
query32	111	62	62	62
query33	520	321	259	259
query34	1180	1107	674	674
query35	766	795	682	682
query36	1401	1414	1247	1247
query37	159	107	89	89
query38	1893	1705	1655	1655
query39	918	927	903	903
query39_1	893	882	912	882
query40	253	157	137	137
query41	65	67	64	64
query42	95	89	93	89
query43	321	320	279	279
query44	1414	774	765	765
query45	199	183	183	183
query46	1079	1228	749	749
query47	2361	2395	2242	2242
query48	386	415	297	297
query49	587	409	310	310
query50	1048	427	327	327
query51	10783	10538	10724	10538
query52	87	86	74	74
query53	260	282	204	204
query54	280	234	235	234
query55	75	69	68	68
query56	308	282	287	282
query57	1424	1403	1319	1319
query58	284	246	250	246
query59	1595	1651	1484	1484
query60	298	270	252	252
query61	150	147	147	147
query62	688	655	591	591
query63	239	203	207	203
query64	2806	1018	803	803
query65	4851	4740	4776	4740
query66	1817	505	385	385
query67	29565	29452	29421	29421
query68	3245	1522	984	984
query69	410	305	277	277
query70	1114	962	973	962
query71	351	316	305	305
query72	3016	2811	2360	2360
query73	824	796	444	444
query74	5137	4962	4793	4793
query75	2602	2580	2221	2221
query76	2315	1179	779	779
query77	351	371	284	284
query78	12272	12362	11672	11672
query79	1408	1211	746	746
query80	1278	541	473	473
query81	525	320	278	278
query82	624	158	126	126
query83	370	319	309	309
query84	296	159	131	131
query85	966	576	498	498
query86	428	309	274	274
query87	1839	1836	1755	1755
query88	3672	2806	2806	2806
query89	452	402	362	362
query90	1929	205	199	199
query91	198	193	160	160
query92	59	64	55	55
query93	1722	1477	1004	1004
query94	721	372	307	307
query95	762	569	469	469
query96	1062	794	357	357
query97	2712	2701	2588	2588
query98	220	204	210	204
query99	1144	1171	1024	1024
Total cold run time: 266054 ms
Total hot run time: 180017 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.13 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit d58d9b27bece6b621edd3c914dd425d9c38b12a2, data reload: false

query1	0.00	0.01	0.00
query2	0.09	0.05	0.05
query3	0.26	0.14	0.13
query4	1.61	0.14	0.13
query5	0.25	0.23	0.24
query6	1.29	1.09	1.04
query7	0.04	0.01	0.01
query8	0.05	0.04	0.04
query9	0.38	0.32	0.32
query10	0.56	0.58	0.55
query11	0.19	0.14	0.14
query12	0.18	0.14	0.14
query13	0.47	0.47	0.48
query14	1.03	1.01	1.00
query15	0.60	0.59	0.61
query16	0.33	0.32	0.32
query17	1.14	1.08	1.14
query18	0.25	0.21	0.21
query19	2.00	2.00	1.95
query20	0.02	0.01	0.01
query21	15.43	0.19	0.13
query22	4.92	0.05	0.05
query23	16.15	0.32	0.13
query24	2.99	0.42	0.31
query25	0.11	0.05	0.04
query26	0.76	0.20	0.16
query27	0.03	0.04	0.03
query28	3.56	0.95	0.55
query29	12.54	4.20	3.35
query30	0.28	0.17	0.17
query31	2.77	0.61	0.30
query32	3.22	0.59	0.50
query33	3.17	3.17	3.22
query34	15.64	4.21	3.51
query35	3.53	3.52	3.55
query36	0.55	0.42	0.43
query37	0.09	0.07	0.07
query38	0.06	0.04	0.04
query39	0.03	0.03	0.03
query40	0.17	0.16	0.15
query41	0.08	0.03	0.04
query42	0.04	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.9 s
Total hot run time: 25.13 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 86.67% (26/30) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 40.00% (12/30) 🎉
Increment coverage report
Complete coverage report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants