aboutsummaryrefslogtreecommitdiff
path: root/server/store/store.go
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2017-01-20 00:52:56 +0000
committerNiall Sheridan <nsheridan@gmail.com>2017-01-22 22:25:35 +0000
commit51cc4c07b2a2b6345b1496baac865f5faf955e7d (patch)
treeedd51d045954eb802c470be4481a1d130d5f988c /server/store/store.go
parentfb4a1232be3b2d00483a7399e7131c211d8cd551 (diff)
Switch from database/sql to sqlx
Diffstat (limited to 'server/store/store.go')
-rw-r--r--server/store/store.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/server/store/store.go b/server/store/store.go
index 8af77e3..249489a 100644
--- a/server/store/store.go
+++ b/server/store/store.go
@@ -7,6 +7,7 @@ import (
"github.com/nsheridan/cashier/lib"
"github.com/nsheridan/cashier/server/config"
+ "github.com/nsheridan/cashier/server/store/types"
)
// New returns a new configured database.
@@ -36,12 +37,12 @@ type CertStorer interface {
// A CertRecord is a representation of a ssh certificate used by a CertStorer.
type CertRecord struct {
- KeyID string `json:"key_id"`
- Principals []string `json:"principals"`
- CreatedAt time.Time `json:"created_at"`
- Expires time.Time `json:"expires"`
- Revoked bool `json:"revoked"`
- Raw string `json:"-"`
+ KeyID string `json:"key_id" db:"key_id"`
+ Principals types.StringSlice `json:"principals" db:"principals"`
+ CreatedAt time.Time `json:"created_at" db:"created_at"`
+ Expires time.Time `json:"expires" db:"expires_at"`
+ Revoked bool `json:"revoked" db:"revoked"`
+ Raw string `json:"-" db:"raw_key"`
}
func parseTime(t uint64) time.Time {
@@ -51,7 +52,7 @@ func parseTime(t uint64) time.Time {
func parseCertificate(cert *ssh.Certificate) *CertRecord {
return &CertRecord{
KeyID: cert.KeyId,
- Principals: cert.ValidPrincipals,
+ Principals: types.StringSlice(cert.ValidPrincipals),
CreatedAt: parseTime(cert.ValidAfter),
Expires: parseTime(cert.ValidBefore),
Raw: lib.GetPublicKey(cert),