-
Notifications
You must be signed in to change notification settings - Fork 15
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!: if
conditional statements for error pipeline mechanisms
#1055
Merged
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
…d including new tests for the new available functionality
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1055 +/- ##
==========================================
- Coverage 89.56% 89.14% -0.42%
==========================================
Files 248 245 -3
Lines 10217 10265 +48
==========================================
Hits 9151 9151
- Misses 833 877 +44
- Partials 233 237 +4 ☔ View full report in Codecov by Sentry. |
…cified in the errors lib
…r as , separated list
…g and dealing with the corresponding functionality
dadrus
changed the title
wip:
feat!: Nov 27, 2023
if
conditional statements for error pipeline mechanismsif
conditional statements for error pipeline mechanisms
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.
Related issue(s)
closes #1048
Checklist
Description
This PR removes support for the
when
clause in the configs of the available error handler mechanisms and makes theif
clause available as already supported for the regular pipeline mechanisms as requested in #1048.So the following error pipeline definition
would become
as in the past, only the error handler of the
default
type does not require execution conditions to be specified.As can be seen form the above example, there are some new objects, the CEL expressions can make use of:
Error
object, supporting the following property:Source
property giving access to the ID of the mechanism which raised that error.type(Error)
returns the type of theError
object and supports the operators==
and!=
to allow checking if an error is either one or another type, like shown in the example above.If you need to check just types, like
type(Error) == precondition_error || type(Error) == authorization_error
, you can simplify it withtype(Error) in [precondition_error, authorization_error]
The error types, one can check the
Error
type object against are theauthentication_error
,authorization_error
,communication_error
,internal_error
and theprecondition_error
types (as already available to the yaml based error pipeline definition).networks()
function accepting either a single CIDR or an array of CIDR definitions, e.g.networks("10.0.0.0/16")
ornetworks(["10.0.0.0/16", "172.0.0.0/16"])
. The created objects are singletons (for the given CIDR/CIDRs) and supports/exposes the following operators:in
(Containment) to check whether a specific IP or all IPs from an array do come from the given networks. Latter you can see in action in the example above (Request.ClientIPAddresses
is a property containing the IP addresses of all known network hops - from the IP of the ultimate client to the IP of the service, which forwarded the request to heimdall.)To check if only a specific address from the given set comes from a specific network or a set of networks, one can use existing macros, like
["192.168.1.10", "10.0.1.1"].exists(ip, ip in networks(["10.0.0.0/16", "172.0.0.0/16"]))
Since
networks(["10.0.0.0/16", "172.0.0.0/16"])
returns a singleton for the given CIDRs, there is no performance penalty in place.To check whether a specific header is set to a particular value or contains a specific mime type, you can just use the available string related functions, like also shown in the example above.