Skip to content

Commit 7e6cb22

Browse files
author
Devdutt Shenoi
authored
Merge branch 'main' into conditional
2 parents 679d781 + 794c8f1 commit 7e6cb22

File tree

17 files changed

+707
-18
lines changed

17 files changed

+707
-18
lines changed

.github/workflows/integration-test.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
name: Integration
2-
1+
name: Integration Tests with Quest
32
on:
43
pull_request:
54
paths-ignore:
6-
- 'docs/**'
7-
- 'helm/**'
8-
- 'assets/**'
9-
- '**.md'
5+
- "docs/**"
6+
- "helm/**"
7+
- "assets/**"
8+
- "**.md"
109

1110
jobs:
1211

.github/workflows/lint.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Lint
2+
on:
3+
pull_request:
4+
paths-ignore:
5+
- "docs/**"
6+
- "helm/**"
7+
- "assets/**"
8+
- "**.md"
9+
push:
10+
branches:
11+
- main
12+
13+
jobs:
14+
15+
fmt:
16+
name: Rust fmt check
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: actions-rs/toolchain@v1
21+
with:
22+
profile: minimal
23+
toolchain: stable
24+
override: true
25+
- run: rustup component add rustfmt
26+
- uses: actions-rs/cargo@v1
27+
with:
28+
command: fmt
29+
args: --all -- --check
30+
31+
clippy:
32+
name: Cargo Clippy check
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: actions-rs/toolchain@v1
37+
with:
38+
profile: minimal
39+
toolchain: stable
40+
override: true
41+
- run: rustup component add clippy
42+
- uses: actions-rs/cargo@v1
43+
with:
44+
command: clippy
45+
args: -- -D warnings

.github/workflows/unit-test.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Unit Tests
2+
on:
3+
pull_request:
4+
paths-ignore:
5+
- "docs/**"
6+
- "helm/**"
7+
- "assets/**"
8+
- "**.md"
9+
push:
10+
branches:
11+
- main
12+
13+
jobs:
14+
unit-tests:
15+
name: Unit tests
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions-rs/toolchain@v1
20+
with:
21+
profile: minimal
22+
toolchain: stable
23+
override: true
24+
- uses: actions-rs/cargo@v1
25+
with:
26+
command: test

src/cli.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,14 @@ impl FromArgMatches for Cli {
526526
self.trino_username = m.get_one::<String>(Self::TRINO_USER_NAME).cloned();
527527

528528
self.kafka_topics = m.get_one::<String>(Self::KAFKA_TOPICS).cloned();
529-
self.kafka_host = m.get_one::<String>(Self::KAFKA_HOST).cloned();
529+
self.kafka_security_protocol = m
530+
.get_one::<SslProtocol>(Self::KAFKA_SECURITY_PROTOCOL)
531+
.cloned();
530532
self.kafka_group = m.get_one::<String>(Self::KAFKA_GROUP).cloned();
531533
self.kafka_client_id = m.get_one::<String>(Self::KAFKA_CLIENT_ID).cloned();
532-
self.kafka_security_protocol = m.get_one::<SslProtocol>(Self::KAFKA_SECURITY_PROTOCOL).cloned();
534+
self.kafka_security_protocol = m
535+
.get_one::<SslProtocol>(Self::KAFKA_SECURITY_PROTOCOL)
536+
.cloned();
533537
self.kafka_partitions = m.get_one::<String>(Self::KAFKA_PARTITIONS).cloned();
534538

535539
self.tls_cert_path = m.get_one::<PathBuf>(Self::TLS_CERT).cloned();

src/correlation/correlation_utils.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Parseable Server (C) 2022 - 2024 Parseable, Inc.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Affero General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Affero General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
19+
use itertools::Itertools;
20+
21+
use crate::rbac::{
22+
map::SessionKey,
23+
role::{Action, Permission},
24+
Users,
25+
};
26+
27+
use super::{CorrelationError, TableConfig};
28+
29+
pub async fn user_auth_for_query(
30+
session_key: &SessionKey,
31+
table_configs: &[TableConfig],
32+
) -> Result<(), CorrelationError> {
33+
let tables = table_configs.iter().map(|t| &t.table_name).collect_vec();
34+
let permissions = Users.get_permissions(session_key);
35+
36+
for table_name in tables {
37+
let mut authorized = false;
38+
39+
// in permission check if user can run query on the stream.
40+
// also while iterating add any filter tags for this stream
41+
for permission in permissions.iter() {
42+
match permission {
43+
Permission::Stream(Action::All, _) => {
44+
authorized = true;
45+
break;
46+
}
47+
Permission::StreamWithTag(Action::Query, ref stream, _)
48+
if stream == table_name || stream == "*" =>
49+
{
50+
authorized = true;
51+
}
52+
_ => (),
53+
}
54+
}
55+
56+
if !authorized {
57+
return Err(CorrelationError::Unauthorized);
58+
}
59+
}
60+
61+
Ok(())
62+
}

0 commit comments

Comments
 (0)