feat: add comprehensive database models and type definitions
- Define Certificate model with full X.509 attributes - Add CertificateAuthority model for CA management - Implement CertificateRequest model for CSR handling - Add CertificateRevocationList model for CRL support - Define User and Organization models for access control - Include comprehensive certificate type definitions (web, client, email, etc.) - Add status enums for certificates, requests, and organizations - Configure GORM relationships and constraints
This commit is contained in:
37
models/crl.go
Normal file
37
models/crl.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// CertificateRevocationList represents a Certificate Revocation List (CRL)
|
||||
type CertificateRevocationList struct {
|
||||
ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
|
||||
SerialNumber string `json:"serial_number" gorm:"not null;unique"`
|
||||
CertificateAuthorityID uuid.UUID `json:"certificate_authority_id" gorm:"type:uuid;not null"`
|
||||
Version int `json:"version" gorm:"not null;default:2"`
|
||||
ThisUpdate time.Time `json:"this_update" gorm:"not null"`
|
||||
NextUpdate time.Time `json:"next_update" gorm:"not null"`
|
||||
FilePath string `json:"file_path" gorm:"not null"` // Path to CRL file
|
||||
RevokedCertificates string `json:"revoked_certificates"` // JSON array of revoked certificate serial numbers with reasons
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||
|
||||
// Relationships
|
||||
CertificateAuthority *CertificateAuthority `json:"certificate_authority" gorm:"foreignKey:CertificateAuthorityID"`
|
||||
}
|
||||
|
||||
// TableName returns the table name for CertificateRevocationList
|
||||
func (crl *CertificateRevocationList) TableName() string {
|
||||
return "certificate_revocation_lists"
|
||||
}
|
||||
|
||||
// BeforeCreate generates a new UUID before creating the record
|
||||
func (crl *CertificateRevocationList) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
crl.ID = uuid.New()
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user