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.
This commit is contained in:
Nick Craig-Wood 2017-06-08 20:35:32 +01:00
parent 9c1e703777
commit 52e1bfae2a
2 changed files with 16 additions and 0 deletions

View File

@ -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"
)

View File

@ -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
}