-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
added AWS enpoint handling #3416
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -29,6 +29,8 @@ func getRootConfig(s logical.Storage) (*aws.Config, error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
credsConfig.AccessKey = config.AccessKey | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
credsConfig.SecretKey = config.SecretKey | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
credsConfig.Region = config.Region | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
credsConfig.IAMEndpoint = config.IAMEndpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
credsConfig.STSEndpoint = config.STSEndpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if credsConfig.Region == "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -51,6 +53,8 @@ func getRootConfig(s logical.Storage) (*aws.Config, error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return &aws.Config{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Credentials: creds, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Region: aws.String(credsConfig.Region), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IAMEndpoint: aws.String(credsConfig.IAMEndpoint), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
STSEndpoint: aws.String(credsConfig.STSEndpoint), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure the issue is because you're using the upstream vault/builtin/credential/aws/client.go Lines 24 to 68 in 1c4baa5
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
HTTPClient: cleanhttp.DefaultClient(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -60,7 +64,13 @@ func clientIAM(s logical.Storage) (*iam.IAM, error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
client := iam.New(session.New(awsConfig)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if *awsConfig.IAMEndpoint != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then this becomes *awsConfig.Endpoint |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
client = iam.New(session.New(awsConfig.WithEndpoint(*awsConfig.IAMEndpoint))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if client == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, fmt.Errorf("could not obtain iam client") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -73,6 +83,9 @@ func clientSTS(s logical.Storage) (*sts.STS, error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
client := sts.New(session.New(awsConfig)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if *awsConfig.STSEndpoint != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
client = sts.New(session.New(awsConfig.WithEndpoint(*awsConfig.STSEndpoint))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if client == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, fmt.Errorf("could not obtain sts client") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,14 @@ func pathConfigRoot() *framework.Path { | |
Type: framework.TypeString, | ||
Description: "Region for API calls.", | ||
}, | ||
"iamendpoint": &framework.FieldSchema{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The auth backend already has iam_endpoint and sts_endpoint; it'd be good to underscore-separate this here. |
||
Type: framework.TypeString, | ||
Description: "Endpoint to custom IAM server URL", | ||
}, | ||
"stsendpoint": &framework.FieldSchema{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
Type: framework.TypeString, | ||
Description: "Endpoint to custom STS server URL", | ||
}, | ||
}, | ||
|
||
Callbacks: map[logical.Operation]framework.OperationFunc{ | ||
|
@@ -37,11 +45,15 @@ func pathConfigRoot() *framework.Path { | |
func pathConfigRootWrite( | ||
req *logical.Request, data *framework.FieldData) (*logical.Response, error) { | ||
region := data.Get("region").(string) | ||
iamendpoint := data.Get("iamendpoint").(string) | ||
stsendpoint := data.Get("stsendpoint").(string) | ||
|
||
entry, err := logical.StorageEntryJSON("config/root", rootConfig{ | ||
AccessKey: data.Get("access_key").(string), | ||
SecretKey: data.Get("secret_key").(string), | ||
Region: region, | ||
AccessKey: data.Get("access_key").(string), | ||
SecretKey: data.Get("secret_key").(string), | ||
IAMEndpoint: iamendpoint, | ||
STSEndpoint: stsendpoint, | ||
Region: region, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -55,9 +67,11 @@ func pathConfigRootWrite( | |
} | ||
|
||
type rootConfig struct { | ||
AccessKey string `json:"access_key"` | ||
SecretKey string `json:"secret_key"` | ||
Region string `json:"region"` | ||
AccessKey string `json:"access_key"` | ||
SecretKey string `json:"secret_key"` | ||
IAMEndpoint string `json:"iamendpoint"` | ||
STSEndpoint string `json:"stsendpoint"` | ||
Region string `json:"region"` | ||
} | ||
|
||
const pathConfigRootHelpSyn = ` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,12 @@ type CredentialsConfig struct { | |
// the client elsewhere. | ||
Region string | ||
|
||
//Endpoint to custom IAM server URL | ||
IAMEndpoint string | ||
|
||
//Endpoint to custom STS server URL | ||
STSEndpoint string | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And then you can just remove these. |
||
// The filename for the shared credentials provider, if being used | ||
Filename string | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place
credsConfig.IAMEndpoint
andcredsConfig.STSEndpoint
are referenced. I don't think you need them in theCredentialsConfig
struct at all because, below, you're putting the endpoint directly in theaws.Config
object.