Module: CASServer::Views
- Defined in:
- lib/casserver/views.rb
Overview
disabled XML indentation because it was causing problems with mod_auth_cas Markaby::Builder.set(:indent, 2)
Class Method Summary collapse
Instance Method Summary collapse
- #configure ⇒ Object
- #layout ⇒ Object
-
#login ⇒ Object
2.1.3 The full login page.
-
#login_form ⇒ Object
Just the login form.
-
#logout ⇒ Object
2.3.2.
-
#proxy ⇒ Object
2.7.2 CAS 2.0 proxy request response.
-
#proxy_validate ⇒ Object
2.6.2 CAS 2.0 proxy validate response.
-
#service_validate ⇒ Object
2.5.2 CAS 2.0 service validate response.
-
#validate ⇒ Object
2.4.2 CAS 1.0 validate response.
Class Method Details
.current_theme ⇒ Object
217 218 219 |
# File 'lib/casserver/views.rb', line 217 def current_theme CASServer::Conf.theme || "simple" end |
.infoline ⇒ Object
227 228 229 |
# File 'lib/casserver/views.rb', line 227 def CASServer::Conf. || "" end |
.organization ⇒ Object
222 223 224 |
# File 'lib/casserver/views.rb', line 222 def organization CASServer::Conf.organization || "" end |
.themes_dir ⇒ Object
212 213 214 |
# File 'lib/casserver/views.rb', line 212 def themes_dir File.dirname(File.(__FILE__))+'../themes' end |
Instance Method Details
#configure ⇒ Object
208 209 |
# File 'lib/casserver/views.rb', line 208 def configure end |
#layout ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/casserver/views.rb', line 12 def layout # wrap as XHTML only when auto_validation is on, otherwise pass right through if @use_layout xhtml_strict do head do title { "#{organization} Central Login" } link(:rel => "stylesheet", :type => "text/css", :href => "/themes/cas.css") link(:rel => "stylesheet", :type => "text/css", :href => "/themes/#{current_theme}/theme.css") end body(:onload => "if (document.getElementById('username')) document.getElementById('username').focus()") do self << yield end end else self << yield end end |
#login ⇒ Object
2.1.3 The full login page.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/casserver/views.rb', line 33 def login @use_layout = true table(:id => "login-box") do tr do td(:colspan => 2) do div(:id => "headline-container") do strong organization text " Central Login" end end end if tr do td(:colspan => 2, :id => "messagebox-container") do div(:class => "messagebox #{@message[:type]}") { [:message] } end end end tr do td(:id => "logo-container") do img(:id => "logo", :src => "/themes/#{current_theme}/logo.png") end td(:id => "login-form-container") do = true login_form end end end end |
#login_form ⇒ Object
Just the login form.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/casserver/views.rb', line 65 def login_form form(:method => "post", :action => @form_action || '/login', :id => "login-form", :onsubmit => "submitbutton = document.getElementById('login-submit'); submitbutton.value='Please wait...'; submitbutton.disabled=true; return true;") do table(:id => "form-layout") do tr do td(:id => "username-label-container") do label(:id => "username-label", :for => "username") { "Username" } end td(:id => "username-container") do input(:type => "text", :id => "username", :name => "username", :size => "32", :tabindex => "1", :accesskey => "u") end end tr do td(:id => "password-label-container") do label(:id => "password-label", :for => "password") { "Password" } end td(:id => "password-container") do input(:type => "password", :id => "password", :name => "password", :size => "32", :tabindex => "2", :accesskey => "p", :autocomplete => "off") end end tr do td{} td(:id => "submit-container") do input(:type => "hidden", :id => "lt", :name => "lt", :value => @lt) input(:type => "hidden", :id => "service", :name => "service", :value => @service) input(:type => "hidden", :id => "warn", :name => "warn", :value => @warn) input(:type => "submit", :class => "button", :accesskey => "l", :value => "LOGIN", :tabindex => "4", :id => "login-submit") end end tr do td(:colspan => 2, :id => "infoline") { } end if end end end |
#logout ⇒ Object
2.3.2
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/casserver/views.rb', line 104 def logout @use_layout = true table(:id => "login-box") do tr do td(:colspan => 2) do div(:id => "headline-container") do strong organization text " Central Login" end end end if tr do td(:colspan => 2, :id => "messagebox-container") do div(:class => "messagebox #{@message[:type]}") { [:message] } if @continue_url p do a(:href => @continue_url) { @continue_url } end end end end end end end |
#proxy ⇒ Object
2.7.2 CAS 2.0 proxy request response.
194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/casserver/views.rb', line 194 def proxy if @success tag!("cas:serviceResponse", 'xmlns:cas' => "http://www.yale.edu/tp/cas") do tag!("cas:proxySuccess") do tag!("cas:proxyTicket") {@pt.to_s.to_xs} end end else tag!("cas:serviceResponse", 'xmlns:cas' => "http://www.yale.edu/tp/cas") do tag!("cas:proxyFailure", :code => @error.code) {@error.to_s.to_xs} end end end |
#proxy_validate ⇒ Object
2.6.2 CAS 2.0 proxy validate response.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/casserver/views.rb', line 165 def proxy_validate if @success tag!("cas:serviceResponse", 'xmlns:cas' => "http://www.yale.edu/tp/cas") do tag!("cas:authenticationSuccess") do tag!("cas:user") {@username.to_s.to_xs} @extra_attributes.each do |key, value| tag!(key) {value} end if @pgtiou tag!("cas:proxyGrantingTicket") {@pgtiou.to_s.to_xs} end if @proxies && !@proxies.empty? tag!("cas:proxies") do @proxies.each do |proxy_url| tag!("cas:proxy") {proxy_url.to_s.to_xs} end end end end end else tag!("cas:serviceResponse", 'xmlns:cas' => "http://www.yale.edu/tp/cas") do tag!("cas:authenticationFailure", :code => @error.code) {@error.to_s.to_xs} end end end |
#service_validate ⇒ Object
2.5.2 CAS 2.0 service validate response.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/casserver/views.rb', line 143 def service_validate if @success tag!("cas:serviceResponse", 'xmlns:cas' => "http://www.yale.edu/tp/cas") do tag!("cas:authenticationSuccess") do tag!("cas:user") {@username.to_s.to_xs} @extra_attributes.each do |key, value| tag!(key) {value} end if @pgtiou tag!("cas:proxyGrantingTicket") {@pgtiou.to_s.to_xs} end end end else tag!("cas:serviceResponse", 'xmlns:cas' => "http://www.yale.edu/tp/cas") do tag!("cas:authenticationFailure", :code => @error.code) {@error.to_s.to_xs} end end end |
#validate ⇒ Object
2.4.2 CAS 1.0 validate response.
133 134 135 136 137 138 139 |
# File 'lib/casserver/views.rb', line 133 def validate if @success text "yes\n#{@username}\n" else text "no\n\n" end end |