Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
28 lines
806 B
Go
28 lines
806 B
Go
package store
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
type calendarCredential struct{ Purpose, Domain, Calendar, Username, Password string }
|
|
|
|
func (s *Store) SealCalendarCredential(domain, id, user, password string) (string, error) {
|
|
b, e := json.Marshal(calendarCredential{"calendar-source-v1", domain, id, user, password})
|
|
if e != nil {
|
|
return "", e
|
|
}
|
|
return s.encryptAuthSecret(b)
|
|
}
|
|
func (s *Store) OpenCalendarCredential(domain, id, cipher string) (string, string, error) {
|
|
b, e := s.decryptAuthSecret(cipher)
|
|
if e != nil {
|
|
return "", "", e
|
|
}
|
|
var v calendarCredential
|
|
if json.Unmarshal(b, &v) != nil || v.Purpose != "calendar-source-v1" || v.Domain != domain || v.Calendar != id {
|
|
return "", "", errors.New("invalid calendar credential context")
|
|
}
|
|
return v.Username, v.Password, nil
|
|
}
|