feat(credentials): Add PasswordAttributes credential type (#6110)
This commit is contained in:
1 parent
d0050ad881
commit
5cf33fa8b3
5 files changed
+146
-37
No files matched your search
@@ -16,6 +16,7 @@ func init() {
|
||||
globals.RegisterPrefixToResourceInfo(globals.UsernamePasswordCredentialPrefix, resource.Credential, Domain, UsernamePasswordSubtype)
|
||||
globals.RegisterPrefixToResourceInfo(globals.UsernamePasswordDomainCredentialPrefix, resource.Credential, Domain, UsernamePasswordDomainSubtype)
|
||||
globals.RegisterPrefixToResourceInfo(globals.UsernamePasswordCredentialPreviousPrefix, resource.Credential, Domain, UsernamePasswordSubtype)
|
||||
globals.RegisterPrefixToResourceInfo(globals.PasswordCredentialPrefix, resource.Credential, Domain, PasswordSubtype)
|
||||
globals.RegisterPrefixToResourceInfo(globals.SshPrivateKeyCredentialPrefix, resource.Credential, Domain, SshPrivateKeySubtype)
|
||||
globals.RegisterPrefixToResourceInfo(globals.JsonCredentialPrefix, resource.Credential, Domain, JsonSubtype)
|
||||
}
|
||||
@@ -25,6 +26,8 @@ const (
|
||||
|
||||
UsernamePasswordDomainSubtype = globals.Subtype("username_password_domain")
|
||||
|
||||
PasswordSubtype = globals.Subtype("password")
|
||||
|
||||
SshPrivateKeySubtype = globals.Subtype("ssh_private_key")
|
||||
|
||||
JsonSubtype = globals.Subtype("json")
|
||||
@@ -48,6 +51,15 @@ func NewUsernamePasswordDomainCredentialId(ctx context.Context) (string, error)
|
||||
return id, nil
|
||||
}
|
||||
|
||||
// PasswordCredentialId generates a new public ID for a password credential.
|
||||
func PasswordCredentialId(ctx context.Context) (string, error) {
|
||||
id, err := db.NewPublicId(ctx, globals.PasswordCredentialPrefix)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(ctx, err, "credential.PasswordCredentialId")
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
// New SshPrivateKeyCredentialId generates a new public ID for an SSH private key credential.
|
||||
func NewSshPrivateKeyCredentialId(ctx context.Context) (string, error) {
|
||||
id, err := db.NewPublicId(ctx, globals.SshPrivateKeyCredentialPrefix)
|
||||
|
||||
@@ -2060,6 +2060,7 @@ func validateAddCredentialSourcesRequest(req *pbs.AddTargetCredentialSourcesRequ
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.UsernamePasswordDomainCredentialPrefix,
|
||||
globals.PasswordCredentialPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
@@ -2074,6 +2075,7 @@ func validateAddCredentialSourcesRequest(req *pbs.AddTargetCredentialSourcesRequ
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.UsernamePasswordDomainCredentialPrefix,
|
||||
globals.PasswordCredentialPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix) {
|
||||
badFields[globals.InjectedApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
@@ -2100,6 +2102,7 @@ func validateSetCredentialSourcesRequest(req *pbs.SetTargetCredentialSourcesRequ
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.UsernamePasswordDomainCredentialPrefix,
|
||||
globals.PasswordCredentialPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
@@ -2114,6 +2117,7 @@ func validateSetCredentialSourcesRequest(req *pbs.SetTargetCredentialSourcesRequ
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.UsernamePasswordDomainCredentialPrefix,
|
||||
globals.PasswordCredentialPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix) {
|
||||
badFields[globals.InjectedApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
@@ -2144,6 +2148,7 @@ func validateRemoveCredentialSourcesRequest(req *pbs.RemoveTargetCredentialSourc
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.UsernamePasswordDomainCredentialPrefix,
|
||||
globals.PasswordCredentialPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
@@ -2158,6 +2163,7 @@ func validateRemoveCredentialSourcesRequest(req *pbs.RemoveTargetCredentialSourc
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.UsernamePasswordDomainCredentialPrefix,
|
||||
globals.PasswordCredentialPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.InjectedApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
|
||||
@@ -157,6 +157,28 @@ message UsernamePasswordDomainAttributes {
|
||||
]; // @gotags: `class:"public"`
|
||||
}
|
||||
|
||||
// The attributes of a Password Credential.
|
||||
message PasswordAttributes {
|
||||
// Input only. The password associated with the credential.
|
||||
google.protobuf.StringValue password = 10 [
|
||||
json_name = "password",
|
||||
(custom_options.v1.generate_sdk_option) = true,
|
||||
(custom_options.v1.mask_mapping) = {
|
||||
this: "attributes.password"
|
||||
that: "Password"
|
||||
}
|
||||
]; // @gotags: `class:"secret"`
|
||||
|
||||
// Output only. The hmac value of the password.
|
||||
string password_hmac = 20 [
|
||||
json_name = "password_hmac",
|
||||
(custom_options.v1.mask_mapping) = {
|
||||
this: "attributes.password_hmac"
|
||||
that: "PasswordHmac"
|
||||
}
|
||||
]; // @gotags: `class:"public"`
|
||||
}
|
||||
|
||||
// The attributes of a SshPrivateKey Credential.
|
||||
message SshPrivateKeyAttributes {
|
||||
// The username associated with the credential.
|
||||
|
||||
Reference in new issue
Block a user