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

Change credential_types output to credential_type #5975

Merged
merged 1 commit into from
Jan 4, 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.2 (Unreleased)

CHANGES:

* secret/aws: Role now returns `credential_type` instead of `credential_types`
to match role input. If a legacy role that can supply more than one
credential type, they will be concatenated with a `,`.

## 1.0.1 (December 14th, 2018)

SECURITY:
Expand Down
12 changes: 6 additions & 6 deletions builtin/logical/aws/path_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,12 @@ type awsRoleEntry struct {

func (r *awsRoleEntry) toResponseData() map[string]interface{} {
respData := map[string]interface{}{
"credential_types": r.CredentialTypes,
"policy_arns": r.PolicyArns,
"role_arns": r.RoleArns,
"policy_document": r.PolicyDocument,
"default_sts_ttl": int64(r.DefaultSTSTTL.Seconds()),
"max_sts_ttl": int64(r.MaxSTSTTL.Seconds()),
"credential_type": strings.Join(r.CredentialTypes, ","),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it also be wrapped with square brackets if the length is over 1? I ask because of this example in the issue: "credential_types": ["assumed_role"].

Copy link
Contributor

Choose a reason for hiding this comment

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

Note too, that the role_arns is an array type as well and should just be role_arn. I'd also assume that when you set role_arn that it conflicts with policy_arn and policy.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tyrannosaurus-becks The brackets are just the way it's being displayed. They're caused by the fact that it's coming back as an array even though the input is (now) a single string. The only reason it would be multiple values at this point is legacy roles, so this is a way to still allow legacy roles to display possibly more than one type while making the output the same type as the input.

@jasonmcintosh I'd also assume that when you set role_arn that it conflicts with policy_arn and policy. -- can you explain?

Copy link
Contributor

Choose a reason for hiding this comment

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

so if you set role_arn, that should be a conflicts with policy_document values. As I believe you don't want to try and modify a role.... just trying to think of the combinations and how they interact on this.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jasonmcintosh I'm not really following. Why should role_arns be role_arn? The logic allows for multiple values.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jefferai Not saying role_arns should be role_arn - saying role_arns should conflict with policy_arn and policy - as you can't have both a role_arn you're explicitly providing as well as a dynamically generated account.

Will see if this solves one of my headaches using terraform resource vault_generic_secret to create various vault roles. Still need to get the vault provider in terraform to work with this as well. https://github.com/terraform-providers/terraform-provider-vault/blob/master/vault/resource_aws_secret_backend_role.go . currently doesn't support role_arns :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @jasonmcintosh, agree that role_arns and policy_arns don't make sense together. The role creation code, I believe, prohibits creating roles with both values.

role_arns and policy_document are compatible -- the latter will scope down the the permissions granted to a role being assumed.

Is there something I'm missing in what you're saying?

"policy_arns": r.PolicyArns,
"role_arns": r.RoleArns,
"policy_document": r.PolicyDocument,
"default_sts_ttl": int64(r.DefaultSTSTTL.Seconds()),
"max_sts_ttl": int64(r.MaxSTSTTL.Seconds()),
}
if r.InvalidData != "" {
respData["invalid_data"] = r.InvalidData
Expand Down