Documentation ¶
Index ¶
- Variables
- func Connect(dsn string) (*gorm.DB, error)
- func CredentialAddOrUpdate(db *gorm.DB, fqdn, cert, key string) error
- func CredentialDelete(db *gorm.DB, fqdn string) error
- func CredentialsContains(credentials []Credential, fqdn string) bool
- func Open(dsn string) (*gorm.DB, error)
- func RecordAdd(db *gorm.DB, record *Record) error
- func RecordDelete(db *gorm.DB, recordID string) (bool, error)
- func RecordUpdate(db *gorm.DB, updates *Record) error
- func ScriptRecords(db *gorm.DB) (map[string]string, error)
- func ScriptValidate(script, origin string) error
- func SuffixList() ([]string, error)
- func TestSetup() (*gorm.DB, error)
- func UserAdd(db *gorm.DB, email string, password string, refer string) error
- func UserCreatePasswordResetToken(db *gorm.DB, email string) (string, error)
- func UserDelete(db *gorm.DB, email string) error
- func UserGroupAdd(db *gorm.DB, uuid string, group string) error
- func UserGroupDelete(db *gorm.DB, uuid string, group string) error
- func UserResetPassword(db *gorm.DB, email string, password string) error
- func UserValidatePasswordResetToken(db *gorm.DB, email, token string) error
- func ZoneAdd(db *gorm.DB, zone string, user string) error
- func ZoneDelete(db *gorm.DB, zone string) (bool, error)
- func ZoneIncrementSerial(db *gorm.DB, uuid string) error
- func ZoneRotateDNSSECKey(db *gorm.DB, uuid string) error
- func ZoneUserAdd(db *gorm.DB, zoneID string, userEmail string) error
- func ZoneUserAuthorized(db *gorm.DB, zoneUuid string, userUuid string) error
- func ZoneUserDelete(db *gorm.DB, zoneUuid string, userEmail string) error
- type Credential
- type DNSSECKey
- type Record
- type User
- type Zone
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserExistingZoneMember = errors.New("user is already a member of this zone") ErrUserNotFound = errors.New("user not found") ErrZoneNotFound = errors.New("zone not found") ErrLastZoneUser = errors.New("unable to remove last user from zone") )
var ( GroupEnabled = "core.ENABLED" // User is permitted to make API requests GroupAdmin = "core.ADMIN" // User is permitted to modify all resources ErrInvalidOrExpiredPasswordResetToken = errors.New("password reset token is invalid or expired") ErrUserOwnsZones = errors.New("user has zones without other users, delete or add another user to these zones before deleting this user account") )
var (
ErrValidationTimeExceeded = errors.New("script validation time exceeded: " + validationTimeInterval.String())
)
Functions ¶
func CredentialAddOrUpdate ¶ added in v0.0.69
CredentialAddOrUpdate adds a new credential to the database
func CredentialDelete ¶ added in v0.0.73
CredentialDelete deletes a credential from the database
func CredentialsContains ¶ added in v0.0.73
func CredentialsContains(credentials []Credential, fqdn string) bool
CredentialsContains checks if a FQDN is in the given list of credentials
func RecordDelete ¶
RecordDelete deletes a DNS record from a zone
func RecordUpdate ¶
RecordUpdate updates a DNS record
func ScriptRecords ¶ added in v0.0.51
ScriptRecords returns a map of DNS labels to script strings
func ScriptValidate ¶ added in v0.0.48
ScriptValidate attempts to compile a script
func TestSetup ¶
TestSetup sets up the test environment by opening a database connection, dropping all tables, and inserting test data
func UserCreatePasswordResetToken ¶ added in v0.0.41
UserCreatePasswordResetToken creates a User's password reset token
func UserGroupAdd ¶
UserGroupAdd adds a role to a Group
func UserGroupDelete ¶
UserGroupDelete removes a role from a Group
func UserResetPassword ¶
UserResetPassword resets a User's password
func UserValidatePasswordResetToken ¶ added in v0.0.41
UserValidatePasswordResetToken checks that a provided password reset token is valid
func ZoneDelete ¶
ZoneDelete deletes a DNS zone
func ZoneIncrementSerial ¶ added in v0.0.60
ZoneIncrementSerial increments a zone's SOA serial by 1
func ZoneRotateDNSSECKey ¶
ZoneRotateDNSSECKey rotates a zone's DNSSEC key
func ZoneUserAdd ¶
ZoneUserAdd adds a user to a zone
func ZoneUserAuthorized ¶
ZoneUserAuthorized checks if a user is authorized for a zone
Types ¶
type Credential ¶ added in v0.0.69
type Credential struct { FQDN string `gorm:"primary_key" json:"id"` Cert string `json:"cert"` Key string `json:"key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
func CredentialList ¶ added in v0.0.69
func CredentialList(db *gorm.DB) ([]Credential, error)
CredentialList gets a list of credentials
type DNSSECKey ¶
type DNSSECKey struct { Base string // Base key filename prefix Key string // DNSKEY Private string // Private key DSKeyTag int // DS key tag DSAlgo int // DS algorithm DSDigestType int // DS digest type DSDigest string // DS digest DSRecordString string // Full DS record in zone file format }
DNSSECKey stores a DNSSEC signing key
type Record ¶
type Record struct { ID string `gorm:"primaryKey,type:uuid;default:uuid_generate_v4()" json:"id"` Type string `json:"type" validate:"required,dns-rrtype"` Label string `json:"label" validate:"required"` Value string `json:"value"` TTL uint32 `json:"ttl" validate:"gte=300,lte=2147483647"` Proxy bool `json:"proxy"` ZoneID string `json:"zone"` Zone Zone `json:"-" validate:"-"` // Zone is populated by the database so will be zero value at record creation time CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
Record stores a DNS record
func RecordList ¶
RecordList returns a list of DNS records for a zone
type User ¶
type User struct { ID string `gorm:"primaryKey,type:uuid;default:uuid_generate_v4()" json:"id"` Email string `gorm:"uniqueIndex" json:"email" validate:"required,email,min=6,max=32"` Password string `gorm:"-" json:"password" validate:"required,min=8,max=256"` Refer string `json:"refer"` // Where did you hear about Packetframe? Groups pq.StringArray `gorm:"type:text[]" json:"groups"` PasswordHash []byte `json:"-"` APIKey string `json:"-"` // Rotated manually by user if needed Token string `json:"-"` // Rotated every n minutes (TODO: autorotate this) PasswordResetToken string `json:"-"` // <token>:<unix timestamp when it was created> CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
func UserFindByAuth ¶
UserFindByAuth finds a user by API key and returns nil if no user exists
func UserFindByEmail ¶
UserFindByEmail finds a user by email and returns nil if no user exists
func UserFindById ¶ added in v0.0.33
UserFindById finds a user by ID and returns nil if no user exists
type Zone ¶
type Zone struct { ID string `gorm:"primaryKey,type:uuid;default:uuid_generate_v4()" json:"id"` Zone string `gorm:"uniqueIndex" json:"zone" validate:"required,fqdn"` Serial uint64 `json:"-"` DNSSEC DNSSECKey `gorm:"embedded" json:"-"` Users pq.StringArray `gorm:"type:text[]" json:"users"` UserEmails pq.StringArray `gorm:"type:text[]" json:"user_emails"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
Zone stores a DNS zone
func ZoneFindByID ¶
ZoneFindByID gets a zone by UUID