mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Configure OAuth2 redirect URL
This commit is contained in:
@ -13,6 +13,7 @@ type AppConfig struct {
|
||||
VimeoApiKey string `yaml:"vimeoApiKey"`
|
||||
PatreonClientId string `yaml:"patreonClientId"`
|
||||
PatreonSecret string `yaml:"patreonSecret"`
|
||||
PatreonRedirectURL string `yaml:"patreonRedirectUrl"`
|
||||
PostgresConnectionURL string `yaml:"postgresConnectionUrl"`
|
||||
RedisURL string `yaml:"redisUrl"`
|
||||
CookieSecret string `yaml:"cookieSecret"`
|
||||
@ -34,6 +35,7 @@ func ReadConfiguration() (cfg *AppConfig, err error) {
|
||||
"vimeoApiKey": "VIMEO_API_KEY",
|
||||
"patreonClientId": "PATREON_CLIENT_ID",
|
||||
"patreonSecret": "PATREON_SECRET",
|
||||
"patreonRedirectUrl": "PATREON_REDIRECT_URL",
|
||||
"postgresConnectionUrl": "POSTGRES_CONNECTION_URL",
|
||||
"redisUrl": "REDIS_CONNECTION_URL",
|
||||
"cookieSecret": "COOKIE_SECRET",
|
||||
|
@ -16,6 +16,7 @@ patreonClientId: "3"
|
||||
patreonSecret: "4"
|
||||
postgresConnectionUrl: "5"
|
||||
cookieSecret: "6"
|
||||
patreonRedirectUrl: "7"
|
||||
`
|
||||
|
||||
func TestReadYaml(t *testing.T) {
|
||||
@ -34,6 +35,7 @@ func TestReadYaml(t *testing.T) {
|
||||
require.Equal(t, "4", cfg.PatreonSecret)
|
||||
require.Equal(t, "5", cfg.PostgresConnectionURL)
|
||||
require.Equal(t, "6", cfg.CookieSecret)
|
||||
require.Equal(t, "7", cfg.PatreonRedirectURL)
|
||||
}
|
||||
|
||||
func TestReadEnv(t *testing.T) {
|
||||
@ -46,6 +48,7 @@ func TestReadEnv(t *testing.T) {
|
||||
os.Setenv("PATREON_SECRET", "44")
|
||||
os.Setenv("POSTGRES_CONNECTION_URL", "55")
|
||||
os.Setenv("COOKIE_SECRET", "66")
|
||||
os.Setenv("PATREON_REDIRECT_URL", "77")
|
||||
|
||||
cfg, err := ReadConfiguration()
|
||||
require.NoError(t, err)
|
||||
@ -56,4 +59,5 @@ func TestReadEnv(t *testing.T) {
|
||||
require.Equal(t, "44", cfg.PatreonSecret)
|
||||
require.Equal(t, "55", cfg.PostgresConnectionURL)
|
||||
require.Equal(t, "66", cfg.CookieSecret)
|
||||
require.Equal(t, "77", cfg.PatreonRedirectURL)
|
||||
}
|
||||
|
@ -39,10 +39,14 @@ func MakeHandlers(feed feed, cfg *config.AppConfig) http.Handler {
|
||||
|
||||
// Static files + HTML
|
||||
|
||||
if cfg.PatreonRedirectURL == "" {
|
||||
cfg.PatreonRedirectURL = "http://localhost:8080/patreon"
|
||||
}
|
||||
|
||||
conf := &oauth2.Config{
|
||||
ClientID: cfg.PatreonClientId,
|
||||
ClientSecret: cfg.PatreonSecret,
|
||||
RedirectURL: "http://localhost:8080/patreon",
|
||||
RedirectURL: cfg.PatreonRedirectURL,
|
||||
Scopes: []string{"users", "pledges-to-me", "my-campaign"},
|
||||
Endpoint: oauth2.Endpoint{
|
||||
AuthURL: patreon.AuthorizationURL,
|
||||
|
Reference in New Issue
Block a user