109 KiB
model
import "github.com/effective-security/trustyca/internal/db/model"
Package model holds the database rows and their validation and conversion to the public API messages.
model.gen.go is generated by make gen-sql-schema from the local database and is never edited; the handwritten files own Validate, the constructors that build rows from parsed certificates (NewCertificate, NewRootCertificate, Issuer.SetCertificate, NewCertificateProfile) and the Pb conversions. JSON is the raw value of the jsonb config columns, which hold nested pb.IssuerConfig and pb.CertProfile documents:
issuer.SetConfig(&pb.IssuerConfig{CrlExpiry: "48h"})
cfg, err := issuer.GetConfig()
A CA row with a zero OrgID is the platform's, and a project row needs an org (validateTenancy).
Index
- Constants
- Variables
- func ScopeOf(projectID xdb.ID) pb.Scope_Enum
- type APIKey
- type APIKeyResult
- func (p *APIKeyResult) GetTableInfo() *xdbschema.TableInfo
- func (m *APIKeyResult) NextPage() *pb.NextPage
- func (m *APIKeyResult) Pb() *pb.APIKeysResponse
- func (p *APIKeyResult) SetResult(rows []*APIKey, hasNextPage bool, nextOffset uint32)
- func (p *APIKeyResult) SetResultWithCursor(rows []*APIKey, hasNextPage bool, cursor func(lastRow *APIKey) string)
- type APIKeySlice
- type Certificate
- func NewCertificate(crt *x509.Certificate, orgID, projectID xdb.ID, profile, pem, issuersPem, label string, locations []string, metadata xdb.Metadata) *Certificate
- func (m *Certificate) IsExpired(now time.Time) bool
- func (m *Certificate) Pb() *pb.Certificate
- func (m *Certificate) ScanRow(rows xdb.Row) error
- func (m *Certificate) Validate() error
- type CertificateCounts
- type CertificateProfile
- func NewCertificateProfile(orgID, projectID xdb.ID, p *pb.CertProfile) (*CertificateProfile, error)
- func (m *CertificateProfile) Definition() (*pb.CertProfile, error)
- func (m *CertificateProfile) Pb() (*pb.CertProfile, error)
- func (m *CertificateProfile) ScanRow(rows xdb.Row) error
- func (m *CertificateProfile) SetConfig(p *pb.CertProfile) error
- func (m *CertificateProfile) Validate() error
- type CertificateProfileResult
- func (p *CertificateProfileResult) GetTableInfo() *xdbschema.TableInfo
- func (v *CertificateProfileResult) NextPage() *pb.NextPage
- func (v *CertificateProfileResult) Pb() (*pb.ProfilesResponse, error)
- func (p *CertificateProfileResult) SetResult(rows []*CertificateProfile, hasNextPage bool, nextOffset uint32)
- func (p *CertificateProfileResult) SetResultWithCursor(rows []*CertificateProfile, hasNextPage bool, cursor func(lastRow *CertificateProfile) string)
- type CertificateProfileSlice
- type CertificateResult
- func (p *CertificateResult) GetTableInfo() *xdbschema.TableInfo
- func (v *CertificateResult) NextPage() *pb.NextPage
- func (v *CertificateResult) Pb() *pb.CertificatesResponse
- func (p *CertificateResult) SetResult(rows []*Certificate, hasNextPage bool, nextOffset uint32)
- func (p *CertificateResult) SetResultWithCursor(rows []*Certificate, hasNextPage bool, cursor func(lastRow *Certificate) string)
- type CertificateSlice
- type Crl
- type CrlResult
- func (p *CrlResult) GetTableInfo() *xdbschema.TableInfo
- func (v *CrlResult) NextPage() *pb.NextPage
- func (v *CrlResult) Pb() *pb.CrlsResponse
- func (p *CrlResult) SetResult(rows []*Crl, hasNextPage bool, nextOffset uint32)
- func (p *CrlResult) SetResultWithCursor(rows []*Crl, hasNextPage bool, cursor func(lastRow *Crl) string)
- type CrlSlice
- type CrlState
- type CrlStateResult
- type Event
- type EventResult
- func (p *EventResult) GetTableInfo() *xdbschema.TableInfo
- func (v *EventResult) NextPage() *pb.NextPage
- func (v *EventResult) Pb() *pb.EventsResponse
- func (p *EventResult) SetResult(rows []*Event, hasNextPage bool, nextOffset uint32)
- func (p *EventResult) SetResultWithCursor(rows []*Event, hasNextPage bool, cursor func(lastRow *Event) string)
- type EventSlice
- type Invite
- type InviteResult
- type InviteSlice
- type Issuer
- func (m *Issuer) GetConfig() (*pb.IssuerConfig, error)
- func (m *Issuer) Pb() (*pb.Issuer, error)
- func (m *Issuer) ScanRow(rows xdb.Row) error
- func (m *Issuer) SetCertificate(crt *x509.Certificate, pem, chainPem, rootPem string)
- func (m *Issuer) SetConfig(cfg *pb.IssuerConfig) error
- func (m *Issuer) Validate() error
- type IssuerCounts
- type IssuerResult
- func (p *IssuerResult) GetTableInfo() *xdbschema.TableInfo
- func (v *IssuerResult) NextPage() *pb.NextPage
- func (v *IssuerResult) Pb() (*pb.IssuersResponse, error)
- func (p *IssuerResult) SetResult(rows []*Issuer, hasNextPage bool, nextOffset uint32)
- func (p *IssuerResult) SetResultWithCursor(rows []*Issuer, hasNextPage bool, cursor func(lastRow *Issuer) string)
- type IssuerSlice
- type JSON
- func MarshalJSONValue(v any) (JSON, error)
- func (j JSON) IsEmpty() bool
- func (j JSON) MarshalJSON() ([]byte, error)
- func (j *JSON) Scan(value any) error
- func (j JSON) String() string
- func (j JSON) Unmarshal(v any) error
- func (j *JSON) UnmarshalJSON(data []byte) error
- func (j JSON) Value() (driver.Value, error)
- type Login
- type LoginResult
- type LoginSlice
- type Membership
- type MembershipInfo
- type MembershipInfoResult
- func (p *MembershipInfoResult) GetTableInfo() *xdbschema.TableInfo
- func (p *MembershipInfoResult) SetResult(rows []*MembershipInfo, hasNextPage bool, nextOffset uint32)
- func (p *MembershipInfoResult) SetResultWithCursor(rows []*MembershipInfo, hasNextPage bool, cursor func(lastRow *MembershipInfo) string)
- type MembershipInfoSlice
- func (m MembershipInfoSlice) CountOrgRole(orgID uint64, role pb.Role_Enum) int
- func (m MembershipInfoSlice) FilterByOrg(orgID uint64) MembershipInfoSlice
- func (m MembershipInfoSlice) FindMemberByEmail(email string, projectID uint64) *MembershipInfo
- func (m MembershipInfoSlice) FindMemberByUserID(userID, projectID uint64) *MembershipInfo
- func (m MembershipInfoSlice) OrgIDs() []xdb.ID
- func (m MembershipInfoSlice) Pb() []*pb.Membership
- type MembershipResult
- type MembershipSlice
- type Org
- type OrgResult
- func (p *OrgResult) GetTableInfo() *xdbschema.TableInfo
- func (v *OrgResult) NextPage() *pb.NextPage
- func (v *OrgResult) Pb() *pb.OrgsResponse
- func (p *OrgResult) SetResult(rows []*Org, hasNextPage bool, nextOffset uint32)
- func (p *OrgResult) SetResultWithCursor(rows []*Org, hasNextPage bool, cursor func(lastRow *Org) string)
- type OrgSlice
- type Project
- type ProjectResult
- func (p *ProjectResult) GetTableInfo() *xdbschema.TableInfo
- func (v *ProjectResult) NextPage() *pb.NextPage
- func (v *ProjectResult) Pb() *pb.ProjectsResponse
- func (p *ProjectResult) SetResult(rows []*Project, hasNextPage bool, nextOffset uint32)
- func (p *ProjectResult) SetResultWithCursor(rows []*Project, hasNextPage bool, cursor func(lastRow *Project) string)
- type ProjectSlice
- type RecordsResult
- type Revoked
- type RevokedCertificate
- type RevokedCertificateResult
- func (p *RevokedCertificateResult) GetTableInfo() *xdbschema.TableInfo
- func (v *RevokedCertificateResult) NextPage() *pb.NextPage
- func (v *RevokedCertificateResult) Pb() *pb.RevokedCertificatesResponse
- func (p *RevokedCertificateResult) SetResult(rows []*RevokedCertificate, hasNextPage bool, nextOffset uint32)
- func (p *RevokedCertificateResult) SetResultWithCursor(rows []*RevokedCertificate, hasNextPage bool, cursor func(lastRow *RevokedCertificate) string)
- type RevokedCertificateSlice
- type RevokedResult
- func (p *RevokedResult) GetTableInfo() *xdbschema.TableInfo
- func (v *RevokedResult) NextPage() *pb.NextPage
- func (p *RevokedResult) SetResult(rows []*Revoked, hasNextPage bool, nextOffset uint32)
- func (p *RevokedResult) SetResultWithCursor(rows []*Revoked, hasNextPage bool, cursor func(lastRow *Revoked) string)
- type RevokedSlice
- type RootCertificate
- type RootCertificateResult
- func (p *RootCertificateResult) GetTableInfo() *xdbschema.TableInfo
- func (v *RootCertificateResult) NextPage() *pb.NextPage
- func (v *RootCertificateResult) Pb() *pb.RootsResponse
- func (p *RootCertificateResult) SetResult(rows []*RootCertificate, hasNextPage bool, nextOffset uint32)
- func (p *RootCertificateResult) SetResultWithCursor(rows []*RootCertificate, hasNextPage bool, cursor func(lastRow *RootCertificate) string)
- type RootCertificateSlice
- type SchemaMigration
- type SchemaMigrationResult
- func (p *SchemaMigrationResult) GetTableInfo() *xdbschema.TableInfo
- func (p *SchemaMigrationResult) SetResult(rows []*SchemaMigration, hasNextPage bool, nextOffset uint32)
- func (p *SchemaMigrationResult) SetResultWithCursor(rows []*SchemaMigration, hasNextPage bool, cursor func(lastRow *SchemaMigration) string)
- type SchemaMigrationSlice
- type StatusCount
- type SummaryCounts
- type User
- type UserResult
- type UserSlice
Constants
Column length limits of the CA tables
const (
// MaxLenForLabel is the length of issuer and profile labels, and of the
// key identifiers and serial numbers
MaxLenForLabel = 64
// MaxLenForName is the length of subject and issuer names, and of the
// certificate label, locations and revocation text
MaxLenForName = 260
// MaxLenForSha256 is the length of a hex encoded SHA-256 thumbprint
MaxLenForSha256 = 64
)
AnyIssuerLabel is the profile issuer label that allows any issuer whose config lists the profile in AllowedProfiles
const AnyIssuerLabel = "*"
ProjectAliasPrefix is used for generated project aliases
const ProjectAliasPrefix = "prj_"
Variables
Dialect provides Dialect for trustycadb
var Dialect = xsql.Postgres
func ScopeOf
func ScopeOf(projectID xdb.ID) pb.Scope_Enum
ScopeOf returns the grant scope for the project ID: Org when the project ID is empty, Project otherwise.
type APIKey
APIKey represents one row from table 'trustyca.apikey'. Primary key: id Indexes:
apikey_key: UNIQUE [key]
apikey_pkey: PRIMARY UNIQUE [id]
idx_apikey_org_project: [org_id,project_id]
type APIKey struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,index,fk:trustyca.project.id" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null,index,fk:trustyca.project.id" json:",omitempty"`
// Key represents 'key' column of 'character varying'
Key string `db:"key,varchar,max:128,index" json:",omitempty"`
// Secret represents 'secret' column of 'character varying'
Secret string `db:"secret,varchar,max:128" json:",omitempty"`
// Label represents 'label' column of 'character varying'
Label string `db:"label,varchar,max:260" json:",omitempty"`
// Scopes represents 'scopes' column of 'ARRAY'
Scopes pq.StringArray `db:"scopes,_varchar" json:",omitempty"`
// Metadata represents 'metadata' column of 'jsonb'
Metadata xdb.Metadata `db:"metadata,jsonb,null" json:",omitempty"`
// Status represents 'status' column of 'integer'
Status pb.ItemStatus_Enum `db:"status,int4" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
// ExpiresAt represents 'expires_at' column of 'timestamp with time zone'
ExpiresAt xdb.Time `db:"expires_at,timestamptz,null" json:",omitempty"`
// UsedAt represents 'used_at' column of 'timestamp with time zone'
UsedAt xdb.Time `db:"used_at,timestamptz,null" json:",omitempty"`
// UsedCount represents 'used_count' column of 'integer'
UsedCount uint32 `db:"used_count,int4" json:",omitempty"`
}
func (*APIKey) IsExpired
func (m *APIKey) IsExpired(now time.Time) bool
IsExpired returns true if the key has an expiry in the past
func (*APIKey) Pb
func (m *APIKey) Pb() *pb.APIKey
Pb converts model to proto; the secret is never returned
func (*APIKey) ScanRow
func (m *APIKey) ScanRow(rows xdb.Row) error
ScanRow scans one row for apikey.
func (*APIKey) Validate
func (m *APIKey) Validate() error
Validate returns error if the model is not valid
type APIKeyResult
type APIKeyResult struct {
Rows APIKeySlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*APIKeyResult) GetTableInfo
func (p *APIKeyResult) GetTableInfo() *xdbschema.TableInfo
func (*APIKeyResult) NextPage
func (m *APIKeyResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*APIKeyResult) Pb
func (m *APIKeyResult) Pb() *pb.APIKeysResponse
Pb converts model to proto
func (*APIKeyResult) SetResult
func (p *APIKeyResult) SetResult(rows []*APIKey, hasNextPage bool, nextOffset uint32)
func (*APIKeyResult) SetResultWithCursor
func (p *APIKeyResult) SetResultWithCursor(rows []*APIKey, hasNextPage bool, cursor func(lastRow *APIKey) string)
type APIKeySlice
type APIKeySlice []*APIKey
type Certificate
Certificate represents one row from table 'trustyca.certificate'. Primary key: id Indexes:
certificate_pkey: PRIMARY UNIQUE [id]
idx_certificate_notafter: [not_after]
idx_certificate_org_id_desc: [id,org_id]
idx_certificate_org_ikid_id_desc: [id,org_id,ikid]
idx_certificate_org_project_id_desc: [org_id,project_id,id]
idx_certificate_org_project_notafter: [project_id,org_id,not_after]
idx_certificate_org_project_status_notafter: [status,org_id,project_id,not_after]
idx_certificate_skid: [skid]
unique_certificate_ikid_serial: UNIQUE [serial_number,ikid]
unique_certificate_sha256: UNIQUE [sha256]
type Certificate struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null,index" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null,index" json:",omitempty"`
// Skid represents 'skid' column of 'character varying'
Skid string `db:"skid,varchar,max:64,index" json:",omitempty"`
// Ikid represents 'ikid' column of 'character varying'
Ikid string `db:"ikid,varchar,max:64,index" json:",omitempty"`
// SerialNumber represents 'serial_number' column of 'character varying'
SerialNumber string `db:"serial_number,varchar,max:64,index" json:",omitempty"`
// NotBefore represents 'not_before' column of 'timestamp with time zone'
NotBefore xdb.Time `db:"not_before,timestamptz" json:",omitempty"`
// NotAfter represents 'not_after' column of 'timestamp with time zone'
NotAfter xdb.Time `db:"not_after,timestamptz,index" json:",omitempty"`
// Subject represents 'subject' column of 'character varying'
Subject string `db:"subject,varchar,max:260" json:",omitempty"`
// Issuer represents 'issuer' column of 'character varying'
Issuer string `db:"issuer,varchar,max:260" json:",omitempty"`
// Sha256 represents 'sha256' column of 'character varying'
Sha256 string `db:"sha256,varchar,max:64,index" json:",omitempty"`
// Profile represents 'profile' column of 'character varying'
Profile string `db:"profile,varchar,max:64" json:",omitempty"`
// Label represents 'label' column of 'character varying'
Label string `db:"label,varchar,max:260" json:",omitempty"`
// Locations represents 'locations' column of 'ARRAY'
Locations pq.StringArray `db:"locations,_varchar" json:",omitempty"`
// Metadata represents 'metadata' column of 'jsonb'
Metadata xdb.Metadata `db:"metadata,jsonb" json:",omitempty"`
// Pem represents 'pem' column of 'text'
Pem string `db:"pem,text" json:",omitempty"`
// IssuersPem represents 'issuers_pem' column of 'text'
IssuersPem string `db:"issuers_pem,text" json:",omitempty"`
// Status represents 'status' column of 'integer'
Status pb.CertificateStatus_Enum `db:"status,int4,index" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
}
func NewCertificate
func NewCertificate(crt *x509.Certificate, orgID, projectID xdb.ID, profile, pem, issuersPem, label string, locations []string, metadata xdb.Metadata) *Certificate
NewCertificate builds the issuance record of a signed certificate. The caller sets Label, Locations and Metadata; the status defaults to Active on registration.
func (*Certificate) IsExpired
func (m *Certificate) IsExpired(now time.Time) bool
IsExpired returns true if the validity period ended before now
func (*Certificate) Pb
func (m *Certificate) Pb() *pb.Certificate
Pb converts model to proto
func (*Certificate) ScanRow
func (m *Certificate) ScanRow(rows xdb.Row) error
ScanRow scans one row for certificate.
func (*Certificate) Validate
func (m *Certificate) Validate() error
Validate returns error if the model is not valid
type CertificateCounts
CertificateCounts are the counts of the certificates of a scope
type CertificateCounts struct {
// ByStatus counts the certificates by status; a status without
// certificates has no entry
ByStatus map[pb.CertificateStatus_Enum]uint64
// Expiring counts the Active certificates whose validity ends within
// each period of the request, in the order of the request; a period
// counts the certificates of the shorter ones too
Expiring []uint64
}
type CertificateProfile
CertificateProfile represents one row from table 'trustyca.certificate_profile'. Primary key: id Indexes:
certificate_profile_pkey: PRIMARY UNIQUE [id]
idx_certificate_profile_org_issuer: [org_id,issuer_label]
unique_certificate_profile_org_project_label: UNIQUE [org_id,project_id,label]
type CertificateProfile struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null,index" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null,index" json:",omitempty"`
// Label represents 'label' column of 'character varying'
Label string `db:"label,varchar,max:64,index" json:",omitempty"`
// IssuerLabel represents 'issuer_label' column of 'character varying'
IssuerLabel string `db:"issuer_label,varchar,max:64,index" json:",omitempty"`
// Status represents 'status' column of 'integer'
Status pb.ItemStatus_Enum `db:"status,int4" json:",omitempty"`
// Config represents 'config' column of 'jsonb'
Config JSON `db:"config,jsonb" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
// UpdatedAt represents 'updated_at' column of 'timestamp with time zone'
UpdatedAt xdb.Time `db:"updated_at,timestamptz" json:",omitempty"`
}
func NewCertificateProfile
func NewCertificateProfile(orgID, projectID xdb.ID, p *pb.CertProfile) (*CertificateProfile, error)
NewCertificateProfile builds a profile row of the scope from the profile definition: the label, issuer label and status come from the definition, the rest of it is stored as the config. A zero orgID is a platform profile.
func (*CertificateProfile) Definition
func (m *CertificateProfile) Definition() (*pb.CertProfile, error)
Definition returns the profile definition from the config with the labels and the status of the row, without its identity: the IDs are left empty. It is for the rows a cache shares between goroutines, since an xdb.ID formats itself into an unsynchronized cache.
func (*CertificateProfile) Pb
func (m *CertificateProfile) Pb() (*pb.CertProfile, error)
Pb converts model to proto: the profile definition from the config with the identity of the row
func (*CertificateProfile) ScanRow
func (m *CertificateProfile) ScanRow(rows xdb.Row) error
ScanRow scans one row for certificate_profile.
func (*CertificateProfile) SetConfig
func (m *CertificateProfile) SetConfig(p *pb.CertProfile) error
SetConfig stores the profile definition. The columns own the identity of the row, so ID, OrgID, ProjectID, Label, IssuerLabel, Status and the timestamps are not stored in the config.
func (*CertificateProfile) Validate
func (m *CertificateProfile) Validate() error
Validate returns error if the model is not valid
type CertificateProfileResult
type CertificateProfileResult struct {
Rows CertificateProfileSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*CertificateProfileResult) GetTableInfo
func (p *CertificateProfileResult) GetTableInfo() *xdbschema.TableInfo
func (*CertificateProfileResult) NextPage
func (v *CertificateProfileResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*CertificateProfileResult) Pb
func (v *CertificateProfileResult) Pb() (*pb.ProfilesResponse, error)
Pb converts model to proto
func (*CertificateProfileResult) SetResult
func (p *CertificateProfileResult) SetResult(rows []*CertificateProfile, hasNextPage bool, nextOffset uint32)
func (*CertificateProfileResult) SetResultWithCursor
func (p *CertificateProfileResult) SetResultWithCursor(rows []*CertificateProfile, hasNextPage bool, cursor func(lastRow *CertificateProfile) string)
type CertificateProfileSlice
type CertificateProfileSlice []*CertificateProfile
type CertificateResult
type CertificateResult struct {
Rows CertificateSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*CertificateResult) GetTableInfo
func (p *CertificateResult) GetTableInfo() *xdbschema.TableInfo
func (*CertificateResult) NextPage
func (v *CertificateResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*CertificateResult) Pb
func (v *CertificateResult) Pb() *pb.CertificatesResponse
Pb converts model to proto
func (*CertificateResult) SetResult
func (p *CertificateResult) SetResult(rows []*Certificate, hasNextPage bool, nextOffset uint32)
func (*CertificateResult) SetResultWithCursor
func (p *CertificateResult) SetResultWithCursor(rows []*Certificate, hasNextPage bool, cursor func(lastRow *Certificate) string)
type CertificateSlice
type CertificateSlice []*Certificate
type Crl
Crl represents one row from table 'trustyca.crl'. Primary key: id Indexes:
crl_pkey: PRIMARY UNIQUE [id]
idx_crl_next_update: [next_update]
unique_crl_ikid: UNIQUE [ikid]
type Crl struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null" json:",omitempty"`
// IssuerID represents 'issuer_id' column of 'bigint'
IssuerID xdb.ID `db:"issuer_id,int8,fk:trustyca.issuer.id" json:",omitempty"`
// Ikid represents 'ikid' column of 'character varying'
Ikid string `db:"ikid,varchar,max:64,index" json:",omitempty"`
// CrlNumber represents 'crl_number' column of 'bigint'
CrlNumber int64 `db:"crl_number,int8" json:",omitempty"`
// ThisUpdate represents 'this_update' column of 'timestamp with time zone'
ThisUpdate xdb.Time `db:"this_update,timestamptz" json:",omitempty"`
// NextUpdate represents 'next_update' column of 'timestamp with time zone'
NextUpdate xdb.Time `db:"next_update,timestamptz,index" json:",omitempty"`
// Issuer represents 'issuer' column of 'character varying'
Issuer string `db:"issuer,varchar,max:260" json:",omitempty"`
// Pem represents 'pem' column of 'text'
Pem string `db:"pem,text" json:",omitempty"`
// Locations represents 'locations' column of 'ARRAY'
Locations pq.StringArray `db:"locations,_varchar" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
}
func (*Crl) Pb
func (m *Crl) Pb() *pb.Crl
Pb converts model to proto
func (*Crl) ScanRow
func (m *Crl) ScanRow(rows xdb.Row) error
ScanRow scans one row for crl.
func (*Crl) Validate
func (m *Crl) Validate() error
Validate returns error if the model is not valid. PublishCrl copies OrgID, ProjectID and Issuer from the issuer row before it validates.
type CrlResult
type CrlResult struct {
Rows CrlSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*CrlResult) GetTableInfo
func (p *CrlResult) GetTableInfo() *xdbschema.TableInfo
func (*CrlResult) NextPage
func (v *CrlResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*CrlResult) Pb
func (v *CrlResult) Pb() *pb.CrlsResponse
Pb converts model to proto; pb.CrlsResponse carries no pagination, so the caller pages with NextPage
func (*CrlResult) SetResult
func (p *CrlResult) SetResult(rows []*Crl, hasNextPage bool, nextOffset uint32)
func (*CrlResult) SetResultWithCursor
func (p *CrlResult) SetResultWithCursor(rows []*Crl, hasNextPage bool, cursor func(lastRow *Crl) string)
type CrlSlice
type CrlSlice []*Crl
type CrlState
CrlState is the state of the CRL of an issuer that publishes CRLs, as the tenant summary classifies it: the issuer, its settings and the end of its validity, and the next update of its current CRL, zero when it has published none. The row is a projection of the issuer and crl tables without their PEMs, which a dashboard never reads.
type CrlState struct {
ID xdb.ID
Label string
Skid string
NotAfter xdb.Time
Config JSON
NextUpdate xdb.Time
}
func (*CrlState) GetConfig
func (m *CrlState) GetConfig() (*pb.IssuerConfig, error)
GetConfig returns the settings of the issuer
func (*CrlState) ScanRow
func (m *CrlState) ScanRow(rows xdb.Row) error
ScanRow scans the projection
type CrlStateResult
CrlStateResult is a page of CRL states
type CrlStateResult struct {
Rows []*CrlState
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*CrlStateResult) SetResult
func (p *CrlStateResult) SetResult(rows []*CrlState, hasNextPage bool, nextOffset uint32)
SetResult sets the page of an offset list
func (*CrlStateResult) SetResultWithCursor
func (p *CrlStateResult) SetResultWithCursor(rows []*CrlState, hasNextPage bool, cursor func(lastRow *CrlState) string)
SetResultWithCursor sets the page of a cursor list and the cursor of the next page from its last row
type Event
Event represents one row from table 'trustyca.event'. Primary key: id Indexes:
event_pkey: PRIMARY UNIQUE [id]
idx_event_email: [email]
idx_event_org_created_id_desc: [id,org_id,created_at]
idx_event_org_id: [org_id]
idx_event_org_project_created_id_desc: [org_id,id,project_id,created_at]
idx_event_org_ref_id: [org_id,ref_id]
idx_event_type: [type]
type Event struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null,index,fk:trustyca.org.id" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null,index,fk:trustyca.project.id" json:",omitempty"`
// Type represents 'type' column of 'integer'
Type pb.EventType_Enum `db:"type,int4,index" json:",omitempty"`
// Title represents 'title' column of 'character varying'
Title string `db:"title,varchar,max:256" json:",omitempty"`
// Description represents 'description' column of 'text'
Description xdb.NULLString `db:"description,text,null" json:",omitempty"`
// Metadata represents 'metadata' column of 'jsonb'
Metadata xdb.Metadata `db:"metadata,jsonb" json:",omitempty"`
// ReferenceID represents 'ref_id' column of 'bigint'
ReferenceID xdb.ID `db:"ref_id,int8,null,index" json:",omitempty"`
// Email represents 'email' column of 'character varying'
Email xdb.NULLString `db:"email,varchar,max:160,null,index" json:",omitempty"`
// Source represents 'source' column of 'character varying'
Source xdb.NULLString `db:"source,varchar,max:256,null" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz,index" json:",omitempty"`
}
func (*Event) Pb
func (v *Event) Pb() *pb.Event
Pb returns pb.Event
func (*Event) ScanRow
func (m *Event) ScanRow(rows xdb.Row) error
ScanRow scans one row for event.
func (*Event) Validate
func (m *Event) Validate() error
Validate the model
type EventResult
type EventResult struct {
Rows EventSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*EventResult) GetTableInfo
func (p *EventResult) GetTableInfo() *xdbschema.TableInfo
func (*EventResult) NextPage
func (v *EventResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*EventResult) Pb
func (v *EventResult) Pb() *pb.EventsResponse
Pb returns pb.Events
func (*EventResult) SetResult
func (p *EventResult) SetResult(rows []*Event, hasNextPage bool, nextOffset uint32)
func (*EventResult) SetResultWithCursor
func (p *EventResult) SetResultWithCursor(rows []*Event, hasNextPage bool, cursor func(lastRow *Event) string)
type EventSlice
type EventSlice []*Event
type Invite
Invite represents one row from table 'trustyca.invite'. Primary key: id Indexes:
idx_invite_email: [email]
idx_invite_org_project: [org_id,project_id]
invite_pkey: PRIMARY UNIQUE [id]
unique_invite_org_project_email: UNIQUE [email,org_id,project_id]
type Invite struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,index,fk:trustyca.project.id" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null,index,fk:trustyca.project.id" json:",omitempty"`
// InviterID represents 'inviter_id' column of 'bigint'
InviterID xdb.ID `db:"inviter_id,int8,fk:trustyca.user.id" json:",omitempty"`
// Email represents 'email' column of 'character varying'
Email string `db:"email,varchar,max:160,index" json:",omitempty"`
// Role represents 'role' column of 'integer'
Role pb.Role_Enum `db:"role,int4" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
// ExpiresAt represents 'expires_at' column of 'timestamp with time zone'
ExpiresAt xdb.Time `db:"expires_at,timestamptz,null" json:",omitempty"`
}
func (*Invite) IsExpired
func (m *Invite) IsExpired(now time.Time) bool
IsExpired returns true if the invite has an expiry in the past
func (*Invite) Pb
func (m *Invite) Pb() *pb.Invite
Pb converts model to proto
func (*Invite) ScanRow
func (m *Invite) ScanRow(rows xdb.Row) error
ScanRow scans one row for invite.
func (*Invite) Scope
func (m *Invite) Scope() pb.Scope_Enum
Scope returns the invite scope
func (*Invite) Validate
func (m *Invite) Validate() error
Validate returns error if the model is not valid
type InviteResult
type InviteResult struct {
Rows InviteSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*InviteResult) GetTableInfo
func (p *InviteResult) GetTableInfo() *xdbschema.TableInfo
func (*InviteResult) SetResult
func (p *InviteResult) SetResult(rows []*Invite, hasNextPage bool, nextOffset uint32)
func (*InviteResult) SetResultWithCursor
func (p *InviteResult) SetResultWithCursor(rows []*Invite, hasNextPage bool, cursor func(lastRow *Invite) string)
type InviteSlice
type InviteSlice []*Invite
func (InviteSlice) FilterByProject
func (m InviteSlice) FilterByProject(projectID uint64) InviteSlice
FilterByProject returns invites at the given scope: projectID 0 returns org-wide invites, otherwise the invites of the project.
func (InviteSlice) Pb
func (m InviteSlice) Pb() []*pb.Invite
Pb converts slice of model to proto
type Issuer
Issuer represents one row from table 'trustyca.issuer'. Primary key: id Indexes:
idx_issuer_notafter: [not_after]
idx_issuer_org_project_status: [org_id,project_id,status]
idx_issuer_parent: [parent_id]
issuer_pkey: PRIMARY UNIQUE [id]
unique_issuer_org_project_label: UNIQUE [org_id,project_id,label]
unique_issuer_skid: UNIQUE [skid]
type Issuer struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null,index" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null,index" json:",omitempty"`
// Label represents 'label' column of 'character varying'
Label string `db:"label,varchar,max:64,index" json:",omitempty"`
// Type represents 'type' column of 'integer'
Type pb.AuthorityType_Enum `db:"type,int4" json:",omitempty"`
// Status represents 'status' column of 'integer'
Status pb.IssuerStatus_Enum `db:"status,int4,index" json:",omitempty"`
// ParentID represents 'parent_id' column of 'bigint'
ParentID xdb.ID `db:"parent_id,int8,null,index" json:",omitempty"`
// Skid represents 'skid' column of 'character varying'
Skid string `db:"skid,varchar,max:64,index" json:",omitempty"`
// Ikid represents 'ikid' column of 'character varying'
Ikid string `db:"ikid,varchar,max:64" json:",omitempty"`
// SerialNumber represents 'serial_number' column of 'character varying'
SerialNumber string `db:"serial_number,varchar,max:64" json:",omitempty"`
// Subject represents 'subject' column of 'character varying'
Subject string `db:"subject,varchar,max:260" json:",omitempty"`
// Issuer represents 'issuer' column of 'character varying'
Issuer string `db:"issuer,varchar,max:260" json:",omitempty"`
// Sha256 represents 'sha256' column of 'character varying'
Sha256 string `db:"sha256,varchar,max:64" json:",omitempty"`
// NotBefore represents 'not_before' column of 'timestamp with time zone'
NotBefore xdb.Time `db:"not_before,timestamptz,null" json:",omitempty"`
// NotAfter represents 'not_after' column of 'timestamp with time zone'
NotAfter xdb.Time `db:"not_after,timestamptz,null,index" json:",omitempty"`
// Pem represents 'pem' column of 'text'
Pem string `db:"pem,text" json:",omitempty"`
// ChainPem represents 'chain_pem' column of 'text'
ChainPem string `db:"chain_pem,text" json:",omitempty"`
// RootPem represents 'root_pem' column of 'text'
RootPem string `db:"root_pem,text" json:",omitempty"`
// CsrPem represents 'csr_pem' column of 'text'
CsrPem string `db:"csr_pem,text" json:",omitempty"`
// KeyProvider represents 'key_provider' column of 'character varying'
KeyProvider string `db:"key_provider,varchar,max:64" json:",omitempty"`
// KeyID represents 'key_id' column of 'character varying'
KeyID string `db:"key_id,varchar,max:260" json:",omitempty"`
// KeyProtected represents 'key_protected' column of 'text'
KeyProtected xdb.NULLString `db:"key_protected,text,null" json:",omitempty"`
// Config represents 'config' column of 'jsonb'
Config JSON `db:"config,jsonb" json:",omitempty"`
// CrlNumber represents 'crl_number' column of 'bigint'
CrlNumber int64 `db:"crl_number,int8" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
// UpdatedAt represents 'updated_at' column of 'timestamp with time zone'
UpdatedAt xdb.Time `db:"updated_at,timestamptz" json:",omitempty"`
}
func (*Issuer) GetConfig
func (m *Issuer) GetConfig() (*pb.IssuerConfig, error)
GetConfig returns the runtime settings; an empty column returns an empty message, never nil
func (*Issuer) Pb
func (m *Issuer) Pb() (*pb.Issuer, error)
Pb converts model to proto; the key ID and the protected key material are never returned
func (*Issuer) ScanRow
func (m *Issuer) ScanRow(rows xdb.Row) error
ScanRow scans one row for issuer.
func (*Issuer) SetCertificate
func (m *Issuer) SetCertificate(crt *x509.Certificate, pem, chainPem, rootPem string)
SetCertificate sets the certificate columns from the parsed certificate and the PEM encodings of the certificate, its intermediates and its root. The status is not changed: a Pending issuer is activated by the DB.
func (*Issuer) SetConfig
func (m *Issuer) SetConfig(cfg *pb.IssuerConfig) error
SetConfig stores the runtime settings; nil clears them
func (*Issuer) Validate
func (m *Issuer) Validate() error
Validate returns error if the model is not valid. A Pending issuer needs its CSR; any other status needs the certificate.
type IssuerCounts
IssuerCounts are the issuers of a scope by lifecycle status; a status without issuers has no entry
type IssuerCounts map[pb.IssuerStatus_Enum]uint64
type IssuerResult
type IssuerResult struct {
Rows IssuerSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*IssuerResult) GetTableInfo
func (p *IssuerResult) GetTableInfo() *xdbschema.TableInfo
func (*IssuerResult) NextPage
func (v *IssuerResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*IssuerResult) Pb
func (v *IssuerResult) Pb() (*pb.IssuersResponse, error)
Pb converts model to proto
func (*IssuerResult) SetResult
func (p *IssuerResult) SetResult(rows []*Issuer, hasNextPage bool, nextOffset uint32)
func (*IssuerResult) SetResultWithCursor
func (p *IssuerResult) SetResultWithCursor(rows []*Issuer, hasNextPage bool, cursor func(lastRow *Issuer) string)
type IssuerSlice
type IssuerSlice []*Issuer
type JSON
JSON is the raw value of a jsonb column that holds a nested document, such as issuer.config (pb.IssuerConfig) and certificate_profile.config (pb.CertProfile), which xdb.Metadata (a flat string map) cannot represent. An empty value is written as the empty object, because the config columns are NOT NULL; a SQL NULL is read as an empty value.
type JSON json.RawMessage
func MarshalJSONValue
func MarshalJSONValue(v any) (JSON, error)
MarshalJSONValue encodes v as a JSON column value. pb messages encode with their generated MarshalJSON (protojson).
func (JSON) IsEmpty
func (j JSON) IsEmpty() bool
IsEmpty returns true when the value holds no document, or the empty object
func (JSON) MarshalJSON
func (j JSON) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler, so the model embeds the document rather than a base64 string
func (*JSON) Scan
func (j *JSON) Scan(value any) error
Scan implements the sql.Scanner interface
func (JSON) String
func (j JSON) String() string
String returns the JSON text
func (JSON) Unmarshal
func (j JSON) Unmarshal(v any) error
Unmarshal decodes the column value into v; an empty value leaves v unchanged
func (*JSON) UnmarshalJSON
func (j *JSON) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler; null is an empty value
func (JSON) Value
func (j JSON) Value() (driver.Value, error)
Value implements the driver.Valuer interface
type Login
Login represents one row from table 'trustyca.login'. Primary key: id Indexes:
idx_login_email: [email]
idx_login_last_at: [last_at]
login_pkey: PRIMARY UNIQUE [id]
unique_login_provider_email: UNIQUE [provider,email]
type Login struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// ExternalID represents 'external_id' column of 'character varying'
ExternalID string `db:"external_id,varchar,max:64" json:",omitempty"`
// Provider represents 'provider' column of 'integer'
Provider pb.IDP_Enum `db:"provider,int4,index" json:",omitempty"`
// Email represents 'email' column of 'character varying'
Email string `db:"email,varchar,max:160,index" json:",omitempty"`
// EmailVerified represents 'email_verified' column of 'boolean'
EmailVerified bool `db:"email_verified,bool" json:",omitempty"`
// Name represents 'name' column of 'character varying'
Name string `db:"name,varchar,max:64" json:",omitempty"`
// AccessToken represents 'access_token' column of 'text'
AccessToken string `db:"access_token,text" json:",omitempty"`
// RefreshToken represents 'refresh_token' column of 'text'
RefreshToken string `db:"refresh_token,text" json:",omitempty"`
// TokenExpiresAt represents 'token_expires_at' column of 'timestamp with time zone'
TokenExpiresAt xdb.Time `db:"token_expires_at,timestamptz,null" json:",omitempty"`
// Count represents 'count' column of 'integer'
Count uint32 `db:"count,int4" json:",omitempty"`
// LastAt represents 'last_at' column of 'timestamp with time zone'
LastAt xdb.Time `db:"last_at,timestamptz,null,index" json:",omitempty"`
}
func FindLoginByID
func FindLoginByID(list []*Login, uid string) *Login
FindLoginByID returns Login if found
func (*Login) Pb
func (u *Login) Pb() *pb.LoginInfo
Pb converts model to proto
func (*Login) ScanRow
func (m *Login) ScanRow(rows xdb.Row) error
ScanRow scans one row for login.
func (*Login) Validate
func (u *Login) Validate() error
Validate returns error if the model is not valid
type LoginResult
type LoginResult struct {
Rows LoginSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*LoginResult) GetTableInfo
func (p *LoginResult) GetTableInfo() *xdbschema.TableInfo
func (*LoginResult) SetResult
func (p *LoginResult) SetResult(rows []*Login, hasNextPage bool, nextOffset uint32)
func (*LoginResult) SetResultWithCursor
func (p *LoginResult) SetResultWithCursor(rows []*Login, hasNextPage bool, cursor func(lastRow *Login) string)
type LoginSlice
type LoginSlice []*Login
type Membership
Membership represents one row from table 'trustyca.membership'. Primary key: id Indexes:
idx_membership_org_project: [org_id,project_id]
idx_membership_user_id: [user_id]
membership_pkey: PRIMARY UNIQUE [id]
unique_membership_org_project_user: UNIQUE [user_id,org_id,project_id]
type Membership struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,index,fk:trustyca.project.id" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null,index,fk:trustyca.project.id" json:",omitempty"`
// UserID represents 'user_id' column of 'bigint'
UserID xdb.ID `db:"user_id,int8,index,fk:trustyca.user.id" json:",omitempty"`
// Role represents 'role' column of 'integer'
Role pb.Role_Enum `db:"role,int4" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
}
func (*Membership) Pb
func (m *Membership) Pb(org *Org, project *Project, user *User) *pb.Membership
Pb converts model to proto
func (*Membership) ScanRow
func (m *Membership) ScanRow(rows xdb.Row) error
ScanRow scans one row for membership.
func (*Membership) Scope
func (m *Membership) Scope() pb.Scope_Enum
Scope returns the grant scope
func (*Membership) Validate
func (m *Membership) Validate() error
Validate returns error if the model is not valid
type MembershipInfo
MembershipInfo represents one row from table 'trustyca.vw_membership_info'.
type MembershipInfo struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,null" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null" json:",omitempty"`
// OrgAlias represents 'org_alias' column of 'character varying'
OrgAlias string `db:"org_alias,varchar,max:32,null" json:",omitempty"`
// OrgName represents 'org_name' column of 'character varying'
OrgName string `db:"org_name,varchar,max:64,null" json:",omitempty"`
// OrgStatus represents 'org_status' column of 'integer'
OrgStatus xdb.Int32 `db:"org_status,int4,null" json:",omitempty"`
// ProjectAlias represents 'project_alias' column of 'character varying'
ProjectAlias string `db:"project_alias,varchar,null" json:",omitempty"`
// ProjectName represents 'project_name' column of 'character varying'
ProjectName string `db:"project_name,varchar,null" json:",omitempty"`
// UserID represents 'user_id' column of 'bigint'
UserID xdb.ID `db:"user_id,int8,null" json:",omitempty"`
// Email represents 'email' column of 'character varying'
Email string `db:"email,varchar,max:160,null" json:",omitempty"`
// Name represents 'name' column of 'character varying'
Name string `db:"name,varchar,max:64,null" json:",omitempty"`
// Role represents 'role' column of 'integer'
Role pb.Role_Enum `db:"role,int4,null" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz,null" json:",omitempty"`
}
func (*MembershipInfo) Pb
func (m *MembershipInfo) Pb() *pb.Membership
Pb converts model to proto
func (*MembershipInfo) ScanRow
func (m *MembershipInfo) ScanRow(rows xdb.Row) error
ScanRow scans one row for vw_membership_info.
func (*MembershipInfo) Scope
func (m *MembershipInfo) Scope() pb.Scope_Enum
Scope returns the grant scope
type MembershipInfoResult
type MembershipInfoResult struct {
Rows MembershipInfoSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*MembershipInfoResult) GetTableInfo
func (p *MembershipInfoResult) GetTableInfo() *xdbschema.TableInfo
func (*MembershipInfoResult) SetResult
func (p *MembershipInfoResult) SetResult(rows []*MembershipInfo, hasNextPage bool, nextOffset uint32)
func (*MembershipInfoResult) SetResultWithCursor
func (p *MembershipInfoResult) SetResultWithCursor(rows []*MembershipInfo, hasNextPage bool, cursor func(lastRow *MembershipInfo) string)
type MembershipInfoSlice
type MembershipInfoSlice []*MembershipInfo
func (MembershipInfoSlice) CountOrgRole
func (m MembershipInfoSlice) CountOrgRole(orgID uint64, role pb.Role_Enum) int
CountOrgRole returns the number of org-wide grants with the role
func (MembershipInfoSlice) FilterByOrg
func (m MembershipInfoSlice) FilterByOrg(orgID uint64) MembershipInfoSlice
FilterByOrg returns the grants of the org
func (MembershipInfoSlice) FindMemberByEmail
func (m MembershipInfoSlice) FindMemberByEmail(email string, projectID uint64) *MembershipInfo
FindMemberByEmail finds a grant by email at the given scope: projectID 0 matches the org-wide grant, otherwise the project grant.
func (MembershipInfoSlice) FindMemberByUserID
func (m MembershipInfoSlice) FindMemberByUserID(userID, projectID uint64) *MembershipInfo
FindMemberByUserID finds a grant by user ID at the given scope: projectID 0 matches the org-wide grant, otherwise the project grant.
func (MembershipInfoSlice) OrgIDs
func (m MembershipInfoSlice) OrgIDs() []xdb.ID
OrgIDs returns the distinct org IDs of the grants, in first-seen order
func (MembershipInfoSlice) Pb
func (m MembershipInfoSlice) Pb() []*pb.Membership
Pb converts slice of model to proto
type MembershipResult
type MembershipResult struct {
Rows MembershipSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*MembershipResult) GetTableInfo
func (p *MembershipResult) GetTableInfo() *xdbschema.TableInfo
func (*MembershipResult) SetResult
func (p *MembershipResult) SetResult(rows []*Membership, hasNextPage bool, nextOffset uint32)
func (*MembershipResult) SetResultWithCursor
func (p *MembershipResult) SetResultWithCursor(rows []*Membership, hasNextPage bool, cursor func(lastRow *Membership) string)
type MembershipSlice
type MembershipSlice []*Membership
type Org
Org represents one row from table 'trustyca.org'. Primary key: id Indexes:
idx_org_name_id: [id,name]
org_pkey: PRIMARY UNIQUE [id]
unique_org_alias: UNIQUE [alias]
type Org struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// Alias represents 'alias' column of 'character varying'
Alias string `db:"alias,varchar,max:32,index" json:",omitempty"`
// Name represents 'name' column of 'character varying'
Name string `db:"name,varchar,max:64,index" json:",omitempty"`
// Description represents 'description' column of 'text'
Description xdb.NULLString `db:"description,text,null" json:",omitempty"`
// Status represents 'status' column of 'integer'
Status pb.ItemStatus_Enum `db:"status,int4" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
}
func (*Org) Pb
func (m *Org) Pb() *pb.Org
Pb converts model to proto
func (*Org) ScanRow
func (m *Org) ScanRow(rows xdb.Row) error
ScanRow scans one row for org.
func (*Org) Validate
func (m *Org) Validate() error
Validate returns error if the model is not valid
type OrgResult
type OrgResult struct {
Rows OrgSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*OrgResult) GetTableInfo
func (p *OrgResult) GetTableInfo() *xdbschema.TableInfo
func (*OrgResult) NextPage
func (v *OrgResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*OrgResult) Pb
func (v *OrgResult) Pb() *pb.OrgsResponse
Pb converts model to proto
func (*OrgResult) SetResult
func (p *OrgResult) SetResult(rows []*Org, hasNextPage bool, nextOffset uint32)
func (*OrgResult) SetResultWithCursor
func (p *OrgResult) SetResultWithCursor(rows []*Org, hasNextPage bool, cursor func(lastRow *Org) string)
type OrgSlice
type OrgSlice []*Org
type Project
Project represents one row from table 'trustyca.project'. Primary key: id Indexes:
idx_project_name_id: [name,id]
idx_project_org_status: [org_id,status]
project_pkey: PRIMARY UNIQUE [id]
unique_project_org_alias: UNIQUE [alias,org_id]
unique_project_org_id: UNIQUE [org_id,id]
type Project struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,index,fk:trustyca.org.id" json:",omitempty"`
// Alias represents 'alias' column of 'character varying'
Alias string `db:"alias,varchar,max:64,index" json:",omitempty"`
// Name represents 'name' column of 'character varying'
Name string `db:"name,varchar,max:64,index" json:",omitempty"`
// Description represents 'description' column of 'text'
Description xdb.NULLString `db:"description,text,null" json:",omitempty"`
// Status represents 'status' column of 'integer'
Status pb.ItemStatus_Enum `db:"status,int4,index" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
// UpdatedAt represents 'updated_at' column of 'timestamp with time zone'
UpdatedAt xdb.Time `db:"updated_at,timestamptz" json:",omitempty"`
}
func (*Project) Pb
func (m *Project) Pb() *pb.Project
Pb converts model to proto
func (*Project) ScanRow
func (m *Project) ScanRow(rows xdb.Row) error
ScanRow scans one row for project.
func (*Project) Validate
func (m *Project) Validate() error
Validate returns error if the model is not valid
type ProjectResult
type ProjectResult struct {
Rows ProjectSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*ProjectResult) GetTableInfo
func (p *ProjectResult) GetTableInfo() *xdbschema.TableInfo
func (*ProjectResult) NextPage
func (v *ProjectResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*ProjectResult) Pb
func (v *ProjectResult) Pb() *pb.ProjectsResponse
Pb converts model to proto
func (*ProjectResult) SetResult
func (p *ProjectResult) SetResult(rows []*Project, hasNextPage bool, nextOffset uint32)
func (*ProjectResult) SetResultWithCursor
func (p *ProjectResult) SetResultWithCursor(rows []*Project, hasNextPage bool, cursor func(lastRow *Project) string)
type ProjectSlice
type ProjectSlice []*Project
func (ProjectSlice) Pb
func (m ProjectSlice) Pb() []*pb.Project
Pb converts slice of model to proto
type RecordsResult
RecordsResult reports how many rows a bulk operation created, updated or deleted.
type RecordsResult struct {
Created int64
Updated int64
Deleted int64
}
func (*RecordsResult) Pb
func (r *RecordsResult) Pb() *pb.RecordsResult
Pb converts the result to proto
type Revoked
Revoked represents one row from table 'trustyca.revoked'. Primary key: id Indexes:
idx_revoked_ikid_notafter: [ikid,not_after]
idx_revoked_ikid_serial: UNIQUE [ikid,serial_number]
idx_revoked_org_project_id_desc: [id,org_id,project_id]
revoked_pkey: PRIMARY UNIQUE [id]
unique_revoked_certificate: UNIQUE [certificate_id]
type Revoked struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null,index" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null,index" json:",omitempty"`
// CertificateID represents 'certificate_id' column of 'bigint'
CertificateID xdb.ID `db:"certificate_id,int8,index,fk:trustyca.certificate.id" json:",omitempty"`
// Ikid represents 'ikid' column of 'character varying'
Ikid string `db:"ikid,varchar,max:64,index" json:",omitempty"`
// SerialNumber represents 'serial_number' column of 'character varying'
SerialNumber string `db:"serial_number,varchar,max:64,index" json:",omitempty"`
// NotAfter represents 'not_after' column of 'timestamp with time zone'
NotAfter xdb.Time `db:"not_after,timestamptz,index" json:",omitempty"`
// RevokedAt represents 'revoked_at' column of 'timestamp with time zone'
RevokedAt xdb.Time `db:"revoked_at,timestamptz" json:",omitempty"`
// Reason represents 'reason' column of 'integer'
Reason pb.ReasonCode_Enum `db:"reason,int4" json:",omitempty"`
// ReasonText represents 'reason_text' column of 'character varying'
ReasonText string `db:"reason_text,varchar,max:260" json:",omitempty"`
}
func (*Revoked) ScanRow
func (m *Revoked) ScanRow(rows xdb.Row) error
ScanRow scans one row for revoked.
func (*Revoked) Validate
func (m *Revoked) Validate() error
Validate returns error if the model is not valid
type RevokedCertificate
RevokedCertificate represents one row from table 'trustyca.vw_revoked_certificate'.
type RevokedCertificate struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,null" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null" json:",omitempty"`
// ProjectID represents 'project_id' column of 'bigint'
ProjectID xdb.ID `db:"project_id,int8,null" json:",omitempty"`
// CertificateID represents 'certificate_id' column of 'bigint'
CertificateID xdb.ID `db:"certificate_id,int8,null" json:",omitempty"`
// Skid represents 'skid' column of 'character varying'
Skid string `db:"skid,varchar,max:64,null" json:",omitempty"`
// Ikid represents 'ikid' column of 'character varying'
Ikid string `db:"ikid,varchar,max:64,null" json:",omitempty"`
// SerialNumber represents 'serial_number' column of 'character varying'
SerialNumber string `db:"serial_number,varchar,max:64,null" json:",omitempty"`
// NotBefore represents 'not_before' column of 'timestamp with time zone'
NotBefore xdb.Time `db:"not_before,timestamptz,null" json:",omitempty"`
// NotAfter represents 'not_after' column of 'timestamp with time zone'
NotAfter xdb.Time `db:"not_after,timestamptz,null" json:",omitempty"`
// Subject represents 'subject' column of 'character varying'
Subject string `db:"subject,varchar,max:260,null" json:",omitempty"`
// Issuer represents 'issuer' column of 'character varying'
Issuer string `db:"issuer,varchar,max:260,null" json:",omitempty"`
// Sha256 represents 'sha256' column of 'character varying'
Sha256 string `db:"sha256,varchar,max:64,null" json:",omitempty"`
// Profile represents 'profile' column of 'character varying'
Profile string `db:"profile,varchar,max:64,null" json:",omitempty"`
// Label represents 'label' column of 'character varying'
Label string `db:"label,varchar,max:260,null" json:",omitempty"`
// Locations represents 'locations' column of 'ARRAY'
Locations pq.StringArray `db:"locations,_varchar,null" json:",omitempty"`
// Metadata represents 'metadata' column of 'jsonb'
Metadata xdb.Metadata `db:"metadata,jsonb,null" json:",omitempty"`
// Pem represents 'pem' column of 'text'
Pem string `db:"pem,text,null" json:",omitempty"`
// IssuersPem represents 'issuers_pem' column of 'text'
IssuersPem string `db:"issuers_pem,text,null" json:",omitempty"`
// Status represents 'status' column of 'integer'
Status pb.CertificateStatus_Enum `db:"status,int4,null" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz,null" json:",omitempty"`
// RevokedAt represents 'revoked_at' column of 'timestamp with time zone'
RevokedAt xdb.Time `db:"revoked_at,timestamptz,null" json:",omitempty"`
// Reason represents 'reason' column of 'integer'
Reason pb.ReasonCode_Enum `db:"reason,int4,null" json:",omitempty"`
// ReasonText represents 'reason_text' column of 'character varying'
ReasonText string `db:"reason_text,varchar,max:260,null" json:",omitempty"`
}
func NewRevokedCertificate
func NewRevokedCertificate(c *Certificate, r *Revoked) *RevokedCertificate
NewRevokedCertificate joins a certificate with its revocation, as the vw_revoked_certificate view does
func (*RevokedCertificate) Certificate
func (m *RevokedCertificate) Certificate() *Certificate
Certificate returns the certificate columns of the row
func (*RevokedCertificate) Pb
func (m *RevokedCertificate) Pb() *pb.RevokedCertificate
Pb converts model to proto
func (*RevokedCertificate) ScanRow
func (m *RevokedCertificate) ScanRow(rows xdb.Row) error
ScanRow scans one row for vw_revoked_certificate.
type RevokedCertificateResult
type RevokedCertificateResult struct {
Rows RevokedCertificateSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*RevokedCertificateResult) GetTableInfo
func (p *RevokedCertificateResult) GetTableInfo() *xdbschema.TableInfo
func (*RevokedCertificateResult) NextPage
func (v *RevokedCertificateResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*RevokedCertificateResult) Pb
func (v *RevokedCertificateResult) Pb() *pb.RevokedCertificatesResponse
Pb converts model to proto
func (*RevokedCertificateResult) SetResult
func (p *RevokedCertificateResult) SetResult(rows []*RevokedCertificate, hasNextPage bool, nextOffset uint32)
func (*RevokedCertificateResult) SetResultWithCursor
func (p *RevokedCertificateResult) SetResultWithCursor(rows []*RevokedCertificate, hasNextPage bool, cursor func(lastRow *RevokedCertificate) string)
type RevokedCertificateSlice
type RevokedCertificateSlice []*RevokedCertificate
type RevokedResult
type RevokedResult struct {
Rows RevokedSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*RevokedResult) GetTableInfo
func (p *RevokedResult) GetTableInfo() *xdbschema.TableInfo
func (*RevokedResult) NextPage
func (v *RevokedResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*RevokedResult) SetResult
func (p *RevokedResult) SetResult(rows []*Revoked, hasNextPage bool, nextOffset uint32)
func (*RevokedResult) SetResultWithCursor
func (p *RevokedResult) SetResultWithCursor(rows []*Revoked, hasNextPage bool, cursor func(lastRow *Revoked) string)
type RevokedSlice
type RevokedSlice []*Revoked
type RootCertificate
RootCertificate represents one row from table 'trustyca.root_certificate'. Primary key: id Indexes:
idx_root_certificate_notafter: [not_after]
idx_root_certificate_org: [org_id]
idx_root_certificate_skid: [skid]
root_certificate_pkey: PRIMARY UNIQUE [id]
unique_root_certificate_sha256: UNIQUE [sha256]
type RootCertificate struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// OrgID represents 'org_id' column of 'bigint'
OrgID xdb.ID `db:"org_id,int8,null,index" json:",omitempty"`
// Skid represents 'skid' column of 'character varying'
Skid string `db:"skid,varchar,max:64,index" json:",omitempty"`
// NotBefore represents 'not_before' column of 'timestamp with time zone'
NotBefore xdb.Time `db:"not_before,timestamptz" json:",omitempty"`
// NotAfter represents 'not_after' column of 'timestamp with time zone'
NotAfter xdb.Time `db:"not_after,timestamptz,index" json:",omitempty"`
// Subject represents 'subject' column of 'character varying'
Subject string `db:"subject,varchar,max:260" json:",omitempty"`
// Sha256 represents 'sha256' column of 'character varying'
Sha256 string `db:"sha256,varchar,max:64,index" json:",omitempty"`
// Trust represents 'trust' column of 'integer'
Trust pb.Trust_Enum `db:"trust,int4" json:",omitempty"`
// Pem represents 'pem' column of 'text'
Pem string `db:"pem,text" json:",omitempty"`
// CreatedAt represents 'created_at' column of 'timestamp with time zone'
CreatedAt xdb.Time `db:"created_at,timestamptz" json:",omitempty"`
}
func NewRootCertificate
func NewRootCertificate(crt *x509.Certificate, orgID xdb.ID, trust pb.Trust_Enum, pem string) *RootCertificate
NewRootCertificate builds a trust anchor row from the parsed certificate; a zero orgID registers a platform root
func (*RootCertificate) Pb
func (m *RootCertificate) Pb() *pb.RootCertificate
Pb converts model to proto
func (*RootCertificate) ScanRow
func (m *RootCertificate) ScanRow(rows xdb.Row) error
ScanRow scans one row for root_certificate.
func (*RootCertificate) Validate
func (m *RootCertificate) Validate() error
Validate returns error if the model is not valid
type RootCertificateResult
type RootCertificateResult struct {
Rows RootCertificateSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*RootCertificateResult) GetTableInfo
func (p *RootCertificateResult) GetTableInfo() *xdbschema.TableInfo
func (*RootCertificateResult) NextPage
func (v *RootCertificateResult) NextPage() *pb.NextPage
NextPage returns the next page of the result
func (*RootCertificateResult) Pb
func (v *RootCertificateResult) Pb() *pb.RootsResponse
Pb converts model to proto
func (*RootCertificateResult) SetResult
func (p *RootCertificateResult) SetResult(rows []*RootCertificate, hasNextPage bool, nextOffset uint32)
func (*RootCertificateResult) SetResultWithCursor
func (p *RootCertificateResult) SetResultWithCursor(rows []*RootCertificate, hasNextPage bool, cursor func(lastRow *RootCertificate) string)
type RootCertificateSlice
type RootCertificateSlice []*RootCertificate
type SchemaMigration
SchemaMigration represents one row from table 'trustyca.schema_migrations'. Primary key: version Indexes:
schema_migrations_pkey: PRIMARY UNIQUE [version]
type SchemaMigration struct {
// Version represents 'version' column of 'bigint'
Version int64 `db:"version,int8,index,primary" json:",omitempty"`
// Dirty represents 'dirty' column of 'boolean'
Dirty bool `db:"dirty,bool" json:",omitempty"`
}
func (*SchemaMigration) ScanRow
func (m *SchemaMigration) ScanRow(rows xdb.Row) error
ScanRow scans one row for schema_migrations.
type SchemaMigrationResult
type SchemaMigrationResult struct {
Rows SchemaMigrationSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*SchemaMigrationResult) GetTableInfo
func (p *SchemaMigrationResult) GetTableInfo() *xdbschema.TableInfo
func (*SchemaMigrationResult) SetResult
func (p *SchemaMigrationResult) SetResult(rows []*SchemaMigration, hasNextPage bool, nextOffset uint32)
func (*SchemaMigrationResult) SetResultWithCursor
func (p *SchemaMigrationResult) SetResultWithCursor(rows []*SchemaMigration, hasNextPage bool, cursor func(lastRow *SchemaMigration) string)
type SchemaMigrationSlice
type SchemaMigrationSlice []*SchemaMigration
type StatusCount
StatusCount is a row of a count by status: the status column of a CA table and the number of its rows in the scope of the query
type StatusCount struct {
Status int32
Count int64
}
func (*StatusCount) ScanRow
func (m *StatusCount) ScanRow(rows xdb.Row) error
ScanRow scans the status and the count
type SummaryCounts
SummaryCounts are the counts of the tenant summary, read at one snapshot
type SummaryCounts struct {
// Issuers counts the issuers of the scope by lifecycle status
Issuers IssuerCounts
// Certificates counts the certificates of the scope by status and by
// expiry period
Certificates *CertificateCounts
// CrlStates are the issuers of the scope that publish CRLs with the
// state of their CRL, every page of them
CrlStates []*CrlState
}
type User
User represents one row from table 'trustyca.user'. Primary key: id Indexes:
unique_user_email: UNIQUE [email]
user_pkey: PRIMARY UNIQUE [id]
type User struct {
// ID represents 'id' column of 'bigint'
ID xdb.ID `db:"id,int8,index,primary" json:",omitempty"`
// Email represents 'email' column of 'character varying'
Email string `db:"email,varchar,max:160,index" json:",omitempty"`
// EmailVerified represents 'email_verified' column of 'boolean'
EmailVerified bool `db:"email_verified,bool" json:",omitempty"`
// Name represents 'name' column of 'character varying'
Name string `db:"name,varchar,max:64" json:",omitempty"`
}
func NewUser
func NewUser(u *pb.UserInfo) (*User, error)
NewUser returns User from Dto
func (*User) Pb
func (u *User) Pb() *pb.UserInfo
Pb converts model to proto
func (*User) ScanRow
func (m *User) ScanRow(rows xdb.Row) error
ScanRow scans one row for user.
func (*User) Validate
func (u *User) Validate() error
Validate returns error if the model is not valid
type UserResult
type UserResult struct {
Rows UserSlice
NextOffset uint32
HasNextPage bool
Cursor string
}
func (*UserResult) GetTableInfo
func (p *UserResult) GetTableInfo() *xdbschema.TableInfo
func (*UserResult) SetResult
func (p *UserResult) SetResult(rows []*User, hasNextPage bool, nextOffset uint32)
func (*UserResult) SetResultWithCursor
func (p *UserResult) SetResultWithCursor(rows []*User, hasNextPage bool, cursor func(lastRow *User) string)
type UserSlice
type UserSlice []*User
Generated by gomarkdoc