Add support for scope and add some missing translations

See this post on meta about the need for the ability to request a custom
scope:

https://meta.discourse.org/t/oauth2-basic-support/33879/116?u=blake
This commit is contained in:
Blake Erickson 2018-05-25 15:35:52 -06:00
parent f60a5799a1
commit 04ef6494de
3 changed files with 7 additions and 0 deletions

View File

@ -12,8 +12,11 @@ en:
oauth2_json_username_path: 'Path in the OAuth2 User JSON to the username. eg: user.username'
oauth2_json_name_path: "Path in the OAuth2 User JSON to the user's full: user.name.full"
oauth2_json_email_path: "Path in the OAuth2 User JSON to the user's email: user.email.primary"
oauth2_json_avatar_path: "Path in the Oauth2 User JSON to the user's avatar: user.avatar_url"
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"
oauth2_scope: "When authorizing request this scope"
oauth2_button_title: "The text for the OAuth2 button"

View File

@ -30,6 +30,7 @@ login:
oauth2_authorize_options:
default: 'scope'
type: list
oauth2_scope: ''
oauth2_button_title:
default: 'with OAuth2'
client: true

View File

@ -40,6 +40,9 @@ class OAuth2BasicAuthenticator < ::Auth::OAuth2Authenticator
if SiteSetting.oauth2_send_auth_header?
opts[:token_params] = { headers: { 'Authorization' => basic_auth_header } }
end
unless SiteSetting.oauth2_scope.blank?
opts[:scope] = SiteSetting.oauth2_scope
end
}
end