mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 01:32:33 +00:00
adding private DNS name as EC2 metadata (#25418)
add instance dns name as inferred_hostname metadata field Co-authored-by: kpcraig <3031348+kpcraig@users.noreply.github.com>
This commit is contained in:
@@ -32,6 +32,7 @@ var (
|
||||
"inferred_aws_region",
|
||||
"inferred_entity_id",
|
||||
"inferred_entity_type",
|
||||
"inferred_hostname",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1456,6 +1456,7 @@ func (b *backend) pathLoginUpdateIam(ctx context.Context, req *logical.Request,
|
||||
|
||||
inferredEntityType := ""
|
||||
inferredEntityID := ""
|
||||
inferredHostname := ""
|
||||
if roleEntry.InferredEntityType == ec2EntityType {
|
||||
instance, err := b.validateInstance(ctx, req.Storage, entity.SessionInfo, roleEntry.InferredAWSRegion, callerID.Account)
|
||||
if err != nil {
|
||||
@@ -1482,6 +1483,7 @@ func (b *backend) pathLoginUpdateIam(ctx context.Context, req *logical.Request,
|
||||
|
||||
inferredEntityType = ec2EntityType
|
||||
inferredEntityID = entity.SessionInfo
|
||||
inferredHostname = *instance.PrivateDnsName
|
||||
}
|
||||
|
||||
auth := &logical.Auth{
|
||||
@@ -1496,6 +1498,7 @@ func (b *backend) pathLoginUpdateIam(ctx context.Context, req *logical.Request,
|
||||
"inferred_entity_id": inferredEntityID,
|
||||
"inferred_aws_region": roleEntry.InferredAWSRegion,
|
||||
"account_id": entity.AccountNumber,
|
||||
"inferred_hostname": inferredHostname,
|
||||
},
|
||||
DisplayName: entity.FriendlyName,
|
||||
Alias: &logical.Alias{
|
||||
@@ -1517,6 +1520,7 @@ func (b *backend) pathLoginUpdateIam(ctx context.Context, req *logical.Request,
|
||||
"inferred_entity_id": inferredEntityID,
|
||||
"inferred_aws_region": roleEntry.InferredAWSRegion,
|
||||
"account_id": entity.AccountNumber,
|
||||
"inferred_hostname": inferredHostname,
|
||||
}); err != nil {
|
||||
b.Logger().Warn(fmt.Sprintf("unable to set alias metadata due to %s", err))
|
||||
}
|
||||
|
||||
@@ -408,6 +408,7 @@ func TestBackend_pathLogin_IAMHeaders(t *testing.T) {
|
||||
"inferred_aws_region",
|
||||
"inferred_entity_id",
|
||||
"inferred_entity_type",
|
||||
"inferred_hostname",
|
||||
},
|
||||
"ec2_alias": "role_id",
|
||||
"ec2_metadata": []string{
|
||||
@@ -614,6 +615,7 @@ func TestBackend_pathLogin_IAMRoleResolution(t *testing.T) {
|
||||
"inferred_aws_region",
|
||||
"inferred_entity_id",
|
||||
"inferred_entity_type",
|
||||
"inferred_hostname",
|
||||
},
|
||||
"ec2_alias": "role_id",
|
||||
"ec2_metadata": []string{
|
||||
|
||||
4
changelog/25418.txt
Normal file
4
changelog/25418.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
```release-note:improvement
|
||||
auth/aws: Add inferred_hostname metadata for IAM AWS authentication method.
|
||||
```
|
||||
Reference in New Issue
Block a user