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

fix browser auth issue, multiple roles, and make role to assume more flexible #318

Merged
merged 1 commit into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private Node getAwsStsSamlForm(Document document) {
Node formActionAttribute = formAttributes.getNamedItem("action");
if (formActionAttribute != null) {
String formAction = formActionAttribute.getTextContent();
if ("https://signin.aws.amazon.com/saml".equals(formAction)) {
if (formAction.endsWith("/saml")) {
return form;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/okta/tools/helpers/RoleHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public AssumeRoleWithSAMLRequest chooseAwsRoleToAssume(String samlResponse) thro
for (RoleOption roleOption : accountOption.roleOptions) {
roleArns.add(roleOption.roleArn);
System.err.println("\t[ " + (i + 1) + " ]: " + roleOption.roleName);
if (roleOption.roleArn.equals(environment.awsRoleToAssume)) {
if (roleOption.roleArn.equals(environment.awsRoleToAssume) ||
roleOption.roleName.equals(environment.awsRoleToAssume)) {
j = i;
}
i++;
Expand Down Expand Up @@ -120,7 +121,7 @@ public AssumeRoleWithSAMLRequest chooseAwsRoleToAssume(String samlResponse) thro
public List<AccountOption> getAvailableRoles(String samlResponse) throws IOException {
Map<String, String> roles = AwsSamlRoleUtils.getRoles(samlResponse);
if (roles.size() == 1) {
String roleArn = roles.values().iterator().next();
String roleArn = roles.keySet().iterator().next();
return Collections.singletonList(
new AccountOption("Account: (" + roleArn.substring("arn:aws:iam::".length(), "arn:aws:iam::".length() + 12) + ")",
Collections.singletonList(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/okta/tools/saml/AwsSamlRoleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Map<String, String> getRoles(String samlResponse) {
String[] parts = roleIdpPair.split(",");
String principalArn = parts[0];
String roleArn = parts[1];
roles.put(principalArn, roleArn);
roles.put(roleArn, principalArn);
}
return roles;
}
Expand Down