From 52e1bfae2a8b67b0056af81eac00a0c394915121 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 8 Jun 2017 20:35:32 +0100 Subject: [PATCH] oauth: Allow auth_url and token_url to be set in the config file If set in the config file, these override the ones configured into the remote. This enables alternative oauth servers to be used for all oauth remotes. This can only be altered by editing the config file for the moment. --- fs/config.go | 6 ++++++ oauthutil/oauthutil.go | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/fs/config.go b/fs/config.go index 4bc804b1c..993dacae1 100644 --- a/fs/config.go +++ b/fs/config.go @@ -44,6 +44,12 @@ const ( // ConfigClientSecret is the config key used to store the client secret ConfigClientSecret = "client_secret" + // ConfigAuthURL is the config key used to store the auth server endpoint + ConfigAuthURL = "auth_url" + + // ConfigTokenURL is the config key used to store the token server endpoint + ConfigTokenURL = "token_url" + // ConfigAutomatic indicates that we want non-interactive configuration ConfigAutomatic = "config_automatic" ) diff --git a/oauthutil/oauthutil.go b/oauthutil/oauthutil.go index a5da620b5..6f8948a68 100644 --- a/oauthutil/oauthutil.go +++ b/oauthutil/oauthutil.go @@ -209,6 +209,16 @@ func overrideCredentials(name string, origConfig *oauth2.Config) (config *oauth2 config.ClientSecret = ClientSecret changed = true } + AuthURL := fs.ConfigFileGet(name, fs.ConfigAuthURL) + if AuthURL != "" { + config.Endpoint.AuthURL = AuthURL + changed = true + } + TokenURL := fs.ConfigFileGet(name, fs.ConfigTokenURL) + if TokenURL != "" { + config.Endpoint.TokenURL = TokenURL + changed = true + } return config, changed }