-
Notifications
You must be signed in to change notification settings - Fork 752
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
Introduce Configuration Pattern for Authn Handlers and Scopes #15363
Introduce Configuration Pattern for Authn Handlers and Scopes #15363
Conversation
…ina-lang into improve-inbound-auth
...erina-integration-test/src/test/java/org/ballerinalang/test/auth/AuthzConfigPatternTest.java
Show resolved
Hide resolved
(boolean|error?)[] responseArray = []; | ||
int count = 0; | ||
foreach AuthnHandler?[] authnHandler in authnHandlers { | ||
responseArray[count] = checkForAuthnHandlers(authnHandler, request); |
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.
Can we break early, without us having to go through all the authentication.
Since we are evaluating AND in this situation (array of arrays), if any of the group was evaluated to be "false" there is no need to proceed invoking other authenticators.
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.
Yeah. Could be improved without the use of the responseArray
. Done with 3ed5350
Codecov Report
@@ Coverage Diff @@
## master #15363 +/- ##
============================================
+ Coverage 22.18% 22.93% +0.74%
+ Complexity 6136 5112 -1024
============================================
Files 1798 1346 -452
Lines 83671 69308 -14363
Branches 12085 9384 -2701
============================================
- Hits 18563 15894 -2669
+ Misses 62095 51636 -10459
+ Partials 3013 1778 -1235
Continue to review full report at Codecov.
|
...erina-integration-test/src/test/java/org/ballerinalang/test/auth/AuthzConfigPatternTest.java
Outdated
Show resolved
Hide resolved
…ng/test/auth/AuthzConfigPatternTest.java Co-Authored-By: Gihan Anuruddha <wggihan@users.noreply.github.com>
Purpose
This is an improvement for Ballerina inbound authentication discussed at [1]. With this improvement, authn handlers and scopes can be engaged with both OR, AND logic. Example for scope engagement is as follows:
Auth should be successful for
scope-1
ORscope-2
.scopes: ["scopes-1", "scopes-2"]
Auth should be successful for
scope-1
ANDscope-2
.scopes: [["scopes-1"], ["scopes-2"]]
Auth should be successful for ((
scope-1
ORscope-2
) AND (scope-3
ORscope-4
)).scopes: [["scopes-1", "scopes-2"], ["scopes-3", "scopes-4"]]
Also, the same configuration pattern can be applied for auth providers as well.
[1] https://groups.google.com/d/msg/ballerina-dev/U3-GY9Q49eQ/TFUaJeZkAwAJ
Remarks
Related PR - #15056
Check List