-
-
Notifications
You must be signed in to change notification settings - Fork 137
update user auth for list filters #1295
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
update user auth for list filters #1295
Conversation
WalkthroughThe changes refactor the mechanism for user authorization and query handling. Functions and imports related to table scanning and query-specific authorization have been removed from the alerts utility, with a shift to dataset-level authorization across several modules. Imports for Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (10)
🚧 Files skipped from review as they are similar to previous changes (6)
🧰 Additional context used🧬 Code Graph Analysis (3)src/correlation.rs (1)
src/alerts/alerts_utils.rs (1)
src/users/filters.rs (3)
⏰ Context from checks skipped due to timeout of 90000ms (10)
🔇 Additional comments (12)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/correlation.rs (1)
90-90
: Consider logging skipped correlations for easier debugging.
Here, ifuser_auth_for_datasets
fails, the correlation is silently skipped. While this behavior may be intentional, adding a log statement could help identify when and why certain correlations are excluded.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/alerts/alerts_utils.rs
(1 hunks)src/alerts/mod.rs
(1 hunks)src/correlation.rs
(3 hunks)src/handlers/airplane.rs
(2 hunks)src/handlers/http/alerts.rs
(2 hunks)src/handlers/http/correlation.rs
(2 hunks)src/handlers/http/query.rs
(3 hunks)src/users/dashboards.rs
(1 hunks)src/users/filters.rs
(3 hunks)src/utils/mod.rs
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (8)
src/handlers/http/alerts.rs (2)
src/utils/actix.rs (1)
extract_session_key_from_req
(51-71)src/utils/mod.rs (1)
user_auth_for_query
(100-108)
src/handlers/airplane.rs (1)
src/utils/mod.rs (1)
user_auth_for_datasets
(110-142)
src/handlers/http/query.rs (1)
src/utils/mod.rs (1)
user_auth_for_datasets
(110-142)
src/alerts/alerts_utils.rs (1)
src/handlers/http/query.rs (1)
query
(69-155)
src/utils/mod.rs (1)
src/handlers/http/query.rs (1)
query
(69-155)
src/alerts/mod.rs (1)
src/utils/mod.rs (1)
user_auth_for_query
(100-108)
src/users/filters.rs (1)
src/utils/mod.rs (2)
user_auth_for_datasets
(110-142)user_auth_for_query
(100-108)
src/correlation.rs (1)
src/utils/mod.rs (1)
user_auth_for_datasets
(110-142)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Build Default x86_64-pc-windows-msvc
- GitHub Check: Build Default aarch64-apple-darwin
- GitHub Check: Build Default x86_64-unknown-linux-gnu
- GitHub Check: Build Default aarch64-unknown-linux-gnu
- GitHub Check: Build Kafka aarch64-apple-darwin
- GitHub Check: Quest Smoke and Load Tests for Distributed deployments
- GitHub Check: Build Kafka x86_64-unknown-linux-gnu
- GitHub Check: Quest Smoke and Load Tests for Standalone deployments
- GitHub Check: coverage
🔇 Additional comments (18)
src/alerts/mod.rs (1)
45-45
: Acknowledge updated import path for user authorization.The import for
user_auth_for_query
has been moved fromalerts_utils
tocrate::utils
, aligning with the broader refactoring of the authorization system to better handle different filter types.src/users/dashboards.rs (1)
29-29
: Import consolidation looks good.The import statement has been refactored to include
user_auth_for_query
in the grouped import fromutils
, improving code organization while maintaining the same functionality.src/handlers/http/alerts.rs (1)
25-25
: Refactored import path for user authentication utilities.The import for
user_auth_for_query
has been successfully moved from a module-specific location to the centralizedutils
module, which aligns with the PR's goal of improving the user authorization process.src/handlers/airplane.rs (1)
214-216
: Function call updated to use dataset-based authorization.The change from
user_auth_for_query
touser_auth_for_datasets
reflects the architecture shift from query-based to dataset-based authorization. This is a key part of the PR's objective to enhance authorization for list filters, ensuring users can be properly authorized regardless of the filter type being used.src/correlation.rs (2)
43-43
: New import aligns with dataset-level authorization refactor.
Importinguser_auth_for_datasets
in place ofuser_auth_for_query
seems consistent with the new approach to dataset-based permissions.
284-284
: Consistent dataset-level check for user authorization.
Replacing the old query-based check with a dataset-focused authorization is clear and consistent. This approach improves readability and unifies the authorization flow.src/handlers/http/correlation.rs (2)
26-26
: Updated import reflects shift to dataset-based checks.
Importinguser_auth_for_datasets
here aligns with the broader refactor and centralizes authorization logic.
57-57
: Dataset-level authorization ensures correctness.
This replacement of the old function properly returns an error if the user lacks permissions for any target dataset. The approach is straightforward and consistent with the rest of the codebase.src/alerts/alerts_utils.rs (1)
33-33
: Cleaned up imports to remove the old query auth references.
This import change reflects the removal of query-based authorization in the alerts utility. No further issues noted.src/handlers/http/query.rs (3)
52-52
: Updated import to use dataset-based authorization instead of query-basedThe import has been updated to use
user_auth_for_datasets
which is consistent with the PR objectives to enhance user authorization for datasets based on different filter types.
102-102
: Updated authorization check to use dataset-level permissionsThe function call has been updated from
user_auth_for_query
touser_auth_for_datasets
, which aligns with the PR objective of modifying the server's authorization logic. This change ensures consistent authorization checking across different filter types.
165-165
: Updated counts request authorization to use dataset-level permissionsSimilar to the main query function, the authorization check in the
get_counts
function has been updated to useuser_auth_for_datasets
, ensuring consistent application of the new authorization approach.src/utils/mod.rs (3)
29-30
: Added necessary imports for table scanning and session managementThe imports have been appropriately updated to support the new functionality for extracting tables from queries and handling user sessions. These changes are required for the new async
get_tables_from_query
function.Also applies to: 36-37
88-98
: Added new async function to extract tables from queriesThis new helper function encapsulates the logic to extract table names from a query string, which is a crucial step in dataset-based authorization. The function properly handles error cases and returns a structured
TableScanVisitor
that contains the table names.
100-108
: Refactored user_auth_for_query to use dataset-based authorizationThe
user_auth_for_query
function has been updated to:
- Be asynchronous to support the async table extraction
- Accept a session key instead of permissions
- Leverage the new
get_tables_from_query
function- Use the dataset-level authorization via
user_auth_for_datasets
This maintains backward compatibility while implementing the PR's objective to shift to dataset-level authorization.
src/users/filters.rs (3)
48-48
: Replaced string type with strongly typed enum for filter_typeUsing a strongly typed enum instead of a string for
filter_type
improves type safety and makes the code more maintainable by preventing typos and invalid filter types.
53-69
: Added FilterType enum with conversion methodThe new
FilterType
enum provides a structured way to represent the different filter types (Filter, SQL, and Search) with proper serialization annotations. Theto_str
method is a helpful utility for converting the enum variants to their string representations when needed.
188-198
: Implemented conditional authorization based on filter typeThis is the core change that fulfills the PR objective. The code now:
- Checks the filter type to determine the appropriate authorization method
- For SQL and Filter types, it uses query-based authorization (
user_auth_for_query
)- For Search type, it uses dataset-based authorization (
user_auth_for_datasets
)This change ensures that saved searches using key:value pair syntax can be properly authorized using the dataset name, addressing the limitation mentioned in the PR description.
current: server checks if user is authorized to a dataset based on query string this logic does not work for saved searches because there is no query string as searches have key:value pair syntax update: server fetches the filter_type if filter_type is sql or filter, server checks if user is authorized to a dataset based on query string if filter_type is search, server checks if user is authorized to a dataset based on the dataset_name
461bbdd
to
3851b0f
Compare
Merging because tests passed once and we just added comments now. |
current: server checks if user is authorized to a dataset based on query string
this logic does not work for saved searches because there is no query string
as searches have key:value pair syntax
update: server fetches the filter_type
if filter_type is sql or filter,
server checks if user is authorized to a dataset based on query string if filter_type is search,
server checks if user is authorized to a dataset based on the dataset_name
Summary by CodeRabbit
New Features
Bug Fixes
Refactor