From 9e43b04f04c431e6933739859d10e7487b91b595 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sun, 12 May 2019 17:20:24 -0400 Subject: [PATCH] Make Keychain struct public --- app.go | 2 +- database.go | 4 ++-- keys.go | 4 ++-- users.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app.go b/app.go index 8f8d3c5..3cd416a 100644 --- a/app.go +++ b/app.go @@ -68,7 +68,7 @@ type App struct { db *datastore cfg *config.Config cfgFile string - keys *keychain + keys *Keychain sessionStore *sessions.CookieStore formDecoder *schema.Decoder diff --git a/database.go b/database.go index 1c1d303..8ec93f7 100644 --- a/database.go +++ b/database.go @@ -44,7 +44,7 @@ var ( type writestore interface { CreateUser(*User, string) error - UpdateUserEmail(keys *keychain, userID int64, email string) error + UpdateUserEmail(keys *Keychain, userID int64, email string) error UpdateEncryptedUserEmail(int64, []byte) error GetUserByID(int64) (*User, error) GetUserForAuth(string) (*User, error) @@ -219,7 +219,7 @@ func (db *datastore) CreateUser(u *User, collectionTitle string) error { // FIXME: We're returning errors inconsistently in this file. Do we use Errorf // for returned value, or impart? -func (db *datastore) UpdateUserEmail(keys *keychain, userID int64, email string) error { +func (db *datastore) UpdateUserEmail(keys *Keychain, userID int64, email string) error { encEmail, err := data.Encrypt(keys.emailKey, email) if err != nil { return fmt.Errorf("Couldn't encrypt email %s: %s\n", email, err) diff --git a/keys.go b/keys.go index 84f7d6a..219e9c7 100644 --- a/keys.go +++ b/keys.go @@ -30,7 +30,7 @@ var ( cookieKeyPath = filepath.Join(keysDir, "cookies_enc.aes256") ) -type keychain struct { +type Keychain struct { emailKey, cookieAuthKey, cookieKey []byte } @@ -42,7 +42,7 @@ func initKeyPaths(app *App) { func initKeys(app *App) error { var err error - app.keys = &keychain{} + app.keys = &Keychain{} if debugging { log.Info(" %s", emailKeyPath) diff --git a/users.go b/users.go index 39ab385..6b245d5 100644 --- a/users.go +++ b/users.go @@ -79,7 +79,7 @@ type ( // EmailClear decrypts and returns the user's email, caching it in the user // object. -func (u *User) EmailClear(keys *keychain) string { +func (u *User) EmailClear(keys *Keychain) string { if u.clearEmail != "" { return u.clearEmail }