Rename root, api and sdk module paths (imports, go.mod, go_package, ldflags, build scripts, buf configs) and regenerate protobuf/gateway code with the project's pinned toolchain. Wire identifiers unchanged. api gets a local replace for sdk; root/api/sdk require v0.1.0. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
// Copyright IBM Corp. 2020, 2026
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package password
|
|
|
|
import (
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/auth/password/store"
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/oplog"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// A Credential is a base type and contains the attributes common to all
|
|
// credentials.
|
|
type Credential struct {
|
|
*store.Credential
|
|
tableName string `gorm:"-"`
|
|
}
|
|
|
|
func allocCredential() Credential {
|
|
return Credential{
|
|
Credential: &store.Credential{},
|
|
}
|
|
}
|
|
|
|
func (c *Credential) clone() *Credential {
|
|
cp := proto.Clone(c.Credential)
|
|
return &Credential{
|
|
Credential: cp.(*store.Credential),
|
|
}
|
|
}
|
|
|
|
// TableName returns the table name.
|
|
func (c *Credential) TableName() string {
|
|
if c.tableName != "" {
|
|
return c.tableName
|
|
}
|
|
return "auth_password_credential"
|
|
}
|
|
|
|
// SetTableName sets the table name.
|
|
func (c *Credential) SetTableName(n string) {
|
|
c.tableName = n
|
|
}
|
|
|
|
func (c *Credential) oplog(op oplog.OpType) oplog.Metadata {
|
|
metadata := oplog.Metadata{
|
|
"resource-public-id": []string{c.PrivateId},
|
|
"resource-type": []string{"password-credential"},
|
|
"op-type": []string{op.String()},
|
|
}
|
|
if c.PasswordAccountId != "" {
|
|
metadata["account-id"] = []string{c.PasswordAccountId}
|
|
}
|
|
return metadata
|
|
}
|