ask : Make a second-level auth

45 views
Skip to first unread message

Bino Oetomo

unread,
Feb 21, 2013, 5:31:39 AM2/21/13
to Django users
Dear All.

I try to write what I call as 'l2auth' or '2nd Level Auth'
it's :
1. because my application will be co-use by some 'company'
2. because I want to delegate user administration to each company
3. I want user login with username format as user@company (it is not
an email)
4. Basically a copy-paste-modify from django auth.

I made a pastebin of the app's models at http://pastebin.com/6iqCXJY6
and this is what syncdb generate : http://oi50.tinypic.com/2rlz18p.jpg

This is How I 'register' the my backend in settings.py
-------START----------
AUTHENTICATION_BACKENDS = ('l2auth.backends.L2Backend',
'django.contrib.auth.backends.ModelBackend',
)
--------STOP----------

And this is my backend.py at http://pastebin.com/u1WVPV8s


I try to login : http://oi47.tinypic.com/20hx1sj.jpg
and it's failed : http://oi48.tinypic.com/35kv89c.jpg

Next I do a test from django shell --> http://pastebin.com/C0Q7v0u5

Question :
1. Did I missed somethings ? what is it ?
2. Why the l2auth_l2user.password field did not hashed ?

I realy appreciate any enlightment, clue, etc etc.

Sincerely
-bino-

Bino Oetomo

unread,
Feb 22, 2013, 12:10:28 AM2/22/13
to Django users

Respond to my own post

Password encryption is fix,

But authentication result different between sheel and we.
I Post the problem at https://groups.google.com/group/django-users/browse_thread/thread/d3c508ce2a0f2dec

Nikolas Stevenson-Molnar

unread,
Feb 22, 2013, 2:17:13 PM2/22/13
to django...@googlegroups.com
I don't think it's necessary to duplicate the User model to accomplish
what you want. Instead, you could write a model with the extra data you
need, relate that to the built-in User model as a one-to-one
relationship, and then write a custom auth backend which looks up the
user using a field in your custom model.

_Nik

Bino Oetomo

unread,
Feb 22, 2013, 8:17:51 PM2/22/13
to Django users
Dear Nikolas and all
I really appreciate your response.

On Feb 23, 2:17 am, Nikolas Stevenson-Molnar <nik.mol...@consbio.org>
wrote:
> I don't think it's necessary to duplicate the User model to accomplish
> what you want. Instead, you could write a model with the extra data you
> need, relate that to the built-in User model as a one-to-one
> relationship, and then write a custom auth backend which looks up the
> user using a field in your custom model.
>
Yes I can do that. But it'll means that I need to set their user-
administrator to have add/change/delete right to the core User
model ..... cmiiw.

Sincerely
-bino-
Reply all
Reply to author
Forward
0 new messages