Tuesday, 15 March 2011

ruby - checking groups at runtime with devise and devise_ldap_authenticatable -


When I do not care about what they are grouping, just working fine can get this devise_ldap_authenticatable LDAP connects whether or not the user authenticates the signature under the scheme. But I want to give only a few members who are apart from one or several specific groups. I have received a post on this question:

(Mani is a one for perfection)

I am asking wrong questions to think. I think that I want to know how to devise (and devise_ldap_authenticatable data stored where I probably do not give it to them at that time but can peep into my array of memberOf and check the groups for myself in the code And then there is there anywhere on the net hows this? None of my googling has changed, but a ldap or not being devious pro I'm guessing my word suck. That I can only remember the way to do this, the closest I think can be that I am able to see help (although I have read, in this case there is very little understanding about me, here on the readmeem its Part:

About ldap inquiries, is this the case?)

You can do this with callback or recognition on the user (or equivalent) model.

  before_create? User_is_not_member_of_specified_group Private Def user_is_not_member_of_specified_group member_of = testamentary :: LdapAdapter.get_ldap_param (self.username, "memberOf") end-member_of test   

Asked by test for your groups of member groups Is a method to give true / false returns based on the

will: :: LdapAdapter.get_ldap_param (self.username, "memberOf") devise_ldap_authenticatable One way is that an array of member groups will return. You want to run your group test on this array.

If you use verification, you can specify error message for unsuccessful users in the trial. Hope this will be helpful.

Edit

Another way to handle it is by modifying your gem redirection and error message by authorized? in the form Devise :: LdapAdapter :: LdapConnect (). This will look like this:

  Devise :: LdapAdapter :: LdapConnect.class_eval do def user_group_test member_of = self.ldap_param_value ("memberOf") test member_of # Is your group testing method ending authorized? DeviseLdapAuthenticatable :: Logger.send ("Authorize user # {dn}") if! User_group_test DeviseLdapAuthenticatable :: Logger.send ("Authorized notify that custom authentication fails.") False elsif return! Authenticated? DeviseLadapAuthenticableable :: Logger.send ("Not authenticated because it is not authenticated.") Back to the wrong Elsif! In_required_groups? DeviseLadapAuthenticableable :: Logger.send ("Not required because in the group is not required.") Back to the wrong Elsif! Is_requard_team? DeviseLadapAuthenticable :: Logger.send ("Not authorized because it does not have the required attribute.") Returns and returns the correct end ending term   

You want to put it in a custom initializer file config / initializers .

No comments:

Post a Comment