Make Keychain struct public

This commit is contained in:
Matt Baer 2019-05-12 17:20:24 -04:00
parent d8937e89a8
commit 9e43b04f04
4 changed files with 6 additions and 6 deletions

2
app.go
View File

@ -68,7 +68,7 @@ type App struct {
db *datastore db *datastore
cfg *config.Config cfg *config.Config
cfgFile string cfgFile string
keys *keychain keys *Keychain
sessionStore *sessions.CookieStore sessionStore *sessions.CookieStore
formDecoder *schema.Decoder formDecoder *schema.Decoder

View File

@ -44,7 +44,7 @@ var (
type writestore interface { type writestore interface {
CreateUser(*User, string) error CreateUser(*User, string) error
UpdateUserEmail(keys *keychain, userID int64, email string) error UpdateUserEmail(keys *Keychain, userID int64, email string) error
UpdateEncryptedUserEmail(int64, []byte) error UpdateEncryptedUserEmail(int64, []byte) error
GetUserByID(int64) (*User, error) GetUserByID(int64) (*User, error)
GetUserForAuth(string) (*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 // FIXME: We're returning errors inconsistently in this file. Do we use Errorf
// for returned value, or impart? // 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) encEmail, err := data.Encrypt(keys.emailKey, email)
if err != nil { if err != nil {
return fmt.Errorf("Couldn't encrypt email %s: %s\n", email, err) return fmt.Errorf("Couldn't encrypt email %s: %s\n", email, err)

View File

@ -30,7 +30,7 @@ var (
cookieKeyPath = filepath.Join(keysDir, "cookies_enc.aes256") cookieKeyPath = filepath.Join(keysDir, "cookies_enc.aes256")
) )
type keychain struct { type Keychain struct {
emailKey, cookieAuthKey, cookieKey []byte emailKey, cookieAuthKey, cookieKey []byte
} }
@ -42,7 +42,7 @@ func initKeyPaths(app *App) {
func initKeys(app *App) error { func initKeys(app *App) error {
var err error var err error
app.keys = &keychain{} app.keys = &Keychain{}
if debugging { if debugging {
log.Info(" %s", emailKeyPath) log.Info(" %s", emailKeyPath)

View File

@ -79,7 +79,7 @@ type (
// EmailClear decrypts and returns the user's email, caching it in the user // EmailClear decrypts and returns the user's email, caching it in the user
// object. // object.
func (u *User) EmailClear(keys *keychain) string { func (u *User) EmailClear(keys *Keychain) string {
if u.clearEmail != "" { if u.clearEmail != "" {
return u.clearEmail return u.clearEmail
} }