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
- .current_theme ⇒ Object
- .infoline ⇒ Object
- .organization ⇒ Object
- .serialize_extra_attribute(value) ⇒ Object
- .themes_dir ⇒ Object
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
216 217 218 |
# File 'lib/casserver/views.rb', line 216 def current_theme $CONF.theme || "simple" end |
.infoline ⇒ Object
226 227 228 |
# File 'lib/casserver/views.rb', line 226 def $CONF. || "" end |
.organization ⇒ Object
221 222 223 |
# File 'lib/casserver/views.rb', line 221 def organization $CONF.organization || "" end |
.serialize_extra_attribute(value) ⇒ Object
231 232 233 234 235 236 237 |
# File 'lib/casserver/views.rb', line 231 def serialize_extra_attribute(value) if value.kind_of?(String) || value.kind_of?(Numeric) value else "<![CDATA[#{value.to_yaml}]]>" end end |
.themes_dir ⇒ Object
211 212 213 |
# File 'lib/casserver/views.rb', line 211 def themes_dir File.dirname(File.(__FILE__))+'../themes' end |
Instance Method Details
#configure ⇒ Object
207 208 |
# File 'lib/casserver/views.rb', line 207 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 @message tr do td(:colspan => 2, :id => "messagebox-container") do div(:class => "messagebox #{@message[:type]}") { @message[: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 @include_infoline = 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 |
# 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 => "submit", :class => "button", :accesskey => "l", :value => _("LOGIN"), :tabindex => "4", :id => "login-submit") end end tr do td(:colspan => 2, :id => "infoline") { } end if @include_infoline end end end |
#logout ⇒ Object
2.3.2
103 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 |
# File 'lib/casserver/views.rb', line 103 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 @message tr do td(:colspan => 2, :id => "messagebox-container") do div(:class => "messagebox #{@message[:type]}") { @message[: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.
193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/casserver/views.rb', line 193 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.
164 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 |
# File 'lib/casserver/views.rb', line 164 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) {serialize_extra_attribute(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.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/casserver/views.rb', line 142 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) {serialize_extra_attribute(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.
132 133 134 135 136 137 138 |
# File 'lib/casserver/views.rb', line 132 def validate if @success text "yes\n#{@username}\n" else text "no\n\n" end end |