EzDevInfo.com

rubycas-client

Ruby client for Yale's Central Authentication Service protocol -- an open source enterprise single sign on system for web applications. rubycas-client - RubyCAS-Client is a Ruby client library for JA-SIG's Central Authentication Service (CAS) protocol. - Google Project Hosting

Zooniverse's Scribe Framework Ruby on Rails CASClient NoMethodError in HomeController#index

UPDATE: I intermittently fixed the problem by commenting out any references to CASClient in my program's code, but now that leaves me with another problem: I won't have any way to create and manage users. The original problem still stands of course.

For the past few months I've been working on trying to get Zooniverse's Scribe framework (document transcription framework) working to use as part of my Term project for university. The library was last updated four years ago and I had to change a couple items in the gemfile and update some code to get it working with current versions of Ruby on Rails and gems. The app is built using Ruby on Rails, and I'm not that familiar with it,

After many issues trying to get things set up, I recently managed to finally run rake successfully, but when I run the rails server and navigate to localhost:3000 I get a page with the following error message: "Undefined method 'before' CASClient Ruby on Rails / undefined method `before' for CASClient::Frameworks::Rails::GatewayFilter:Class".

I've only been able to find references in the program's code to a "before" method in a couple of .rb files such as home_controller.rb

before_filter CASClient::Frameworks::Rails::GatewayFilter

Do you have any suggestions on what I can do to get it working? At this point I'm just trying to get it working as a proof of concept and I will customize it for my project after that. Starting to get stressed out with deadlines looming! =(

I'll post more info in code blocks below. All my current code can be found at McGill Weather on Github if you want to take a closer look at the project or test it out for yourself.

Thank you so much!

Here is the full stack trace:

activesupport (4.2.0) lib/active_support/callbacks.rb:450:in `public_send'
activesupport (4.2.0) lib/active_support/callbacks.rb:450:in `block in make_lambda'
activesupport (4.2.0) lib/active_support/callbacks.rb:163:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:163:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
/home/rob/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/rob/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/rob/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

Gemfile:

source 'http://rubygems.org'

gem 'rails', '4.2.0'
gem 'rubycas-client', '~> 2.3.9'
gem 'rake', '10.4.2'
gem "activeresource", "~> 4.0.0"
gem 'bson_ext'
gem 'mongo_mapper', :branch => 'rails3'
#gem 'barista'

gem 'heroku'



# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19'

# Bundle the extra gems:
# gem 'bj'
gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development, :test do
   gem 'webrat'
   gem 'shoulda'
   gem 'factory_girl_rails', '1.4.0'
   gem 'mocha'
   gem 'autotest'
   gem 'autotest-rails'
     gem 'jasmine'

end

Source: (StackOverflow)

How to implement single sign out with RubyCAS, but don't store session in database?

I want to implement single sign out with RubyCAS, but that must store session in database, I don't want to do that.

How to implement single sign out with RubyCAS, but don't store session in database?


Source: (StackOverflow)

Advertisements

rubycas-client authentification and local session

I am using ruby-cas client, for an authentification based on a CAS. I would like to link the ruby_cas authentication to my application :

when we log in with cas, in additon to the CAS session created, a session for my application is also created.

What should i do?

thanks


Source: (StackOverflow)

rubycas-client XML parsing

When using CAS-client following the instructions, I've reached a point where I've got a positive response from an external CAS server:

CAS server responded with #<Net::HTTPOK 200 OK readbody=true>:

And the XML is like this:

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
  <cas:authenticationSuccess>
    <cas:attributes>
      <cas:user>4oaz8QMucIrlFOU7dr3QpWkqbRY=</cas:user>
      <cas:ccc></cas:ccc>
      <cas:tipo>EDITED_OUT</cas:tipo>
      <cas:acceso>cd</cas:acceso>
      <cas:identificador>EDITED_OUT</cas:identificador>
      <cas:txtBienvenida>EDITED_OUT</cas:txtBienvenida>
      <cas:usuarioValidado>S</cas:usuarioValidado>
      <cas:correo>EDITED_OUT</cas:correo>
      <cas:tlf>EDITED_OUT</cas:tlf>
      <cas:tipoAcceso>2</cas:tipoAcceso>
      <cas:xusuario>EDITED_OUT</cas:xusuario>
      <!-- En caso de que el usuario disponga de certificado digital -->

      <cas:nif>EDITED_OUT</cas:nif>
      <cas:email>EDITED_OUT</cas:email>
      <cas:apellido1>EDITED_OUT</cas:apellido1>
      <cas:apellido2>EDITED_OUT</cas:apellido2>
      <cas:anagramaFiscal>EDITED_OUT</cas:anagramaFiscal>
      <cas:nombre>EDITED_OUT</cas:nombre>

      <!-- Faltan las fechas -->

      <cas:tipoCertificado>EDITED_OUT</cas:tipoCertificado>
      <cas:emisor>EDITED_OUT</cas:emisor>
      <cas:usoCertificado>EDITED_OUT</cas:usoCertificado>
      <cas:apellidosResponsable>EDITED_OUT</cas:apellidosResponsable>

      <!-- Faltan las fechas -->

      <cas:politica>1.3.6.1.4.1.5734.3.5</cas:politica>
      <cas:subject>EDITED_OUT</cas:subject>
      <cas:versionPolitica>45</cas:versionPolitica>
      <cas:organizacionEmisora>FNMT</cas:organizacionEmisora>
      <cas:idPolitica>DEFAULT</cas:idPolitica>
      <cas:numSerie>EDITED_OUT</cas:numSerie>
      <cas:clasificacion>FNMT</cas:clasificacion>
      <cas:tipoAfirma>0</cas:tipoAfirma>
    </cas:attributes>
  </cas:authenticationSuccess>
</cas:serviceResponse>

Then I get this log message from rubycas-client:

Ticket "EDITED_OUT" for service "EDITED_OUT" belonging to user nil is VALID.

And then this error dump:

TypeError (can't dup NilClass):
  org/jruby/RubyKernel.java:1894:in `dup'
  ----CUTTED----

Examining the code, I've come to the conclusion that the error is in filter.rb line 64:

controller.session[client.username_session_key] = st.user.dup

Debugging, I examined the contents of the st object:

(rdb:2) st.is_valid?
true
(rdb:2) st.user
nil
(rdb:2) st
#<CASClient::ServiceTicket:0x7e054262
  @renew=nil,
  @extra_attributes={
    "user"=>"4oaz8QMucIrlFOU7dr3QpWkqbRY="
    "ccc"=>nil,
    "tipo"=>"CIUDADANO",
    "acceso"=>"cd",
    "identificador"=>"EDITED_OUT",
    "txtBienvenida"=>"EDITED_OUT",
    "usuarioValidado"=>"S", 
    "correo"=>"EDITED_OUT",
    "tlf"=>"EDITED_OUT",
    "tipoAcceso"=>"2",
    "xusuario"=>"EDITED_OUT",
    "nif"=>"EDITED_OUT", 
    "email"=>"EDITED_OUT",
    "apellido1"=>"EDITED_OUT",
    "apellido2"=>"EDITED_OUT",      
    "anagramaFiscal"=>"EDITED_OUT",         
    "nombre"=>"EDITED_OUT",
    "tipoCertificado"=>"FNMT PF",       
    "emisor"=>"EDITED_OUT",
    "usoCertificado"=>"EDITED_OUT",
    "apellidosResponsable"=>"EDITED_OUT",
    "politica"=>"1.3.6.1.4.1.5734.3.5",
    "subject"=>"EDITED_OUT",
    "versionPolitica"=>"45",
    "organizacionEmisora"=>"FNMT",
    "idPolitica"=>"DEFAULT",
    "numSerie"=>"EDITED_OUT",
    "clasificacion"=>"FNMT",
    "tipoAfirma"=>"0"
  },
  @service="EDITED_OUT",
  @failure_code=nil,
  @ticket="EDITED_OUT",
  @pgt_iou=nil,
  @user=nil,
  @failure_message=nil,
  @success=true
>

Then, researching the xml parsing and responses.rb, I arrived to this in line 55:

cas_user = @xml.elements["cas:user"]

cas_user is always nil because there is no cas:user element in the XML root, but there's one as child of cas:attributes, thus this:

@xml.elements["cas:attributes/cas:user"]

returns something, in my case, something that looks like a digest of some kind, though I don't know how it's encoded or what info is there.

My question is, if that cas:attributes/cas:user attribute is the one that the client is trying to parse from the XML, or if it's something else. Also, I'd like to know if that XML format I pasted above is CAS-2.0 protocol compliant or if the error comes from a badly-formed XML. It's strange that rubycas-client stores all the "useful data" inside the extra_attributes.

I'm using the following:

Thanks your your help.


Source: (StackOverflow)

RubyCas client using https not receiving the CasServer 'LogoutRequest'

RubyCas client using https is not receiving the CasServer 'LogoutRequest'

I used 'rubyCas-client' gem. It's working fine in http (with cluster servers also), but when I am trying to use 'HTTPS' (using ssl certificate), my application server itself is not receiving the CasServer session 'LogoutRequest'. It's still maintaining the session.

Why is this happening?


Source: (StackOverflow)

Reading session values in RubyCas Client filter method

I am using ruby-cas server as my single sign on solutions and the rubycas-client in my application to check if user authenticated or now.

Everything works fine, but now i added an API route in the CAS server that allows a user to authenticate only by providing an email address and returns a service ticket to the app.

I then set this ticket in a sessions called cas_last_valid_ticket this way

session['cas_last_valid_ticket'] = ticket 

this is the json response with the ticket from the API

But when i try to load the application and navigate to another route the filter method can not read that session, precisely here:

last_st = controller.session[:cas_last_valid_ticket]
last_st_service = controller.session[:cas_last_valid_ticket_service]

Those values are both nil causing the application to redirect back to the login page.

How can I achieve something like this?

Any help would be greatly appreciated.


Source: (StackOverflow)