|
83 | 83 | globals.SshPrivateKeyCredentialType, |
84 | 84 | globals.UnspecifiedCredentialType, |
85 | 85 | globals.UsernamePasswordDomainCredentialType, |
| 86 | + globals.PasswordCredentialType, |
86 | 87 | } |
87 | 88 |
|
88 | 89 | validKeyTypes = []string{ |
@@ -851,6 +852,11 @@ func toProto(ctx context.Context, in credential.Library, opt ...handlers.Option) |
851 | 852 | m[domainAttribute] = mapping.DomainAttribute |
852 | 853 | } |
853 | 854 |
|
| 855 | + case *vault.PasswordOverride: |
| 856 | + if mapping.PasswordAttribute != "" { |
| 857 | + m[passwordAttribute] = mapping.PasswordAttribute |
| 858 | + } |
| 859 | + |
854 | 860 | case *vault.SshPrivateKeyOverride: |
855 | 861 | if mapping.UsernameAttribute != "" { |
856 | 862 | m[usernameAttribute] = mapping.UsernameAttribute |
@@ -1006,6 +1012,17 @@ func toStorageVaultLibrary(ctx context.Context, storeId string, in *pb.Credentia |
1006 | 1012 | opts = append(opts, vault.WithMappingOverride(vault.NewUsernamePasswordDomainOverride(mapOpts...))) |
1007 | 1013 | } |
1008 | 1014 |
|
| 1015 | + case globals.PasswordCredentialType: |
| 1016 | + opts = append(opts, vault.WithCredentialType(credentialType)) |
| 1017 | + overrides := in.CredentialMappingOverrides.AsMap() |
| 1018 | + var mapOpts []vault.Option |
| 1019 | + if password := overrides[passwordAttribute]; password != nil { |
| 1020 | + mapOpts = append(mapOpts, vault.WithOverridePasswordAttribute(password.(string))) |
| 1021 | + } |
| 1022 | + if len(mapOpts) > 0 { |
| 1023 | + opts = append(opts, vault.WithMappingOverride(vault.NewPasswordOverride(mapOpts...))) |
| 1024 | + } |
| 1025 | + |
1009 | 1026 | case globals.SshPrivateKeyCredentialType: |
1010 | 1027 | opts = append(opts, vault.WithCredentialType(credentialType)) |
1011 | 1028 | overrides := in.CredentialMappingOverrides.AsMap() |
@@ -1340,6 +1357,8 @@ func validateMapping(badFields map[string]string, credentialType globals.Credent |
1340 | 1357 | validFields[usernameAttribute] = true |
1341 | 1358 | validFields[passwordAttribute] = true |
1342 | 1359 | validFields[domainAttribute] = true |
| 1360 | + case globals.PasswordCredentialType: |
| 1361 | + validFields[passwordAttribute] = true |
1343 | 1362 | default: |
1344 | 1363 | badFields[globals.CredentialTypeField] = fmt.Sprintf("Unknown credential type %q", credentialType) |
1345 | 1364 | return |
@@ -1457,6 +1476,18 @@ func getMappingUpdates(credentialType globals.CredentialType, current vault.Mapp |
1457 | 1476 | default: |
1458 | 1477 | ret[domainAttribute] = currentDomain |
1459 | 1478 | } |
| 1479 | + case globals.PasswordCredentialType: |
| 1480 | + var currentPass any |
| 1481 | + if overrides, ok := current.(*vault.PasswordOverride); ok { |
| 1482 | + currentPass = overrides.PasswordAttribute |
| 1483 | + } |
| 1484 | + |
| 1485 | + switch { |
| 1486 | + case masks[passwordAttribute]: |
| 1487 | + ret[passwordAttribute] = new[passwordAttribute] |
| 1488 | + default: |
| 1489 | + ret[passwordAttribute] = currentPass |
| 1490 | + } |
1460 | 1491 | case globals.SshPrivateKeyCredentialType: |
1461 | 1492 | var currentUser, currentpPass, currentPk any |
1462 | 1493 | if overrides, ok := current.(*vault.SshPrivateKeyOverride); ok { |
|
0 commit comments