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

service/iam: AssumeRolePolicyDocument is a JSON string and requires unescaping #227

Closed
pete911 opened this issue Oct 15, 2018 · 5 comments
Closed
Labels
closed-for-staleness feature-request A feature should be added or improved.

Comments

@pete911
Copy link

pete911 commented Oct 15, 2018

Version of AWS SDK for Go v2.0.0-preview.5

Version of Go (1.11)

Assume role policy document response from iam.GetRoleRequest is url encoded

Steps to reproduce

out, _ := svc.GetRoleRequest(&iam.GetRoleInput{RoleName: aws.String(roleName)}).Send()
document := aws.StringValue(out.Role.AssumeRolePolicyDocument)
// document is url encoded need to decode it
decodedDocument, _ := url.PathUnescape(document)

Decoding/unescaping should be done before the struct is returned. User should NOT know/care about these things.

@pete911
Copy link
Author

pete911 commented Apr 10, 2019

I don't mind creating PR, but need some pointers, because service/iam/api.go (where the code needs to be added) says Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
But cannot find what is calling that main.go. I had a quick look at Makefile ... Can you point me to some docs about project structure etc.

@jasdel jasdel added the feature-request A feature should be added or improved. label May 17, 2019
@jasdel jasdel changed the title IAM Policy is url encoded service/iam: AssumeRolePolicyDocument requires manual url unescaping May 17, 2019
@jasdel jasdel changed the title service/iam: AssumeRolePolicyDocument requires manual url unescaping service/iam: AssumeRolePolicyDocument is a JSON string and requires unescaping May 17, 2019
@jasdel
Copy link
Contributor

jasdel commented May 17, 2019

Thanks for the feature request @pete911. The SDK does not currently have the metadata available to know that the AssumeRolePolicyDocument member's value is a JSON string. I suggest using strconv.Unqoute instead of url.PathUnescape. I think this will ensure consistent results without any side effects.

@pete911
Copy link
Author

pete911 commented May 18, 2019

@jasdel is this because the library is generated from templates? quicker/easier to keep multiple libraries written in different languages up to date? Because to me this seems like quick fix.

@jasdel
Copy link
Contributor

jasdel commented May 28, 2019

The AWS SDKs for Go (v1 and v2) are generated from models defined by the API service teams. The SDK will consume these models to generate the SDK's API clients, operation methods, and types. Given the current model information the AssumeRolePolicyDocument field is a string value, and the SDK doesn't have a way to know that the value should be unescaped, and is a document. I'll forward this issue onto the service team.

I think what one way we'd like to solve this issue is for fields like AssumeRolePolicyDocument to be decorated in a way that allow the SDK to know they are a JSON document, or at a minimum that the SDK should unescape the field's value during unmarshal.

Also, I mistakenly suggested strconv.Unquote. url.PathUnescape does look to be best workaround for this issue.

@github-actions
Copy link

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants