sshpiper/sshpiperd/upstream/database/model.go
11notes 63bbdb3441 database backend optimization (#40)
* add support for longer than 2048bit keys

* added support for PKCS#1, PKCS#8, DSA, ECDSA keys
2019-10-07 17:45:57 -07:00

88 lines
1.3 KiB
Go

package database
import (
"github.com/jinzhu/gorm"
)
type authMapType int
const (
authMapTypeNone = iota
authMapTypePassword
authMapTypePrivateKey
)
const fallbackUserEntry = "FALLBACK_USER"
type keydata struct {
gorm.Model
Name string `gorm:"type:varchar(45)"`
Data string `gorm:"type:text"`
Type string `gorm:"type:varchar(45)"`
}
type privateKey struct {
Key keydata
KeyID int
UpstreamID int
}
type hostKey struct {
Key keydata
KeyID int
ServerID int
}
type server struct {
gorm.Model
Name string `gorm:"type:varchar(45)"`
Address string `gorm:"type:varchar(100)"`
HostKeyID int
HostKey hostKey
IgnoreHostKey bool
}
type upstream struct {
gorm.Model
Name string `gorm:"type:varchar(45)"`
ServerID int
Server server
Username string `gorm:"type:varchar(45)"`
Password string `gorm:"type:varchar(60)"`
PrivateKeyID int
PrivateKey privateKey
AuthMapType authMapType
}
type authorizedKey struct {
Key keydata
KeyID int
DownstreamID int
}
type downstream struct {
gorm.Model
Name string `gorm:"type:varchar(45)"`
Username string `gorm:"type:varchar(45);unique_index"`
UpstreamID int
Upstream upstream
AuthorizedKeys []authorizedKey
}
type config struct {
gorm.Model
Entry string `gorm:"type:varchar(45);unique_index"`
Value string `gorm:"type:varchar(100)"`
}