Files
pages/internal/store/calendar_credentials.go
T
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
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.
2026-09-27 14:44:43 +09:00

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
}