Skip to content
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

Conversation

hiragi-gkuth
Copy link
Contributor

@hiragi-gkuth hiragi-gkuth commented Jun 7, 2023

resolve #2201

I'm going to add tests.

Shimaoka Shuya added 2 commits June 7, 2023 10:17
Signed-off-by: Shimaoka Shuya <[email protected]>
Signed-off-by: Shimaoka Shuya <[email protected]>
@hiragi-gkuth hiragi-gkuth marked this pull request as draft June 8, 2023 01:46
}
// then, we conduct a perfect match search
if (skipDomain.equals(domainName)) {
Copy link
Collaborator

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 *

Copy link
Contributor Author

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) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Shimaoka Shuya added 3 commits June 8, 2023 14:49
Signed-off-by: Shimaoka Shuya <[email protected]>
Signed-off-by: Shimaoka Shuya <[email protected]>
Signed-off-by: Shimaoka Shuya <[email protected]>
@hiragi-gkuth
Copy link
Contributor Author

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(",")));
Copy link
Collaborator

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(","));

Copy link
Contributor Author

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]>
@hiragi-gkuth hiragi-gkuth marked this pull request as ready for review June 8, 2023 07:10
@hiragi-gkuth hiragi-gkuth marked this pull request as draft June 8, 2023 12:27
@hiragi-gkuth hiragi-gkuth marked this pull request as ready for review June 9, 2023 06:18
Copy link
Collaborator

@havetisyan havetisyan left a 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.

@hiragi-gkuth
Copy link
Contributor Author

@havetisyan

Thank you for your review. I've updated the documentation

@hiragi-gkuth
Copy link
Contributor Author

I forgot to commit with signed-off. I will rebase later.

@hiragi-gkuth hiragi-gkuth force-pushed the add-domain-prefix-check-for-service-validation branch from 8446c69 to 477703a Compare June 27, 2023 09:44
Signed-off-by: Shimaoka Shuya <[email protected]>
@hiragi-gkuth hiragi-gkuth force-pushed the add-domain-prefix-check-for-service-validation branch from 477703a to 7a8fa34 Compare June 27, 2023 09:48
@havetisyan havetisyan merged commit a264f25 into AthenZ:master Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

request for wildcard-based skip domain determination
2 participants