summaryrefslogtreecommitdiff
path: root/internal/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index e6bc19a..7a80897 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -18,8 +18,18 @@ type Config struct {
GoogleCredentialsFile string
GoogleCalendarID string
- // Google Tasks
- GoogleTasksListID string
+ // Google Tasks (real 3-legged OAuth -- service-account auth cannot see a
+ // user's personal task lists, see NewGoogleTasksClient's doc comment)
+ GoogleTasksListID string
+ GoogleOAuthClientID string
+ GoogleOAuthClientSecret string
+ // GoogleOAuthRedirectURL must exactly match an "Authorized redirect URI"
+ // on the OAuth 2.0 Client ID in Google Cloud Console -- kept as its own
+ // explicit var rather than derived from WebAuthnOrigin (which isn't set
+ // in production; passkeys aren't configured either) so there's exactly
+ // one place that has to match Console, not two things that have to
+ // agree with each other.
+ GoogleOAuthRedirectURL string
// Paths
DatabasePath string
@@ -66,7 +76,10 @@ func Load() (*Config, error) {
GoogleCalendarID: getEnvWithDefault("GOOGLE_CALENDAR_ID", "primary"),
// Google Tasks
- GoogleTasksListID: getEnvWithDefault("GOOGLE_TASKS_LIST_ID", "@default"),
+ GoogleTasksListID: getEnvWithDefault("GOOGLE_TASKS_LIST_ID", "@default"),
+ GoogleOAuthClientID: os.Getenv("GOOGLE_OAUTH_CLIENT_ID"),
+ GoogleOAuthClientSecret: os.Getenv("GOOGLE_OAUTH_CLIENT_SECRET"),
+ GoogleOAuthRedirectURL: getEnvWithDefault("GOOGLE_OAUTH_REDIRECT_URL", "https://doot.terst.org/settings/google-tasks/callback"),
// Paths
DatabasePath: getEnvWithDefault("DATABASE_PATH", "./dashboard.db"),
@@ -140,9 +153,11 @@ func (c *Config) HasGoogleCalendar() bool {
return c.GoogleCredentialsFile != ""
}
-// HasGoogleTasks checks if Google Tasks is configured
+// HasGoogleTasks checks if Google Tasks OAuth is configured (client ID and
+// secret from Google Cloud Console) -- doesn't mean a user has actually
+// connected yet, that's the oauth_tokens row, checked separately.
func (c *Config) HasGoogleTasks() bool {
- return c.GoogleCredentialsFile != "" && c.GoogleTasksListID != ""
+ return c.GoogleOAuthClientID != "" && c.GoogleOAuthClientSecret != ""
}
// getEnvWithDefault returns environment variable value or default if not set