rubycas/rubycas-server — Issue #72: Error when SQLAuthlogic authenticator has no encryptor_options
Author: bitaxis
Created: 2011-12-01 06:54:06+00:00
State: open

I have configured rubycas-server to use the Authlogic authenticator. I found that in ```config.yml```, if I don't specify any ```encryptor_options``` in the ```authenticator``` section, then ```CASServer::Authenticators::SQLAuthlogic#validate``` errors out with the following:

NoMethodError - undefined method `each' for nil:NilClass:
/home/bitaxis/.rvm/gems/ruby-1.9.2-p290/gems/rubycas-server-1.0.1/lib/casserver/authenticators/sql_authlogic.rb:69:in `validate'
/home/bitaxis/.rvm/gems/ruby-1.9.2-p290/gems/rubycas-server-1.0.1/lib/casserver/server.rb:444:in `block (2 levels) in '
/home/bitaxis/.rvm/gems/ruby-1.9.2-p290/gems/rubycas-server-1.0.1/lib/casserver/server.rb:436:in `each'
/home/bitaxis/.rvm/gems/ruby-1.9.2-p290/gems/rubycas-server-1.0.1/lib/casserver/server.rb:436:in `block in '

The reason is simple, as ```@options[:encryptor_options]``` evaluates to ```nil``` when no ```encryptor_options``` are specified.

One fix is modifying line 69 to be as follows:

```ruby
(@options[:encryptor_options] || []).each do |name, value|
```

I've tested this fix locally, and it works fine.