-
Notifications
You must be signed in to change notification settings - Fork 110
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: allow to conditionally block mutation via expressions #1480
Merged
StarpTech
merged 16 commits into
main
from
dustin/eng-6203-allow-to-block-mutations-conditionally
Jan 3, 2025
Merged
feat: allow to conditionally block mutation via expressions #1480
StarpTech
merged 16 commits into
main
from
dustin/eng-6203-allow-to-block-mutations-conditionally
Jan 3, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Router image scan passed✅ No security vulnerabilities found in image:
|
Noroth
requested changes
Jan 2, 2025
Noroth
reviewed
Jan 3, 2025
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.
Let me know about my last comment otherwise LGTM
jensneuse
requested changes
Jan 3, 2025
Noroth
approved these changes
Jan 3, 2025
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
StarpTech
commented
Jan 3, 2025
StarpTech
commented
Jan 3, 2025
…ditionally # Conflicts: # router-tests/events/kafka_events_test.go
jensneuse
approved these changes
Jan 3, 2025
StarpTech
deleted the
dustin/eng-6203-allow-to-block-mutations-conditionally
branch
January 3, 2025 12:41
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This pull request introduces the capability to conditionally block mutations, subscriptions, and non-persisted operations. Instead of relying on YAML configuration alone, we have implemented support for dynamic expressions that are evaluated at runtime. Users can leverage request headers, URL parameters, query parameters, and authentication context (such as claims and scopes) to define the condition when operations are blocked. If no condition is provided all operations are blocked.
Example Configuration
Block by a header condition
Block by a scope condition
The expression parser and runtime are powered by expr-lang, a widely used library in the Go ecosystem. We chose
expr
for its elegant DSL and robust error reporting.During router bootstrap, the system will validate that the expression are valid and returns the expected type (a boolean for conditions). If the expression evaluates to an incorrect type, the process will fail with a detailed error message.
This step forward, will also lay the foundation for a more dynamic approach in applying configuration or extracting values at runtime.
Warning
As part of the preparations for Cosmo V1, targeted for release in Q1 2025, this pull request introduces essential changes to enhance long-term stability and maintainability. While we strive to minimize breaking changes, they are sometimes necessary to lay the foundation for a more robust and scalable system. This update includes non-backward compatible modifications, specifically impacting the configuration of operation blocking mechanisms.
Checklist