-
Notifications
You must be signed in to change notification settings - Fork 50
fix: IAM auth in CN RDS (#579) #582
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
| final Pattern auroraDnsPattern = | ||
| Pattern.compile( | ||
| "(.+)\\.(proxy-|cluster-|cluster-ro-|cluster-custom-)?[a-zA-Z0-9]+\\.([a-zA-Z0-9\\-]+)\\.rds\\.amazonaws\\.com", | ||
| "(.+)\\.(proxy-|cluster-|cluster-ro-|cluster-custom-)?[a-zA-Z0-9]+\\.([a-zA-Z0-9\\-]+)\\.rds\\.amazonaws\\.com(\\.cn)?", |
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.
Why do we need the last (\.cn) in this regexp? The code checks for China url pattern further.
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'd suggest to replocate entire method getRdsRegion() to RdsUtils.
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 was double checking this DNS pattern against the one in RdSUtils.java and it contains (\.cn)? at the end. Same thing in the aws-advanced-jdbc-wrapper. So it looks like this pattern may have been missing it.
| final Pattern auroraDnsPattern = | ||
| Pattern.compile( | ||
| "(.+)\\.(proxy-|cluster-|cluster-ro-|cluster-custom-)?[a-zA-Z0-9]+\\.([a-zA-Z0-9\\-]+)\\.rds\\.amazonaws\\.com", | ||
| "(.+)\\.(proxy-|cluster-|cluster-ro-|cluster-custom-)?[a-zA-Z0-9]+\\.([a-zA-Z0-9\\-]+)\\.rds\\.amazonaws\\.com(\\.cn)?", |
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 there might be some confusion here (?)
the first regex was supposed to try to match non-CN endpoints
and then there was the CN-matcher for CN endpoints
do you want to merge them so one regex matches both?
I would suggest to put the regex string as a static variable and in the comments put the patterns that are valid
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.
Added (\\.cn)? to the end because i noticed that the pattern in RdsUtils.java has it, but it doesnt have it here.
Personally, I'd prefer not to mix them. I'd rather keep it simple with two separate patterns, than one more complex one.
I will put them in static vars are you suggested though.
edit: I think i might actually just eliminate these patterns here, and directly reference the ones that are defined in RdsUtils.java
| log.logTrace(exceptionMessage); | ||
| throw ExceptionFactory.createException(exceptionMessage); | ||
| } | ||
| matcher = chinaMatcher; |
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.
do you need to do something with the matcher here?
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.
It gets used a lil further down.
| */ | ||
| @Test | ||
| public void test_7_ValidChinaHostAndRegion() { | ||
| Assertions.assertNotNull(new AwsIamAuthenticationTokenHelper( |
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.
maybe you should add a couple of examples that have the .cn at the end but have other irregularities in the middle of the URL to be sure your regex is catching what you want
73d5d1d to
5283ca7
Compare
5283ca7 to
ce0b254
Compare
Summary
fix: IAM auth in CN RDS (#579)
Description
Previously
AwsIamAuthenticationTokenHelper#getRegionaurora DNS pattern did not support CN regions. Added an aurora DNS pattern for CN region specifically.Additional Reviewers
By submitting this pull request, I confirm that my contribution is made under the terms of the GPLv2 license.