Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to authenticate users using rubycas-server with multi-field?

I used rubycas-server to build an sso systems, using devise to do the user's system, but now my question is, rubycas-server only one field like 'email' , I want to use 'email' / 'tel' / 'nickname' for user login. no more info in wiki

authenticator:
 class: CASServer::Authenticators::SQLBcrypt
 database:
   adapter: mysql2
   database: xxxx
   username: root
   password: xxxx
   host: localhost
 user_table: users
 username_column: email # tel/nickname
 password_column: encrypted_password

sorry about my poor English! help me, thanks very much!

like image 930
scottxu Avatar asked Mar 26 '26 08:03

scottxu


1 Answers

I'm affraid it woulnd't be possible. As can be seen in the official repository, this authenticator just matches given column name with user name:

  def matching_users
    results = user_model.find(:all, :conditions => ["#{username_column} = ?", @username])
    results.select { |user| BCrypt::Password.new(user.send(password_column.to_sym)) == @password }
  end

For your case the best idea would be to write custom authenticator that matches email/tel/nickname. This is however very tough login name though, consider some more user friendly.

like image 141
blelump Avatar answered Mar 28 '26 00:03

blelump



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!