rubycas / rubycas-server

Provides single sign-on authentication for web applications, implementing the server-end of Jasig's CAS protocol.
http://rubycas.github.com
Other
628 stars 270 forks source link

SQL AUTHENTICATOR Problems ? #147

Closed rbinsztock closed 11 years ago

rbinsztock commented 11 years ago

Well, i try to use Two authenticator my LDAP Authenticator works great but now i want to add an SQL one for backup.

The thing is i got only error when i try to connect with it :

oMethodError - undefined method length' for nil:NilClass: /home/rbi/sites/rubycas-server/lib/casserver/authenticators/sql.rb:83:invalidate' /home/rbi/sites/rubycas-server/lib/casserver/server.rb:443:in block (2 levels) in <class:Server>' /home/rbi/sites/rubycas-server/lib/casserver/server.rb:435:ineach' /home/rbi/sites/rubycas-server/lib/casserver/server.rb:435:in block in <class:Server>' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:incall' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in block in compile!' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in[]' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in block (3 levels) in route!' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:inroute_eval' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in block (2 levels) in route!' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:inblock in process_route' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in catch' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:inprocess_route' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in block in route!' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:ineach' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in route!' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:indispatch!' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in block in call!' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:inblock in invoke' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in catch' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:ininvoke' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in call!' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:755:incall' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in call' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:incall' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in call' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:incall' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in call' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/rack-1.4.1/lib/rack/nulllogger.rb:9:incall' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/rack-1.4.1/lib/rack/head.rb:9:in call' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/showexceptions.rb:21:incall' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:99:in call' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:inblock in call' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:1471:in synchronize' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:incall' /home/rbi/.rvm/gems/ruby-1.9.3-p327@rubycas/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in service' /home/rbi/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice' /home/rbi/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /home/rbi/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

I have try with password in plain text with :

class: CASServer::Authenticators::SQL database: adapter: mysql2 database: rubycas_user username: root password: coucou host: localhost user_table: users username_column: username password_column: password

and another one with encrypted password :

class: CASServer::Authenticators::SQLEncrypted database: adapter: mysql2 database: rubycas_interface username: root password: coucou host: localhost user_table: users username_column: login encrypt_function: 'user.crypted_password == Digest::SHA1.hexdigest("--#{user.salt}--#{@password}--")'

i got the same error for both undefined method "lenght"

one with the SQL adapter and the encrypted one with the SQLencrypted adapater.

Thanks a lot.

My password are stored in SHA1 into my rubycas_interface.

rbinsztock commented 11 years ago

well, i finally comment the line 56 into sql_encrypted.rb : #$LOG.debug "#{self.class}: [#{user_model}] " + "Connection pool size: #{user_model.connection_pool.instance_variable_get(:@checked_out).length}/#{user_model.connection_pool.instance_variable_get(:@connections).length}"

and it's work now!

jodyrodd commented 11 years ago

:@checked_out was removed from the connection pool object.

mitfik commented 11 years ago

Hi,

Thanks for reporting that. I also had that issue. I prepared fix for that but before merging I need to make sure if I understood it correctly.

As far as I understand it, we want to log here information about how many connections we have opened and what is the max pool size, right? Because if so, this code do not provide that anyway. It should be something like that:

 "Connection pool size: #{user_model.connection_pool.connections.length}/#{user_model.connection_pool.instance_variable_get(:@size).length}"

Is that correct?

jodyrodd commented 11 years ago

That is correct, though you just want to call:

#{user_model.connection_pool.instance_variable_get(:@size)

Calling length on @size is undefined.

mitfik commented 11 years ago

Yes, good point, somehow I miss that one. Ok so I will prepare fix for that.

Thanks for review.