forked from TrueCloudLab/certificates
Extract cert storer methods from AuthDB
To be able to extend the AuthDB with methods that also extend the provisioner we need to either create a new method or to split the interface. This change splits the interface so we can have a cleaner implementation.
This commit is contained in:
parent
14524d7916
commit
20b2c6a201
2 changed files with 8 additions and 3 deletions
9
db/db.go
9
db/db.go
|
@ -50,14 +50,19 @@ type AuthDB interface {
|
||||||
Revoke(rci *RevokedCertificateInfo) error
|
Revoke(rci *RevokedCertificateInfo) error
|
||||||
RevokeSSH(rci *RevokedCertificateInfo) error
|
RevokeSSH(rci *RevokedCertificateInfo) error
|
||||||
GetCertificate(serialNumber string) (*x509.Certificate, error)
|
GetCertificate(serialNumber string) (*x509.Certificate, error)
|
||||||
StoreCertificate(crt *x509.Certificate) error
|
|
||||||
UseToken(id, tok string) (bool, error)
|
UseToken(id, tok string) (bool, error)
|
||||||
IsSSHHost(name string) (bool, error)
|
IsSSHHost(name string) (bool, error)
|
||||||
StoreSSHCertificate(crt *ssh.Certificate) error
|
|
||||||
GetSSHHostPrincipals() ([]string, error)
|
GetSSHHostPrincipals() ([]string, error)
|
||||||
Shutdown() error
|
Shutdown() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CertificateStorer is an extension of AuthDB that allows to store
|
||||||
|
// certificates.
|
||||||
|
type CertificateStorer interface {
|
||||||
|
StoreCertificate(crt *x509.Certificate) error
|
||||||
|
StoreSSHCertificate(crt *ssh.Certificate) error
|
||||||
|
}
|
||||||
|
|
||||||
// DB is a wrapper over the nosql.DB interface.
|
// DB is a wrapper over the nosql.DB interface.
|
||||||
type DB struct {
|
type DB struct {
|
||||||
nosql.DB
|
nosql.DB
|
||||||
|
|
|
@ -20,7 +20,7 @@ type SimpleDB struct {
|
||||||
usedTokens *sync.Map
|
usedTokens *sync.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSimpleDB(c *Config) (AuthDB, error) {
|
func newSimpleDB(c *Config) (*SimpleDB, error) {
|
||||||
db := &SimpleDB{}
|
db := &SimpleDB{}
|
||||||
db.usedTokens = new(sync.Map)
|
db.usedTokens = new(sync.Map)
|
||||||
return db, nil
|
return db, nil
|
||||||
|
|
Loading…
Reference in a new issue