Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Add aws auth support #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add aws auth support #10

wants to merge 1 commit into from

Conversation

4killo
Copy link

@4killo 4killo commented May 1, 2022

  • with this change, application uses this sdk and run in aws environment can use meta datas for auth.

 - with this chnage, appliaction uses this sdk and run in aws enviroment can use metadatas for auth
Copy link
Collaborator

@andrii-zakurenyi andrii-zakurenyi left a comment

Choose a reason for hiding this comment

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

I've added a bunch of small comments. Nothing huge. In general PR looks good to me

return "", "", err
}

body, err := ioutil.ReadAll(r.HTTPRequest.Body)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is recommended to use io.ReadAll() in a new code. Please change to io.ReadAll(r.HTTPRequest.Body)


func (a *authorization) getCallerIdentityRequest() *request.Request {
r, _ := sts.New(a.sess).GetCallerIdentityRequest(nil)
r.Sign()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sign() method can return error. Is it ok to ignore it?

)

const (
defaultTLD string = "com"
defaultURLTemplate string = "https://%s.secretsvaultcloud.%s/v1/%s%s"
defaultURLTemplate string = "https://%s.devbambe.%s/v1/%s%s"
Copy link
Collaborator

Choose a reason for hiding this comment

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

devbambe is internal. Please fix

log.Fatalf("failed to configure vault: %v", err)
}

secret, err := dsv.Secret("resources:us-east-5:server1")
Copy link
Collaborator

Choose a reason for hiding this comment

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

in the example/client/client_auth.go file you made this change:

-	secret, err := dsv.Secret("path:of:the:secret")
+	secret, err := dsv.Secret("your secret path")

maybe in this example it should also be the same dsv.Secret("your secret path").

Or make path to a Secret configurable (via env or flags).

@@ -117,18 +131,43 @@ func (v Vault) accessResource(method, resource, path string, input interface{})
return data, err
}

type requestBody struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

requestBody is too global (or universal). Please choose a better name e.g. "accessTokenRequest"

Password string `json:"password"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
RefreshToken string `json:"refresh_token"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like "RefreshToken" field is not used.

t.Error("unexpected err", err)
}

if !reflect.DeepEqual(header, tt.expectedHeader) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

header and tt.expectedHeader are strings. No need to use reflect package to compare them.

t.Error("unexpected header", header)
}

if !reflect.DeepEqual(body, tt.expectedBody) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

body and tt.expectedBody are strings. No need to use reflect package to compare them.

@@ -1,3 +1,7 @@
module github.com/thycotic/dsv-sdk-go

go 1.13
go 1.18
Copy link
Collaborator

Choose a reason for hiding this comment

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

awesome. Please change version in ".github/workflows/tests.yml" too

Comment on lines +16 to +17
GCP
AZURE
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe these should be added once supported.

Copy link
Collaborator

@andrii-zakurenyi andrii-zakurenyi left a comment

Choose a reason for hiding this comment

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

Please update README too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants