Files
threshold/internal/session/static_credential.go
T
429247f407 [COMPLIANCE] Update Copyright Headers (#6282)
* [COMPLIANCE] Update Copyright and License Headers

* chore: make gen to generate files with copyright headers

* chore: update missed copyright headers

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Justin Nguyen <justin.nguyen@hashicorp.com>
2026-01-28 11:05:07 -06:00

49 lines
1.4 KiB
Go

// Copyright IBM Corp. 2020, 2025
// SPDX-License-Identifier: BUSL-1.1
package session
import (
cred "github.com/hashicorp/boundary/internal/credential"
)
// A StaticCredential represents the relationship between a session, a
// credential and the purpose of the credential.
type StaticCredential struct {
SessionId string `json:"session_id,omitempty" gorm:"primary_key"`
CredentialPurpose string `json:"credential_purpose,omitempty" gorm:"primary_key"`
CredentialStaticId string `json:"credential_id,omitempty" gorm:"default:null"`
tableName string `gorm:"-"`
}
// NewStaticCredential creates a new in memory Credential representing the
// relationship between session a credential and the purpose of the credential.
func NewStaticCredential(id string, purpose cred.Purpose) *StaticCredential {
return &StaticCredential{
CredentialStaticId: id,
CredentialPurpose: string(purpose),
}
}
func (c *StaticCredential) clone() *StaticCredential {
return &StaticCredential{
SessionId: c.SessionId,
CredentialPurpose: c.CredentialPurpose,
CredentialStaticId: c.CredentialStaticId,
}
}
// TableName returns the table name.
func (c *StaticCredential) TableName() string {
if c.tableName != "" {
return c.tableName
}
return "session_credential_static"
}
// SetTableName sets the table name.
func (c *StaticCredential) SetTableName(n string) {
c.tableName = n
}