First commit
This commit is contained in:
43
internal/models/ca.go
Normal file
43
internal/models/ca.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type CA struct {
|
||||
ID string `json:"id" bson:"_id"`
|
||||
Name string `json:"name" bson:"name"`
|
||||
CommonName string `json:"common_name" bson:"common_name"`
|
||||
Organization string `json:"organization" bson:"organization"`
|
||||
Country string `json:"country" bson:"country"`
|
||||
Province string `json:"province" bson:"province"`
|
||||
Locality string `json:"locality" bson:"locality"`
|
||||
Email string `json:"email" bson:"email"`
|
||||
PrivateKey string `json:"private_key,omitempty" bson:"private_key"`
|
||||
Certificate string `json:"certificate" bson:"certificate"`
|
||||
SerialNumber string `json:"serial_number" bson:"serial_number"`
|
||||
ValidFrom time.Time `json:"valid_from" bson:"valid_from"`
|
||||
ValidTo time.Time `json:"valid_to" bson:"valid_to"`
|
||||
IsRoot bool `json:"is_root" bson:"is_root"`
|
||||
CreatedAt time.Time `json:"created_at" bson:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
|
||||
}
|
||||
|
||||
type CreateCARequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
CommonName string `json:"common_name" binding:"required"`
|
||||
Organization string `json:"organization" binding:"required"`
|
||||
Country string `json:"country" binding:"required"`
|
||||
Province string `json:"province"`
|
||||
Locality string `json:"locality"`
|
||||
Email string `json:"email" binding:"omitempty,email"` // omitempty permet les chaînes vides
|
||||
KeySize int `json:"key_size" binding:"required,min=2048"`
|
||||
ValidYears int `json:"valid_years" binding:"required,min=1,max=20"`
|
||||
IsRoot bool `json:"is_root"`
|
||||
}
|
||||
|
||||
type UpdateCARequest struct {
|
||||
Name string `json:"name"`
|
||||
Organization string `json:"organization"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
38
internal/models/certificate.go
Normal file
38
internal/models/certificate.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Certificate struct {
|
||||
ID string `json:"id" bson:"_id"`
|
||||
CommonName string `json:"common_name" bson:"common_name"`
|
||||
Subject string `json:"subject" bson:"subject"`
|
||||
DNSNames []string `json:"dns_names" bson:"dns_names"`
|
||||
IPAddresses []string `json:"ip_addresses" bson:"ip_addresses"`
|
||||
Type string `json:"type" bson:"type"` // "server" or "client"
|
||||
PrivateKey string `json:"private_key,omitempty" bson:"private_key"`
|
||||
Certificate string `json:"certificate" bson:"certificate"`
|
||||
SerialNumber string `json:"serial_number" bson:"serial_number"`
|
||||
ValidFrom time.Time `json:"valid_from" bson:"valid_from"`
|
||||
ValidTo time.Time `json:"valid_to" bson:"valid_to"`
|
||||
IssuerCAID string `json:"issuer_ca_id" bson:"issuer_ca_id"`
|
||||
Revoked bool `json:"revoked" bson:"revoked"`
|
||||
RevokedAt time.Time `json:"revoked_at,omitempty" bson:"revoked_at"`
|
||||
RevokedReason string `json:"revoked_reason,omitempty" bson:"revoked_reason"`
|
||||
CreatedAt time.Time `json:"created_at" bson:"created_at"`
|
||||
}
|
||||
|
||||
type CreateCertificateRequest struct {
|
||||
CommonName string `json:"common_name" binding:"required"`
|
||||
DNSNames []string `json:"dns_names"`
|
||||
IPAddresses []string `json:"ip_addresses"`
|
||||
Type string `json:"type" binding:"required,oneof=server client"`
|
||||
KeySize int `json:"key_size" binding:"required,min=2048"`
|
||||
ValidDays int `json:"valid_days" binding:"required,min=1,max=365"`
|
||||
IssuerCAID string `json:"issuer_ca_id" binding:"required"`
|
||||
}
|
||||
|
||||
type RevokeCertificateRequest struct {
|
||||
Reason string `json:"reason" binding:"required"`
|
||||
}
|
||||
43
internal/models/subca.go
Normal file
43
internal/models/subca.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SubCA struct {
|
||||
ID string `json:"id" bson:"_id"`
|
||||
Name string `json:"name" bson:"name"`
|
||||
CommonName string `json:"common_name" bson:"common_name"`
|
||||
Organization string `json:"organization" bson:"organization"`
|
||||
Country string `json:"country" bson:"country"`
|
||||
Province string `json:"province" bson:"province"`
|
||||
Locality string `json:"locality" bson:"locality"`
|
||||
Email string `json:"email" bson:"email"`
|
||||
PrivateKey string `json:"private_key,omitempty" bson:"private_key"`
|
||||
Certificate string `json:"certificate" bson:"certificate"`
|
||||
SerialNumber string `json:"serial_number" bson:"serial_number"`
|
||||
ValidFrom time.Time `json:"valid_from" bson:"valid_from"`
|
||||
ValidTo time.Time `json:"valid_to" bson:"valid_to"`
|
||||
ParentCAID string `json:"parent_ca_id" bson:"parent_ca_id"`
|
||||
CreatedAt time.Time `json:"created_at" bson:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
|
||||
}
|
||||
|
||||
type CreateSubCARequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
CommonName string `json:"common_name" binding:"required"`
|
||||
Organization string `json:"organization" binding:"required"`
|
||||
Country string `json:"country" binding:"required"`
|
||||
Province string `json:"province"`
|
||||
Locality string `json:"locality"`
|
||||
Email string `json:"email" binding:"omitempty,email"` // omitempty permet les chaînes vides
|
||||
KeySize int `json:"key_size" binding:"required,min=2048"`
|
||||
ValidYears int `json:"valid_years" binding:"required,min=1,max=10"`
|
||||
ParentCAID string `json:"parent_ca_id" binding:"required"`
|
||||
}
|
||||
|
||||
type UpdateSubCARequest struct {
|
||||
Name string `json:"name"`
|
||||
Organization string `json:"organization"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
Reference in New Issue
Block a user