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

Use AWS SDK to fetch AWS credentials #1311

Merged
merged 19 commits into from Jan 21, 2020
Merged

Use AWS SDK to fetch AWS credentials #1311

merged 19 commits into from Jan 21, 2020

Conversation

sebastiankirsch
Copy link
Contributor

As discussed in #1310, credentials for ECR would be fetched via AWS SDK.

The dependency is optional, yet it would only introduce this:

[INFO] +- com.amazonaws:aws-java-sdk-core:jar:1.11.696:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.7.3:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.6.7:compile

i.e. outside of the SDK itself, only Jackson.
So: would you consider making this a full dependency, which would allow to remove 170loc in AuthConfigFactory and some more in the according test? It would also allow to get rid of the AwsSigner4 and AwsSigner4Request classes, since that functionality is found in the SDK as well.

No matter what, this will make Jackson available, and with GSON already in the mix, maybe you want to prevent using Jackson via checkstyle or SonarCloud or something? Especially as long as it's optional.

I'll try to come up with a meaningful test for this...

@sebastiankirsch
Copy link
Contributor Author

My tests indicate that <optional>true</optional> doesn't seem to have an effect. I know that this works as expected for "normal" projects; maybe it's different for plugins?
So, it's either a no-go for this PR, incorporate the AWS SDK fully, or try to find a work-around with sub-modules and dynamic class loading...

Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be best to avoid direct type references to the SDK to avoid any issues in cases when those types are not available on the class path.

Instead, just use full reflection for everything:

Class prChainClass = Class.forName("com.amazonaws.auth.DefaultAWSCredentialsProviderChain");
Object chain = prChainClass.getConstructor(new Class[0]).newInstance();
....

(just as an example).

That way it would be also possible to use the SDK as plugin dependencies directly within the plugin declaration and there is no need for usion optional dependencies.

@codecov
Copy link

codecov bot commented Jan 20, 2020

Codecov Report

Merging #1311 into master will not change coverage.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #1311   +/-   ##
=========================================
  Coverage     56.29%   56.29%           
  Complexity     1816     1816           
=========================================
  Files           158      158           
  Lines          8653     8653           
  Branches       1335     1335           
=========================================
  Hits           4871     4871           
  Misses         3307     3307           
  Partials        475      475
Impacted Files Coverage Δ Complexity Δ
...o/fabric8/maven/docker/util/AuthConfigFactory.java 71.57% <ø> (ø) 82 <0> (ø) ⬇️
...bric8/maven/docker/access/ecr/EcrExtendedAuth.java 90.69% <100%> (ø) 11 <1> (ø) ⬇️

@sebastiankirsch sebastiankirsch changed the title WIP: Use AWS SDK to fetch AWS credentials Use AWS SDK to fetch AWS credentials Jan 20, 2020
Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot ! Looks really good, would love to merge it soonish and make a next release quite quickly.

Some minor review points though, please see below.


/**
* Shameless copy of the original for testing {@link io.fabric8.maven.docker.util.aws.AwsSdkAuthConfigFactory}.
* Based on <tt>com.amazonaws:aws-java-sdk-core:1.11.707</tt>.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any licensing issues ? Under which license the aws-java-sdk-core is licensed (so that it allows code copying with contribution ?). Don't wanna get into struggle because of licensing (was there already :)

Is there any chance that we could implement this without reusing SDK code ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know its only a test class, but still this could pose some issue for some folks. The good thing is that we are talking here about a tool which is not part the of any delivered application that builds with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AWS SDK is licensed under Apache License 2.0. Afaik that's one of the most liberal licenses you could ask for.

I could remove this, but then there wouldn't be a test at all. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, APL is ok. I had once a case where a GPL code snippet sneaked in (in another project). Was quite some hazzle to get this out again. I'm fine with it now (I will add some extra comment here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, licensing can be a pain...

src/main/asciidoc/inc/_authentication.adoc Outdated Show resolved Hide resolved
Co-Authored-By: Roland Huß <rhuss@redhat.com>
@sonarcloud
Copy link

sonarcloud bot commented Jan 21, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 1 Code Smell

82.4% 82.4% Coverage
0.0% 0.0% Duplication

Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks again !

@rhuss rhuss merged commit 8c4fab2 into fabric8io:master Jan 21, 2020
@sebastiankirsch
Copy link
Contributor Author

@rhuss
Copy link
Collaborator

rhuss commented Jan 21, 2020

@rhuss You're too fast for me: sebastiankirsch@f5a514b

sorry, this doesn't happen often these days ;-) I added your commit to master, as I already cut a new 0.33.0 release. So will make it into v0.34.0 then ...

rohanKanojia added a commit to rohanKanojia/jkube that referenced this pull request Jun 18, 2021
Add support in AuthConfigFactory to retrieve credentials from
different mechanisms for AWS.

Port of fabric8io/docker-maven-plugin#1311
Port of fabric8io/docker-maven-plugin#1310

Related to eclipse-jkube#702

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this pull request Jun 18, 2021
Add support in AuthConfigFactory to retrieve credentials from
different mechanisms for AWS.

Port of fabric8io/docker-maven-plugin#1311
Port of fabric8io/docker-maven-plugin#1310

Related to eclipse-jkube#702

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this pull request Jun 18, 2021
Add support in AuthConfigFactory to retrieve credentials from
different mechanisms for AWS.

Port of fabric8io/docker-maven-plugin#1311
Port of fabric8io/docker-maven-plugin#1310

Related to eclipse-jkube#702

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this pull request Jun 18, 2021
Add support in AuthConfigFactory to retrieve credentials from
different mechanisms for AWS.

Port of fabric8io/docker-maven-plugin#1311
Port of fabric8io/docker-maven-plugin#1310

Related to eclipse-jkube#702

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this pull request Jun 18, 2021
Add support in AuthConfigFactory to retrieve credentials from
different mechanisms for AWS.

Port of fabric8io/docker-maven-plugin#1311
Port of fabric8io/docker-maven-plugin#1310

Related to eclipse-jkube#702

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this pull request Jun 22, 2021
Add support in AuthConfigFactory to retrieve credentials from
different mechanisms for AWS.

Port of fabric8io/docker-maven-plugin#1311
Port of fabric8io/docker-maven-plugin#1310

Related to eclipse-jkube#702

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit to eclipse-jkube/jkube that referenced this pull request Jun 23, 2021
Add support in AuthConfigFactory to retrieve credentials from
different mechanisms for AWS.

Port of fabric8io/docker-maven-plugin#1311
Port of fabric8io/docker-maven-plugin#1310

Related to #702

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
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.

None yet

2 participants