Fix: can't login when login or dn is in UTF-8 #87

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
4 participants
@graudeejs

I wrote simple patch to fix issue, when some data (login or dn) is in UTF-8.
Without this patch you won't be able to login in this case.

For example I had situation when devise_ldap_authenticatable tried and failed with cn=graudējs,dc=example,dc=com or cn=graudeejs,ou=piemērs,dc=example,dc=com

To avoid problems you need to force BINARY encoding for data that you send to ldap

@stevenyxu

This comment has been minimized.

Show comment Hide comment
@stevenyxu

stevenyxu Jun 4, 2012

Collaborator

Thanks for the patch! A couple questions.

  1. have you considered 1.8 compatibility? afaik, String#force_encoding is 1.9 only.
  2. have you identified the fundamental flaw that prevents you from sending strings encoded in UTF-8 over the wire? I get the impression that, if this is indeed a library issue, it may well take place at the net/ldap layer instead of at ours. That's not to rule out the appropriateness of a fix here, but I'd just like to understand if it's a flaw in our code that's causing this.
  3. why are you force encoding rather than transcoding via #encode?

Thanks for the submitting the patch. I look forward to merging it so others can enjoy it once we resolve the compatibility issue and once I educate myself a bit more over the methodology and rationale.

Collaborator

stevenyxu commented Jun 4, 2012

Thanks for the patch! A couple questions.

  1. have you considered 1.8 compatibility? afaik, String#force_encoding is 1.9 only.
  2. have you identified the fundamental flaw that prevents you from sending strings encoded in UTF-8 over the wire? I get the impression that, if this is indeed a library issue, it may well take place at the net/ldap layer instead of at ours. That's not to rule out the appropriateness of a fix here, but I'd just like to understand if it's a flaw in our code that's causing this.
  3. why are you force encoding rather than transcoding via #encode?

Thanks for the submitting the patch. I look forward to merging it so others can enjoy it once we resolve the compatibility issue and once I educate myself a bit more over the methodology and rationale.

@graudeejs

This comment has been minimized.

Show comment Hide comment
@graudeejs

graudeejs Jun 4, 2012

  1. No. Sorry didn't even thought about it. We use 1.9 only.
  2. Actually you're right, the flaw is more like in net/ldap, I have Class which is syncing users from/to ldap and all fields that have UTF-8 need to be forced to be BINARY before sending, and to UTF-8 when they are received. Perhaps net/ldap should be patched instead.
  3. I'm pretty new to Ruby. Google told me about force_encoding, didn't know about #encode.
  1. No. Sorry didn't even thought about it. We use 1.9 only.
  2. Actually you're right, the flaw is more like in net/ldap, I have Class which is syncing users from/to ldap and all fields that have UTF-8 need to be forced to be BINARY before sending, and to UTF-8 when they are received. Perhaps net/ldap should be patched instead.
  3. I'm pretty new to Ruby. Google told me about force_encoding, didn't know about #encode.
@kwent

This comment has been minimized.

Show comment Hide comment
@kwent

kwent Jun 15, 2012

Pull request very helpful. I clone @graudeejs repository and users login with non latin characters works now !

You have to implements this as soon as possible in the official repo...

kwent commented Jun 15, 2012

Pull request very helpful. I clone @graudeejs repository and users login with non latin characters works now !

You have to implements this as soon as possible in the official repo...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment