Skip to content

Commit

Permalink
Merge branch 'master' into continueShutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjeschke authored Aug 8, 2019
2 parents be67b8d + 8253885 commit 4399681
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- ECR credentials from IAM Task role for ECS Fargate deployment ([#1233](https://github.com/fabric8io/docker-maven-plugin/issues/1233))
- Fix bug in properties names extracted from docker config json file ([#1237](https://github.com/fabric8io/docker-maven-plugin/issues/1237))
- Fix that portPropertyFile is not written anymore [F#1112]
- Use identity token if found in Docker config.json ([#1249](https://github.com/fabric8io/docker-maven-plugin/issues/1249))

* **0.30.0** (2019-04-21)
- Restore ANSI color to Maven logging if disabled during plugin execution and enable color for Windows with Maven 3.5.0 or later. Color logging is enabled by default, but disabled if the Maven CLI disables color (e.g. in batch mode) ([#1108](https://github.com/fabric8io/docker-maven-plugin/issues/1108))
Expand Down
37 changes: 32 additions & 5 deletions src/main/java/io/fabric8/maven/docker/access/AuthConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,28 @@ public class AuthConfig {
private final String password;
private final String email;
private final String auth;
private final String identityToken;

private final String authEncoded;

public AuthConfig(Map<String,String> params) {
this(params.get("username"),
params.get("password"),
params.get("email"),
params.get("auth"));
params.get("auth"),
params.get("identityToken"));
}

public AuthConfig(String username, String password, String email, String auth) {
this(username, password, email, auth, null);
}

public AuthConfig(String username, String password, String email, String auth, String identityToken) {
this.username = username;
this.password = password;
this.email = email;
this.auth = auth;
this.identityToken = identityToken;
authEncoded = createAuthEncoded();
}

Expand All @@ -47,11 +54,22 @@ public AuthConfig(String username, String password, String email, String auth) {
* @param email the email to use for authentication
*/
public AuthConfig(String credentialsEncoded, String email) {
this(credentialsEncoded, email, null);
}

/**
* Constructor which takes an base64 encoded credentials in the form 'user:password'
*
* @param credentialsEncoded the docker encoded user and password
* @param email the email to use for authentication
*/
public AuthConfig(String credentialsEncoded, String email, String identityToken) {
String credentials = new String(Base64.decodeBase64(credentialsEncoded));
String[] parsedCreds = credentials.split(":",2);
username = parsedCreds[0];
password = parsedCreds[1];
this.email = email;
this.identityToken = identityToken;
auth = null;
authEncoded = createAuthEncoded();
}
Expand All @@ -68,6 +86,10 @@ public String getAuth() {
return auth;
}

public String getIdentityToken() {
return identityToken;
}

public String toHeaderValue() {
return authEncoded;
}
Expand All @@ -76,10 +98,15 @@ public String toHeaderValue() {

private String createAuthEncoded() {
JsonObject ret = new JsonObject();
putNonNull(ret, "username", username);
putNonNull(ret, "password", password);
putNonNull(ret, "email", email);
putNonNull(ret, "auth", auth);
if(identityToken != null) {
putNonNull(ret, "identitytoken", identityToken);
} else {
putNonNull(ret, "username", username);
putNonNull(ret, "password", password);
putNonNull(ret, "email", email);
putNonNull(ret, "auth", auth);
}

try {
return encodeBase64ChunkedURLSafeString(ret.toString().getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,9 @@ private AuthConfig extractAuthConfigFromAuths(String registryToLookup, JsonObjec
return null;
}
String auth = credentials.get("auth").getAsString();
String identityToken = credentials.has("identitytoken") ? credentials.get("identitytoken").getAsString() : null;
String email = credentials.has(AUTH_EMAIL) ? credentials.get(AUTH_EMAIL).getAsString() : null;
return new AuthConfig(auth,email);
return new AuthConfig(auth, email, identityToken);
}

private AuthConfig extractAuthConfigFromCredentialsHelper(String registryToLookup, String credConfig) throws MojoExecutionException {
Expand Down

0 comments on commit 4399681

Please sign in to comment.