How to use password hasher snippet in Django?

2015-01-21 Thread Supermario


I am trying to move Druap 7 site to django 1.7 without invalidating user 
passwords, and this proved to be daunting.

Fortunately, I have found this 

 SO 
question and this  hashing 
snippet but there is no documentation and as a newbie to django, I have no 
clue how to integrate the snippet into my project.

So greatly appreciate your help about this.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3ed080a2-0a71-4e8d-afe5-c4d953746d24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use password hasher snippet in Django?

2015-01-22 Thread Supermario
Many thanks for your help Thomas. Indeed I am in the middle of big escape 
effort to get the heck away from Drupal.

I tested your snippet in the shell and DrupalPasswordHasher hashes 
perfectly well there. 

However, when I integrate the hash into my project as per your explanation, 
django-registration module still refuse to authenticate old drupal users. 

Any ideas on how to troubleshoot this?
 
Cheers

On Thursday, January 22, 2015 at 4:12:07 AM UTC+1, Thomas wrote:
>
> On Jan 21, 2015, at 3:07 PM, Supermario > 
> wrote:
>
> I am trying to move Druap 7 site to django 1.7 without invalidating user 
> passwords, and this proved to be daunting.
>
> Fortunately, I have found this 
> <http://stackoverflow.com/questions/9876700/migrate-passwords-from-drupal-7-to-django>
>  SO 
> question and this <https://djangosnippets.org/snippets/3030/> hashing 
> snippet but there is no documentation and as a newbie to django, I have no 
> clue how to integrate the snippet into my project.
>
>
> I’ve enclosed a password processor I used in the past for a Drupal 
> conversion; the gist came from a web search and is attributed in the code 
> but has some minor fixes. I’ve actually included two processors, with one 
> disabled with “XXX” in the function name. I think I had trouble getting 
> that one to work.
>
> You can create a “drupal” app, which just has an __init__.py and this file 
> as hashers.py
>
> You will want to add “drupal” as one of your apps, then also define the 
> following in your settings.py:
>
> PASSWORD_HASHERS = (
> 'django.contrib.auth.hashers.PBKDF2PasswordHasher',
> 'drupal.hashers.DrupalPasswordHasher',
> 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
> 'django.contrib.auth.hashers.BCryptPasswordHasher',
> )
>
> Since you are starting fresh, you can include only the recommended best 
> password hasher from Django plus the drupal hasher. And if you prefer you 
> could fold the hashers.py file into another existing app in your project.
>
> Also, the structure of your project may be a bit different from mine since 
> the recommended Django layout has changed a bit over the last few versions.
>
> hth, and enjoy getting the heck away from Drupal hell…
>
> - Tom
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aa905c13-b9b1-42ba-b0c2-4127d079a8c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django UnicodeDecodeError at /admin/login/

2015-01-27 Thread Supermario
I try to implement this  hasher 
in order to be able to authenticate user who are imported from drupal 7. 

So I put the hasher in the settings.py as follows:


PASSWORD_HASHERS = (

'myproj.drupal_hasher.DrupalPasswordHasher', #drupal hasher
 
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',

'django.contrib.auth.hashers.BCryptPasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher',
'django.contrib.auth.hashers.MD5PasswordHasher',
'django.contrib.auth.hashers.CryptPasswordHasher',
 ) 



However it does not authenticate imported users from drupal and for users 
who are created in Django I get:

'ascii' codec can't decode byte 0xcf in position 0: ordinal not in 
range(128)




Here is the trackback:


Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/auth/

Django Version: 1.7.3
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'article',
 'photo',
 'debug_toolbar',
 'django_markdown',
 'haystack')
Installed Middleware:
(u'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/core/handlers/base.py"
 
in get_response
  111. response = wrapped_callback(request, *
callback_args, **callback_kwargs)
File "/home/mario/myproj/myauth/views.py" in auth_view
  16. user = auth.authenticate(username=username, password=password)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py"
 
in authenticate
  60. user = backend.authenticate(**credentials)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/backends.py"
 
in authenticate
  17. if user.check_password(password):
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
 
in check_password
  237. return check_password(raw_password, self.password, setter
)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py"
 
in check_password
  63. setter(password)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
 
in setter
  235. self.set_password(raw_password)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
 
in set_password
  227. self.password = make_password(raw_password)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py"
 
in make_password
  85. return hasher.encode(password, salt)
File "/home/mario/myproj/myproj/drupal_hasher.py" in encode
  81. encoded_hash = self._apply_hash(password, self._digests[
digest], settings)
File "/home/mario/myproj/myproj/drupal_hasher.py" in _apply_hash
  68. password_hash = digest(password_hash + password).
digest()

Exception Type: UnicodeDecodeError at /auth/
Exception Value: 'ascii' codec can't decode byte 0xcf in position 0: 
ordinal not in range(128)


All source and destination database tables are converted to utf8_unicode_ci.

I am stock on this problem for days so really appreciate your help. 



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5dd15420-01d5-4b1f-adf0-af3ee585ba73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


What is the most usable forum app for Django 1.7?

2015-02-15 Thread Supermario
I am looking for a forum app to integrate into my project which is going to 
be quite high-traffic. So I am looking for a mature forum app. I know there 
are a couple of forum apps listed here:

https://www.djangopackages.com/grids/g/forums/

By 'usable' I mean: 

- Easy to integrate into existing project
- Tested in production environment and showed to be trustworthy
- Has security and performance in mind 
- Has basic functionalities of conventional bulletin-boards 

I have not tried them all, but it appears to me that some are pretty 
out-dated or even abandoned. And some are not production ready yet. 

So I appreciate your hints to choose the best. 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2e370eb8-a89d-4b97-8b5c-19b64adc095e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.