Skip to content

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #41994

### What problem does this PR solve?
Related PR: #39577

Problem Summary:
In #39577, we added the auth check for all HTTP API on FE side.
But it introduced an issue that when `enable_all_http_auth`, the
internal http request
will fail due to lack of authentication info.
For example, when cloning replica from one BE to another, it use HTTP
API.

This PR mainly changes:

1. Unify the token generation and checking logic

	Move `TokenManager` from `load` package to `Env`, as a global mgr.

	It is responsible for generating tokens at fix interval.
	And the token will be sent to BE via heartbeat.

	BE will save last 2 tokens, and use the latest token in HTTP request.

	All HTTP request sent by BE will add a header `Auth-Token`,
and BE's HTTP server will check if this token in header is same as token
	from FE heartbeat.

2. Add a new class `ClusterInfo` on BE side to replace `TMasterInfo`.

	`TMasterInfo` is a thrift object used to save master info and pass them
	from FE to BE via heartbeat.
	So it should only be a message payload, we should get info from it and
	save it in another structure: `ClusterInfo`.

Co-authored-by: morningman <yunyou@selectdb.com>
@doris-robot
Copy link

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?

@doris-robot
Copy link

run buildall

@morningman morningman closed this Nov 12, 2024
@morningman morningman reopened this Nov 12, 2024
@morningman
Copy link
Contributor

run buildall

Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

uint32_t worker_thread_num, TMasterInfo* local_master_info) {
HeartbeatServer* heartbeat_server = new HeartbeatServer(local_master_info);
uint32_t worker_thread_num, ClusterInfo* cluster_info) {
HeartbeatServer* heartbeat_server = new HeartbeatServer(cluster_info);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use auto when initializing with new to avoid duplicating the type name [modernize-use-auto]

Suggested change
HeartbeatServer* heartbeat_server = new HeartbeatServer(cluster_info);
auto* heartbeat_server = new HeartbeatServer(cluster_info);


#pragma once

#include <gen_cpp/Types_types.h>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'gen_cpp/Types_types.h' file not found [clang-diagnostic-error]

#include <gen_cpp/Types_types.h>
         ^

@morningman morningman merged commit 478b36e into branch-3.0 Nov 12, 2024
@CalvinKirs CalvinKirs deleted the auto-pick-41994-branch-3.0 branch November 12, 2024 08:12
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