-
Notifications
You must be signed in to change notification settings - Fork 284
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
add wildcard support for ServiceMemberSkipDomains #2202
add wildcard support for ServiceMemberSkipDomains #2202
Conversation
Signed-off-by: Shimaoka Shuya <[email protected]>
Signed-off-by: Shimaoka Shuya <[email protected]>
} | ||
// then, we conduct a perfect match search | ||
if (skipDomain.equals(domainName)) { |
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.
this should be "else if" otherwise we're wasting operations comparing the same value which already contains * against a domain name that will never include *
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.
thank you. I've fixed it.
if (!validateServiceMemberSkipDomains.contains(domainName)) { | ||
if (dbService.getServiceIdentity(domainName, serviceName, true) == null) { | ||
throw ZMSUtils.requestError("Principal " + memberName + " is not a valid service", caller); | ||
for (String skipDomain : validateServiceMemberSkipDomains) { |
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.
validateServiceMemberSkipDomains was created as a Set to have simple contains check. if we're treating as a regular list instead, you should change the definition to be an ArrayList instead of a Set.
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.
thank you. I've fixed it.
Signed-off-by: Shimaoka Shuya <[email protected]>
Signed-off-by: Shimaoka Shuya <[email protected]>
Signed-off-by: Shimaoka Shuya <[email protected]>
I have added test cases. |
@@ -830,7 +830,7 @@ void loadConfigurationSettings() { | |||
|
|||
final String skipDomains = System.getProperty( | |||
ZMSConsts.ZMS_PROP_VALIDATE_SERVICE_MEMBERS_SKIP_DOMAINS, ""); | |||
validateServiceMemberSkipDomains = new HashSet<>(Arrays.asList(skipDomains.split(","))); | |||
validateServiceMemberSkipDomains = new ArrayList<>(Arrays.asList(skipDomains.split(","))); |
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.
No need to create a new ArrayList<> here. Arrays.asList already does the job and returns an ArrayList. So just call it:
validateServiceMemberSkipDomains = Arrays.asList(skipDomains.split(","));
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 considered writing it that way, but Arrays.asList() and new ArrayList return different types. (ref)
As a result, there may be some confusion about this behavior in the future.
However, I am not too concerned about it, so I think Arrays.asList() is fine.
Thanks for pointing this out.
Signed-off-by: Shimaoka Shuya <[email protected]>
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.
@hiragi-gkuth one last request.
https://github.com/AthenZ/athenz/blob/master/servers/zms/conf/zms.properties#L434
can you update the documentation to indicate that the domain name can now include * wildcard at the end of the domain name to providing subdomain matching.
Thank you for your review. I've updated the documentation |
I forgot to commit with signed-off. I will rebase later. |
8446c69
to
477703a
Compare
Signed-off-by: Shimaoka Shuya <[email protected]>
477703a
to
7a8fa34
Compare
resolve #2201
I'm going to add tests.