Auth Manager API part 5: SigV4 Auth Manager#11995
Conversation
372fd66 to
5aaa81e
Compare
5aaa81e to
79f3917
Compare
|
The flink test failure seems unrelated. I will try to trigger a new run. |
|
|
||
| @Override | ||
| public HTTPRequest authenticate(HTTPRequest request) { | ||
| return sign(delegate.authenticate(request)); |
There was a problem hiding this comment.
We don't appear to have a precondition check or protect against the delegate being null.
|
Only one minor comment, but I'll wait for @nastra to look this over as well. |
d48a965 to
5de163d
Compare
| @Override | ||
| public RESTSigV4AuthSession catalogSession( | ||
| RESTClient sharedClient, Map<String, String> properties) { | ||
| catalogProperties = properties; |
There was a problem hiding this comment.
| catalogProperties = properties; | |
| this.catalogProperties = properties; |
| private final Aws4Signer signer = Aws4Signer.create(); | ||
| private final AuthManager delegate; | ||
|
|
||
| private Map<String, String> catalogProperties; |
There was a problem hiding this comment.
should this maybe be an empty map by default? What happens if the methods are called in the wrong order and the map hasn't been initialized yet?
| this.delegate = Preconditions.checkNotNull(delegateAuthSession, "Invalid delegate: null"); | ||
| this.signingRegion = awsProperties.restSigningRegion(); | ||
| this.signingName = awsProperties.restSigningName(); | ||
| this.credentialsProvider = awsProperties.restCredentialsProvider(); |
There was a problem hiding this comment.
is the credentials provider returned here always non-null?
There was a problem hiding this comment.
Looking at AwsProperties, yes.
| HTTPHeader.of("Content-Type", "application/json"), | ||
| HTTPHeader.of("Content-Encoding", "gzip"))) | ||
| .build()); | ||
| try (RESTSigV4AuthSession session = new RESTSigV4AuthSession(signer, delegate, awsProperties)) { |
There was a problem hiding this comment.
we should also have some separate test method(s) that pass nulls as parameters but also where the required aws props (region/name) aren't set
There was a problem hiding this comment.
I added tests for null parameters but I don't see how to test missing props, because AwsProperties falls back to environment variables in that case.
| private Map<String, String> catalogProperties; | ||
|
|
||
| public RESTSigV4AuthManager(String name, AuthManager delegate) { | ||
| this.delegate = delegate; |
There was a problem hiding this comment.
we might also want to make sure that the delegate is non-null here
5th PR for the Auth Manager API. Previous ones:
This PR introduces the SigV4 auth manager. It can be reviewed independently of part4.
The peculiarity of the SIgV4 manager is that it takes a delegate auth manager. IOW, it is able to first delegate authentication to some other auth manager (by default, OAuth2), then sign the request, potentially relocating the authorization header introduced by the delegate manager. This is the current behavior of SigV4 signing.
Contrary to what I said earlier on the dev list, the SigV4 manager at this stage is still "unplugged". Merging this PR is completely harmless.
The old
RESTSigV4Signeris still there and active, its contents can be compared with those of the newRESTSigV4AuthSessionthat will replace it soon.\cc @nastra @danielcweeks