Re: How to make the username "case insensitive"

YanQian <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
> Date: Mon, 31 Mar 2014 09:50:18 +0200
> From: [email protected]
> To: [email protected]
> CC: [email protected]
> Subject: Re: [Roundup-users] How to make the username "case insensitive"
> 
> 
> You can add an auditor to roundup (in the detectors directory of your
> tracker instance) that converts all usernames to lowercase,
> e.g.(untested):
> 
> def username_lowercase(db, cl, nodeid, new_values):
>     if 'username' in new_values:
>         new_values['username'] = new_values['username'].lower()
> def init(db):
>     db.user.audit("set", username_lowercase)
>     db.user.audit("create", username_lowercase)
> 
> The second part is to change your ldap authentication modification for
> roundup to always convert the username to lowercase. I guess you made a
> modification to your roundup instance for ldap login or does RedHat come
> with such a modification?
> 
> Of course after this modification you should change all existing
> usernames to lowercase, e.g., by script(again untested):
> 
> from roundup import instance
> tracker = instance.open('.')
> db = tracker.open ('admin')
> 
> for id in db.user.getnodeids(retired=False):
>     db.user.set(id, username=db.user.get(id, 'username').lower())
> 
> 
> So I guess we won't need any modifications to roundup core for this
> usage scenario.
> 
> Ralf
> -- 
> Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
> Open Source Consulting                  www:   http://www.runtux.com
> Reichergasse 131, A-3411 Weidling       email: [email protected]
> allmenda.com member                     email: [email protected]

Thank you for your hints! Since I am not familiar with python programming, I did some rough hack that get it working, base on your thoughts.
I added two lines to the original LDAPLogin2 extention.http://www.roundup-tracker.org/cgi-bin/moin.cgi/LDAPLogin2
1, I added "username=username.lower()" under line 184, it looks like below:
def ldap_login(self, username='', password=''):        """Perform a login against LDAP."""        self.auth_method = 'ldap'        username=username.lower()    #this is the line I added.
2, I added "self.client.user = self.client.user.lower()" before line 420, it looks like below:
try:            self.client.user = self.client.user.lower()    #this is the line I added.            self.client.userid = self.db.user.lookup(self.client.user)            # update the empty values with LDAP values
Of cource, as you said, I need also change the existing ldap usernames in the roundup to lower case.After these are done, username of any new ldap users will be lower case, and They can login with both Upper or lower case usernames.

------------------------------------------------------------------------------

_______________________________________________
Roundup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/roundup-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.