MCPcopy Index your code
hub / github.com/coder/coder / getAuthenticatedURL

Function getAuthenticatedURL

coderd/database/awsiamrds/awsiamrds.go:84–100  ·  view source on GitHub ↗
(cfg aws.Config, dbURL string)

Source from the content-addressed store, hash-verified

82}
83
84func getAuthenticatedURL(cfg aws.Config, dbURL string) (string, error) {
85 nURL, err := url.Parse(dbURL)
86 if err != nil {
87 return "", xerrors.Errorf("parsing dbURL: %w", err)
88 }
89
90 // generate a new rds session auth tokenized URL
91 rdsEndpoint := fmt.Sprintf("%s:%s", nURL.Hostname(), nURL.Port())
92 token, err := auth.BuildAuthToken(context.Background(), rdsEndpoint, cfg.Region, nURL.User.Username(), cfg.Credentials)
93 if err != nil {
94 return "", xerrors.Errorf("building rds auth token: %w", err)
95 }
96 // set token as user password
97 nURL.User = url.UserPassword(nURL.User.Username(), token)
98
99 return nURL.String(), nil
100}
101
102type connector struct {
103 url string

Callers 2

OpenMethod · 0.85
ConnectMethod · 0.85

Calls 3

ParseMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected