diff --git a/app/controllers/redmine_oauth_controller.rb b/app/controllers/redmine_oauth_controller.rb index c743c1e..df8509c 100644 --- a/app/controllers/redmine_oauth_controller.rb +++ b/app/controllers/redmine_oauth_controller.rb @@ -6,8 +6,8 @@ class RedmineOauthController < AccountController include Helpers::MailHelper include Helpers::Checker def oauth_azure - if Setting.plugin_redmine_omniauth_azure[:azure_oauth_authentication] - session[:back_url] = params[:back_url] + if Setting.plugin_redmine_omniauth_azure['azure_oauth_authentication'] + session['back_url'] = params['back_url'] redirect_to oauth_client.auth_code.authorize_url(:redirect_uri => oauth_azure_callback_url, :scope => scopes) else password_authentication @@ -15,11 +15,11 @@ def oauth_azure end def oauth_azure_callback - if params[:error] - flash[:error] = l(:notice_access_denied) + if params['error'] + flash['error'] = l(:notice_access_denied) redirect_to signin_path else - token = oauth_client.auth_code.get_token(params[:code], :redirect_uri => oauth_azure_callback_url, :resource => "00000002-0000-0000-c000-000000000000") + token = oauth_client.auth_code.get_token(params['code'], :redirect_uri => oauth_azure_callback_url, :resource => "00000002-0000-0000-c000-000000000000") user_info = JWT.decode(token.token, nil, false) logger.error user_info @@ -28,7 +28,7 @@ def oauth_azure_callback if email checked_try_to_login email, user_info.first else - flash[:error] = l(:notice_no_verified_email_we_could_use) + flash['error'] = l(:notice_no_verified_email_we_could_use) redirect_to signin_path end end @@ -38,13 +38,13 @@ def checked_try_to_login(email, user) if allowed_domain_for?(email) try_to_login email, user else - flash[:error] = l(:notice_domain_not_allowed, :domain => parse_email(email)[:domain]) + flash['error'] = l(:notice_domain_not_allowed, :domain => parse_email(email)['domain']) redirect_to signin_path end end def try_to_login email, info - params[:back_url] = session[:back_url] + params['back_url'] = session['back_url'] session.delete(:back_url) user = User.joins(:email_addresses) @@ -88,10 +88,10 @@ def try_to_login email, info end def oauth_client - @client ||= OAuth2::Client.new(settings[:client_id], settings[:client_secret], + @client ||= OAuth2::Client.new(settings['client_id'], settings['client_secret'], :site => 'https://login.windows.net', - :authorize_url => '/' + settings[:tenant_id] + '/oauth2/authorize', - :token_url => '/' + settings[:tenant_id] + '/oauth2/token') + :authorize_url => '/' + settings['tenant_id'] + '/oauth2/authorize', + :token_url => '/' + settings['tenant_id'] + '/oauth2/token') end def settings diff --git a/app/views/hooks/_view_account_login_bottom.html.erb b/app/views/hooks/_view_account_login_bottom.html.erb index 411de3a..1b83fa6 100644 --- a/app/views/hooks/_view_account_login_bottom.html.erb +++ b/app/views/hooks/_view_account_login_bottom.html.erb @@ -1,6 +1,6 @@ <%= stylesheet_link_tag 'buttons', :plugin => 'redmine_omniauth_azure' %> -<% if Setting.plugin_redmine_omniauth_azure[:azure_oauth_authentication] %> +<% if Setting.plugin_redmine_omniauth_azure['azure_oauth_authentication'] %> <%= link_to oauth_azure_path(:back_url => back_url) do %> <%= button_tag :class => 'button-login' do %> <%= image_tag('/plugin_assets/redmine_omniauth_azure/images/azure_login_icon.png', :class => 'button-login-icon', :alt => l(:login_via_azure)) %> diff --git a/app/views/settings/_azure_settings.html.erb b/app/views/settings/_azure_settings.html.erb index 47afffc..ff0d635 100644 --- a/app/views/settings/_azure_settings.html.erb +++ b/app/views/settings/_azure_settings.html.erb @@ -1,20 +1,20 @@
- <%= text_field_tag 'settings[client_id]', @settings[:client_id] %> + <%= text_field_tag 'settings[client_id]', @settings['client_id'] %>
- <%= text_field_tag 'settings[client_secret]', @settings[:client_secret] %> + <%= text_field_tag 'settings[client_secret]', @settings['client_secret'] %>
- <%= text_field_tag 'settings[tenant_id]', @settings[:tenant_id] %> + <%= text_field_tag 'settings[tenant_id]', @settings['tenant_id'] %>
- <%= text_area_tag "settings[allowed_domains]", @settings[:allowed_domains], :rows => 5 %> + <%= text_area_tag "settings[allowed_domains]", @settings['allowed_domains'], :rows => 5 %>
- <%= check_box_tag "settings[azure_oauth_authentication]", true, @settings[:azure_oauth_authentication] %> + <%= check_box_tag "settings[azure_oauth_authentication]", true, @settings['azure_oauth_authentication'] %>
diff --git a/lib/helpers/checker.rb b/lib/helpers/checker.rb index 81fb300..f0d3fa9 100644 --- a/lib/helpers/checker.rb +++ b/lib/helpers/checker.rb @@ -1,11 +1,11 @@ module Helpers module Checker def allowed_domain_for? email - allowed_domains = Setting.plugin_redmine_omniauth_azure[:allowed_domains] + allowed_domains = Setting.plugin_redmine_omniauth_azure['allowed_domains'] return unless allowed_domains allowed_domains = allowed_domains.split return true if allowed_domains.empty? - allowed_domains.index(parse_email(email)[:domain]) + allowed_domains.index(parse_email(email)['domain']) end end end