From e8b2307acdeb960c29da17860ed6ccc45143be01 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 25 May 2016 17:46:06 +1000 Subject: [PATCH] Add setting for authorize options --- config/locales/server.en.yml | 1 + config/settings.yml | 3 +++ plugin.rb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 8d41da0..d9f0a6d 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -13,4 +13,5 @@ en: oauth2_email_verified: "Check this if the OAuth2 site has verified the email" oauth2_send_auth_header: "Send the token as an HTTP Authorization header" oauth2_debug_auth: "Include rich debugging information in your logs" + oauth2_authorize_options: "When authorizing request these options" diff --git a/config/settings.yml b/config/settings.yml index 57f801c..1a73d22 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -14,6 +14,9 @@ login: oauth2_email_verified: false oauth2_send_auth_header: true oauth2_debug_auth: false + oauth2_authorize_options: + default: 'scope' + type: list oauth2_button_title: default: 'with OAuth2' client: true diff --git a/plugin.rb b/plugin.rb index 1dc9a0e..e4716b2 100644 --- a/plugin.rb +++ b/plugin.rb @@ -20,6 +20,8 @@ class OAuth2BasicAuthenticator < ::Auth::OAuth2Authenticator authorize_url: SiteSetting.oauth2_authorize_url, token_url: SiteSetting.oauth2_token_url } + opts[:authorize_options] = SiteSetting.oauth2_authorize_options.split("|").map(&:to_sym) + if SiteSetting.oauth2_send_auth_header? opts[:token_params] = {headers: {'Authorization' => basic_auth_header }} end