-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: impl basic auth #1531
feat: impl basic auth #1531
Conversation
src/proxy/src/auth/mod.rs
Outdated
pub struct AuthBase; | ||
|
||
impl Auth for AuthBase { | ||
fn load_credential(&mut self) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove default implementation.
src/proxy/src/auth/mod.rs
Outdated
} | ||
|
||
#[derive(Default)] | ||
pub struct AuthBase; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Authorizator
src/proxy/src/grpc/prom_query.rs
Outdated
@@ -81,6 +81,21 @@ impl Proxy { | |||
msg: "Missing context", | |||
code: StatusCode::BAD_REQUEST, | |||
})?; | |||
|
|||
// Check if the tenant is authorized to access the database. | |||
if !self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use interceptor to do auth check for gRPC
https://github.com/hyperium/tonic/blob/master/examples/src/interceptor/server.rs
For HTTP, see https://stackoverflow.com/questions/54988438/how-to-check-the-authorization-header-using-warp
src/proxy/src/auth/mod.rs
Outdated
#[derive(Debug, Clone, Deserialize, Serialize, Default)] | ||
pub struct Config { | ||
pub enable: bool, | ||
pub auth_type: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define this with an Enum.
src/proxy/src/auth/mod.rs
Outdated
pub type AuthRef = Arc<Mutex<dyn Auth>>; | ||
|
||
/// Header of tenant name | ||
pub const TENANT_HEADER: &str = "x-horaedb-access-tenant"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basic authorization use authorization
header, we should avoid those custom headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Rationale
Close #929
Detailed Changes
Test Plan
Add this to config,
/tmp/auth.csv
has this formatusername,password
, one user one line.