diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2016-07-17 23:54:42 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2016-07-24 23:23:33 +0100 |
commit | 44fef1c2a163bdfd781ef08a06e3cf5cf9b7d5da (patch) | |
tree | bcde234bf45255a8935aeacf7ee544f256b455cc /server/store/store.go | |
parent | c9849d667ab55c23d343332a11afb3eb8ede3f2d (diff) |
Add a page for revoking certs
Add a template for revocation
Use DATETIME type to store created/expires times
Require auth for the /admin and /revoke endpoints
Diffstat (limited to 'server/store/store.go')
-rw-r--r-- | server/store/store.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/server/store/store.go b/server/store/store.go index ad4922a..f6ac66e 100644 --- a/server/store/store.go +++ b/server/store/store.go @@ -1,6 +1,8 @@ package store import ( + "time" + "golang.org/x/crypto/ssh" "github.com/nsheridan/cashier/server/certutil" @@ -22,18 +24,22 @@ type CertStorer interface { type CertRecord struct { KeyID string Principals []string - CreatedAt uint64 - Expires uint64 + CreatedAt time.Time + Expires time.Time Revoked bool Raw string } +func parseTime(t uint64) time.Time { + return time.Unix(int64(t), 0) +} + func parseCertificate(cert *ssh.Certificate) *CertRecord { return &CertRecord{ KeyID: cert.KeyId, Principals: cert.ValidPrincipals, - CreatedAt: cert.ValidAfter, - Expires: cert.ValidBefore, + CreatedAt: parseTime(cert.ValidAfter), + Expires: parseTime(cert.ValidBefore), Raw: certutil.GetPublicKey(cert), } } |