Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Make the CAS server URL configurable (ugly way but CAS Omniauth strat…
Browse files Browse the repository at this point in the history
…egy doesn't seem to support :setup option for :cas_server ; maybe I'll try to send a pull request later)
  • Loading branch information
jbbarth committed Jun 7, 2011
1 parent ad05252 commit 2f864aa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/views/settings/_omniauth_cas_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<label><%= l(:label_login_page_text) %> :</label>
<%= text_field_tag 'settings[label_login_with_cas]', @settings['label_login_with_cas'] %>
</p>
<p>
<label><%= l(:label_cas_server) %> :</label>
<%= text_field_tag 'settings[cas_server]', @settings['cas_server'] %>
</p>
</fieldset>


1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
en:
label_login_with_cas: Login with CAS
label_login_page_text: Login page text
label_cas_server: CAS Server URL
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fr:
label_login_with_cas: S'authentifier avec CAS
label_login_page_text: Texte de la page de login
label_cas_server: Adresse serveur CAS
10 changes: 8 additions & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
author_url 'mailto:[email protected]'
url 'http://github.com/jbbarth/redmine_omniauth_cas'
version '0.0.1'
settings :default => { 'label_login_with_cas' => '' },
settings :default => { 'label_login_with_cas' => '', 'cas_server' => 'http://localhost:9292/' },
:partial => 'settings/omniauth_cas_settings'
end

Expand Down Expand Up @@ -44,4 +44,10 @@

# Sample CAS provider
require 'omniauth/enterprise'
config.middleware.use OmniAuth::Strategies::CAS, :cas_server => 'http://localhost:9292'
setup_app = Proc.new do |env|
cas_server = Setting["plugin_redmine_omniauth_cas"]["cas_server"]
cas_server = 'http://localhost:9292/' if cas_server.blank?
config = OmniAuth::Strategies::CAS::Configuration.new(:cas_server => cas_server)
env['omniauth.strategy'].instance_variable_set(:@configuration, config)
end
config.middleware.use OmniAuth::Strategies::CAS, :cas_server => 'http://localhost:9292/', :setup => setup_app
2 changes: 2 additions & 0 deletions test/integration/account_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class AccountPatchTest < ActionController::IntegrationTest
assert_equal User.anonymous, User.current
assert_select 'div.flash.error', 'Invalid user or password'
end

should "use the configured CAS address if provided in plugin settings"
end
end
end

0 comments on commit 2f864aa

Please sign in to comment.