-
Notifications
You must be signed in to change notification settings - Fork 71
Support populating identity override without guarded route #1600
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
Conversation
|
@nageshwaravijay1117 I think the fix we want is in They each rely on However, we already have |
Sure, @jfallows. I agree with the proposed changes. While implementing the solution, I considered handling it within the Engine Manager so that we can avoid separate implementations for each binding and make the approach more generic. |
|
Yes understood. However it ends up mutating the configuration to support a workaround for incorrect implementation. So I think we should just fix the incorrect implementation in http-kafka and sse-kafka bindings. |
jfallows
left a comment
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.
http-kafka feedback also applies to sse-kafka changes.
.../java/io/aklivity/zilla/runtime/binding/http/kafka/internal/config/HttpKafkaRouteConfig.java
Outdated
Show resolved
Hide resolved
.../java/io/aklivity/zilla/runtime/binding/http/kafka/internal/config/HttpKafkaRouteConfig.java
Outdated
Show resolved
Hide resolved
.../java/io/aklivity/zilla/runtime/binding/http/kafka/internal/config/HttpKafkaRouteConfig.java
Outdated
Show resolved
Hide resolved
.../java/io/aklivity/zilla/runtime/binding/http/kafka/internal/config/HttpKafkaRouteConfig.java
Outdated
Show resolved
Hide resolved
.../java/io/aklivity/zilla/runtime/binding/http/kafka/internal/config/HttpKafkaRouteConfig.java
Outdated
Show resolved
Hide resolved
...a/io/aklivity/zilla/runtime/binding/http/kafka/internal/config/HttpKafkaRouteConfigTest.java
Outdated
Show resolved
Hide resolved
| referencedGuardNames = HttpKafkaWithResolver.extractGuardNames(withConfig); | ||
| } | ||
|
|
||
| // Only add guards that are actually referenced in expressions |
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.
Isn't it correct to say that route.guarded can be ignored and instead we only want to process all of the guards referenced by guard name in the expressions?
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.
I think route.guarded entries contain pre-resolved identity and attribute functions set during config initialization. Bypassing them would require redundant guard resolution via EngineContext and lose route-specific guard configurations.
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.
The concepts of guarded routes and guarded expressions are distinct.
Guarded routes are trying to make sure that zero or more specific roles are active for a valid session of a specific guard, such that the route is ignored if the session is invalid or the required roles are not active for the session. This is already handled by the engine, just the binding needs to ask the route to verify passing a valid session.
Guarded expressions are references to attributes of the session for a specific guard. It does not require any specific roles to be active. In each case we need the guard handler to resolve the guarded identity or guarded attribute expression.
The original mistake in the design was requiring guarded expressions on a route to only work on a guarded route, whereas this enhancement is to break that coupling, so that routes do not need to be guarded for guarded expressions to work.
So as part of these changes, we can verify that it is viable to remove the exposure of identity resolver and attribute resolver from the route as that can only be populated for guarded routes and therefore not relevant in the general case. As part of that removal we can also consider making it easier to obtain the guard handler by name instead of having to jump through so many hoops in the binding as it calls back into the engine context.
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.
I attempted to simplify the code by always using EngineContext.supplyGuard() instead of checking route.guarded.identity or route.guarded.attributes first, but this caused integration test failures and AssertionErrors. For existing guarded routes, context.supplyGuard() returned null because the guards hadn’t been fully registered in EngineContext at that point in the lifecycle. This resulted in some existing test failures.
To resolve this, should we defer route-config construction until the EngineContext is fully populated?
@jfallows, please share your thoughts.
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.
@nageshwaravijay1117 there was an issue with the guardId obtained from the guardName, so the lookup for GuardHandler then failed.
See de35c8a where I have made the necessary resolveId function available on the RouteConfig and used it from http-kafka to demonstrate tests passing without needing to use the guarded routes.
Please review and make corresponding changes to sse-kafka.
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.
@jfallows verified the changes locally and updated the SSE-Kafka changes.
Added support for guard identity expressions without explicit guarded routes
Implemented two-phase guard processing in EngineManager to enable guard expressions like ${guarded[''].identity} and ${guarded[''].attributes.*} to work without declaring the guard in a route's guarded section.
Fixes #1518.