[web2py] Re: Login manually
Hello, Massimo gave me some clues and I think I've found the solution: I was debugging my code and saw that this line: db.auth_user.password.validate(password) returns a 2-tupla: (crypter password, error) In my code (and in all examples I've seen through Internet), this 2-tuple is stored in the database. So what you see in the database is: |pbkdf2(1000,20,sha512)$90718911d716ab40$9ab041ebf5432bb9432cef16165865d320123e0a|None| The password and the error are stored in the same field. Everything is ok, but I am storing the wrong thing. So when I try to log in, the password field is not a password but a 2-tuple, it's strange to web2py and it crashes. What I've done is: passwordAux = db.auth_user.password.validate(password) if passwordAux[1] != None ...insert(..., password=password[0]) And now, this is working. Now, what is stored in the databse is the password only: pbkdf2(1000,20,sha512)$90718911d716ab40$9ab041ebf5432bb9432cef16165865d320123e0a and the log in works perfectly. Kind regards! El jueves, 20 de diciembre de 2012 20:10:41 UTC+1, Wonton escribió: If you don't mind I could send you my project to your email directly. El jueves, 20 de diciembre de 2012 16:14:12 UTC+1, Massimo Di Pierro escribió: If your data is not confidential, any chance you send me your application? To me this looks like corrupted data in database as if the password field was at some pointed treated as type='list:string' and than changed back to type='password'. Is it possible? Massimo On Wednesday, 19 December 2012 11:28:15 UTC-6, Wonton wrote: Yes, of course. This is my ticket: Error ticket for dianaappv1 Ticket ID 127.0.0.1.2012-12-19.18-24-12.5d2b292c-7e9a-4281-a9f7-bb9aa17bbd0c type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) Versión web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable') Python Python 2.7.1: /usr/bin/python Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. Traceback (most recent call last): File /Applications/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 101, in module File /Applications/web2py/gluon/globals.py, line 188, in lambda self._caller = lambda f: f() File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 27, in public_call return servicios_publicos() File /Applications/web2py/gluon/tools.py, line 4387, in __call__ return self.serve_json(request.args[1:]) File /Applications/web2py/gluon/tools.py, line 4197, in serve_json s = universal_caller(self.json_procedures[args[0]], *args[1:], **d) File /Applications/web2py/gluon/tools.py, line 3889, in universal_caller return f(**arg_dict) File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 65, in login user = auth.login_bare(usuario, password) File /Applications/web2py/gluon/tools.py, line 1789, in login_bare if not user.registration_key and password == user[passfield]: File /Applications/web2py/gluon/validators.py, line 2636, in __eq__ h = simple_hash(self.password, key, salt, digest_alg) File /Applications/web2py/gluon/utils.py, line 74, in simple_hash h = hashlib.new(digest_alg) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 121, in __hash_new return __get_builtin_constructor(name)(string) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 88, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type |pbkdf2(1000,20,sha512) Error snapshot [image: help] type 'exceptions.ValueError'(unsupported hash type |pbkdf2(1000,20,sha512)) inspect attributes Frames - *File /Applications/web2py/gluon/restricted.py in restricted at line 212* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in module at line 101* código argumentos variables - *File /Applications/web2py/gluon/globals.py in lambda at line 188* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in public_call at line 27* código argumentos variables - *File /Applications/web2py/gluon/tools.py in __call__ at line 4387* código argumentos variables - *File /Applications/web2py/gluon/tools.py in serve_json at line 4197*
[web2py] Re: Login manually
Sorry, I made a mistake. Where I say: passwordAux = db.auth_user.password.validate(password) if passwordAux[1] *!=* None ...insert(..., password=password[0]) I should say: passwordAux = db.auth_user.password.validate(password) if passwordAux[1] *==* None ...insert(..., password=password[0]) El lunes, 24 de diciembre de 2012 10:42:13 UTC+1, Wonton escribió: Hello, Massimo gave me some clues and I think I've found the solution: I was debugging my code and saw that this line: db.auth_user.password.validate(password) returns a 2-tupla: (crypter password, error) In my code (and in all examples I've seen through Internet), this 2-tuple is stored in the database. So what you see in the database is: |pbkdf2(1000,20,sha512)$90718911d716ab40$9ab041ebf5432bb9432cef16165865d320123e0a|None| The password and the error are stored in the same field. Everything is ok, but I am storing the wrong thing. So when I try to log in, the password field is not a password but a 2-tuple, it's strange to web2py and it crashes. What I've done is: passwordAux = db.auth_user.password.validate(password) if passwordAux[1] != None ...insert(..., password=password[0]) And now, this is working. Now, what is stored in the databse is the password only: pbkdf2(1000,20,sha512)$90718911d716ab40$9ab041ebf5432bb9432cef16165865d320123e0a and the log in works perfectly. Kind regards! El jueves, 20 de diciembre de 2012 20:10:41 UTC+1, Wonton escribió: If you don't mind I could send you my project to your email directly. El jueves, 20 de diciembre de 2012 16:14:12 UTC+1, Massimo Di Pierro escribió: If your data is not confidential, any chance you send me your application? To me this looks like corrupted data in database as if the password field was at some pointed treated as type='list:string' and than changed back to type='password'. Is it possible? Massimo On Wednesday, 19 December 2012 11:28:15 UTC-6, Wonton wrote: Yes, of course. This is my ticket: Error ticket for dianaappv1 Ticket ID 127.0.0.1.2012-12-19.18-24-12.5d2b292c-7e9a-4281-a9f7-bb9aa17bbd0c type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) Versión web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable') Python Python 2.7.1: /usr/bin/python Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. Traceback (most recent call last): File /Applications/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 101, in module File /Applications/web2py/gluon/globals.py, line 188, in lambda self._caller = lambda f: f() File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 27, in public_call return servicios_publicos() File /Applications/web2py/gluon/tools.py, line 4387, in __call__ return self.serve_json(request.args[1:]) File /Applications/web2py/gluon/tools.py, line 4197, in serve_json s = universal_caller(self.json_procedures[args[0]], *args[1:], **d) File /Applications/web2py/gluon/tools.py, line 3889, in universal_caller return f(**arg_dict) File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 65, in login user = auth.login_bare(usuario, password) File /Applications/web2py/gluon/tools.py, line 1789, in login_bare if not user.registration_key and password == user[passfield]: File /Applications/web2py/gluon/validators.py, line 2636, in __eq__ h = simple_hash(self.password, key, salt, digest_alg) File /Applications/web2py/gluon/utils.py, line 74, in simple_hash h = hashlib.new(digest_alg) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 121, in __hash_new return __get_builtin_constructor(name)(string) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 88, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type |pbkdf2(1000,20,sha512) Error snapshot [image: help] type 'exceptions.ValueError'(unsupported hash type |pbkdf2(1000,20,sha512)) inspect attributes Frames - *File /Applications/web2py/gluon/restricted.py in restricted at line 212* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in module at line 101* código argumentos variables - *File /Applications/web2py/gluon/globals.py in lambda at line 188*
[web2py] Re: Login manually
If your data is not confidential, any chance you send me your application? To me this looks like corrupted data in database as if the password field was at some pointed treated as type='list:string' and than changed back to type='password'. Is it possible? Massimo On Wednesday, 19 December 2012 11:28:15 UTC-6, Wonton wrote: Yes, of course. This is my ticket: Error ticket for dianaappv1 Ticket ID 127.0.0.1.2012-12-19.18-24-12.5d2b292c-7e9a-4281-a9f7-bb9aa17bbd0c type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) Versión web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable') Python Python 2.7.1: /usr/bin/python Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. Traceback (most recent call last): File /Applications/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 101, in module File /Applications/web2py/gluon/globals.py, line 188, in lambda self._caller = lambda f: f() File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 27, in public_call return servicios_publicos() File /Applications/web2py/gluon/tools.py, line 4387, in __call__ return self.serve_json(request.args[1:]) File /Applications/web2py/gluon/tools.py, line 4197, in serve_json s = universal_caller(self.json_procedures[args[0]], *args[1:], **d) File /Applications/web2py/gluon/tools.py, line 3889, in universal_caller return f(**arg_dict) File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 65, in login user = auth.login_bare(usuario, password) File /Applications/web2py/gluon/tools.py, line 1789, in login_bare if not user.registration_key and password == user[passfield]: File /Applications/web2py/gluon/validators.py, line 2636, in __eq__ h = simple_hash(self.password, key, salt, digest_alg) File /Applications/web2py/gluon/utils.py, line 74, in simple_hash h = hashlib.new(digest_alg) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 121, in __hash_new return __get_builtin_constructor(name)(string) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 88, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type |pbkdf2(1000,20,sha512) Error snapshot [image: help] type 'exceptions.ValueError'(unsupported hash type |pbkdf2(1000,20,sha512)) inspect attributes Frames - *File /Applications/web2py/gluon/restricted.py in restricted at line 212* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in module at line 101* código argumentos variables - *File /Applications/web2py/gluon/globals.py in lambda at line 188* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in public_call at line 27* código argumentos variables - *File /Applications/web2py/gluon/tools.py in __call__ at line 4387* código argumentos variables - *File /Applications/web2py/gluon/tools.py in serve_json at line 4197* código argumentos variables - *File /Applications/web2py/gluon/tools.py in universal_caller at line 3889* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in login at line 65* código argumentos variables - *File /Applications/web2py/gluon/tools.py in login_bare at line 1789* código argumentos variables - *File /Applications/web2py/gluon/validators.py in __eq__ at line 2636* código argumentos variables - *File /Applications/web2py/gluon/utils.py in simple_hash at line 74* código argumentos variables - *File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py in __hash_new at line 121* código argumentos variables - *File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py in __get_builtin_constructor at line 88* código argumentos variables Function argument list (name='|pbkdf2(1000,20,sha512)') Code listing 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. if bs ==
[web2py] Re: Login manually
If you don't mind I could send you my project to your email directly. El jueves, 20 de diciembre de 2012 16:14:12 UTC+1, Massimo Di Pierro escribió: If your data is not confidential, any chance you send me your application? To me this looks like corrupted data in database as if the password field was at some pointed treated as type='list:string' and than changed back to type='password'. Is it possible? Massimo On Wednesday, 19 December 2012 11:28:15 UTC-6, Wonton wrote: Yes, of course. This is my ticket: Error ticket for dianaappv1 Ticket ID 127.0.0.1.2012-12-19.18-24-12.5d2b292c-7e9a-4281-a9f7-bb9aa17bbd0c type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) Versión web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable') Python Python 2.7.1: /usr/bin/python Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. Traceback (most recent call last): File /Applications/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 101, in module File /Applications/web2py/gluon/globals.py, line 188, in lambda self._caller = lambda f: f() File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 27, in public_call return servicios_publicos() File /Applications/web2py/gluon/tools.py, line 4387, in __call__ return self.serve_json(request.args[1:]) File /Applications/web2py/gluon/tools.py, line 4197, in serve_json s = universal_caller(self.json_procedures[args[0]], *args[1:], **d) File /Applications/web2py/gluon/tools.py, line 3889, in universal_caller return f(**arg_dict) File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 65, in login user = auth.login_bare(usuario, password) File /Applications/web2py/gluon/tools.py, line 1789, in login_bare if not user.registration_key and password == user[passfield]: File /Applications/web2py/gluon/validators.py, line 2636, in __eq__ h = simple_hash(self.password, key, salt, digest_alg) File /Applications/web2py/gluon/utils.py, line 74, in simple_hash h = hashlib.new(digest_alg) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 121, in __hash_new return __get_builtin_constructor(name)(string) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 88, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type |pbkdf2(1000,20,sha512) Error snapshot [image: help] type 'exceptions.ValueError'(unsupported hash type |pbkdf2(1000,20,sha512)) inspect attributes Frames - *File /Applications/web2py/gluon/restricted.py in restricted at line 212* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in module at line 101* código argumentos variables - *File /Applications/web2py/gluon/globals.py in lambda at line 188* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in public_call at line 27* código argumentos variables - *File /Applications/web2py/gluon/tools.py in __call__ at line 4387* código argumentos variables - *File /Applications/web2py/gluon/tools.py in serve_json at line 4197* código argumentos variables - *File /Applications/web2py/gluon/tools.py in universal_caller at line 3889* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in login at line 65* código argumentos variables - *File /Applications/web2py/gluon/tools.py in login_bare at line 1789* código argumentos variables - *File /Applications/web2py/gluon/validators.py in __eq__ at line 2636* código argumentos variables - *File /Applications/web2py/gluon/utils.py in simple_hash at line 74* código argumentos variables - *File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py in __hash_new at line 121* código argumentos variables - *File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py in __get_builtin_constructor at line 88* código argumentos variables Function argument list
[web2py] Re: Login manually
Can you please show me the complete traceback? I cannot reproduce this and I this error is not generated from a web2py function. On Tuesday, 18 December 2012 11:11:51 UTC-6, Massimo Di Pierro wrote: Can I see you models? Are you changing the validator for db.auth_user.password? Your error says: type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) I do not understand where | in |pbkdf2 would come from. On Tuesday, 18 December 2012 09:33:12 UTC-6, Wonton wrote: Hi Massimo!! I'm using version 2.2.1 (2012-10-21 16:57:04) stable. I dowloaded it last week. El martes, 18 de diciembre de 2012 16:26:29 UTC+1, Massimo Di Pierro escribió: Which web2py version? The error suggests you are using an older web2py version with newly created database of records. Massimo On Monday, 17 December 2012 14:59:02 UTC-6, Wonton wrote: Hello everyone, I'm developing a backend site with web2py. I have 2 web services, one to register a user and a second one to login the user. This is the first one: def register(user, email, password): db.auth_user.insert(username=user, email=email, password=db.auth_user.password.validate(password)) ... return 'OK' It's working ok and the users are created without problem. This is the second one: def login(user, password): response = auth.login_bare(user, password) if not response: message = 'Error' else: message = 'OK' return message With this service I have the following error: type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) I've tried to find any solution to this problem without success. Any of you has any idea of what is happening? Thank you very much and kind regards! Wonton --
[web2py] Re: Login manually
Yes, of course. This is my ticket: Error ticket for dianaappv1 Ticket ID 127.0.0.1.2012-12-19.18-24-12.5d2b292c-7e9a-4281-a9f7-bb9aa17bbd0c type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) Versión web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable') Python Python 2.7.1: /usr/bin/python Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. Traceback (most recent call last): File /Applications/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 101, in module File /Applications/web2py/gluon/globals.py, line 188, in lambda self._caller = lambda f: f() File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 27, in public_call return servicios_publicos() File /Applications/web2py/gluon/tools.py, line 4387, in __call__ return self.serve_json(request.args[1:]) File /Applications/web2py/gluon/tools.py, line 4197, in serve_json s = universal_caller(self.json_procedures[args[0]], *args[1:], **d) File /Applications/web2py/gluon/tools.py, line 3889, in universal_caller return f(**arg_dict) File /Applications/web2py/applications/dianaappv1/controllers/default.py https://127.0.0.1:8000/admin/default/edit/dianaappv1/controllers/default.py, line 65, in login user = auth.login_bare(usuario, password) File /Applications/web2py/gluon/tools.py, line 1789, in login_bare if not user.registration_key and password == user[passfield]: File /Applications/web2py/gluon/validators.py, line 2636, in __eq__ h = simple_hash(self.password, key, salt, digest_alg) File /Applications/web2py/gluon/utils.py, line 74, in simple_hash h = hashlib.new(digest_alg) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 121, in __hash_new return __get_builtin_constructor(name)(string) File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py, line 88, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type |pbkdf2(1000,20,sha512) Error snapshot [image: help] type 'exceptions.ValueError'(unsupported hash type |pbkdf2(1000,20,sha512)) inspect attributes Frames - *File /Applications/web2py/gluon/restricted.py in restricted at line 212* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in module at line 101* código argumentos variables - *File /Applications/web2py/gluon/globals.py in lambda at line 188* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in public_call at line 27* código argumentos variables - *File /Applications/web2py/gluon/tools.py in __call__ at line 4387* código argumentos variables - *File /Applications/web2py/gluon/tools.py in serve_json at line 4197* código argumentos variables - *File /Applications/web2py/gluon/tools.py in universal_caller at line 3889* código argumentos variables - *File /Applications/web2py/applications/dianaappv1/controllers/default.py in login at line 65* código argumentos variables - *File /Applications/web2py/gluon/tools.py in login_bare at line 1789* código argumentos variables - *File /Applications/web2py/gluon/validators.py in __eq__ at line 2636* código argumentos variables - *File /Applications/web2py/gluon/utils.py in simple_hash at line 74* código argumentos variables - *File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py in __hash_new at line 121* código argumentos variables - *File /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py in __get_builtin_constructor at line 88* código argumentos variables Function argument list (name='|pbkdf2(1000,20,sha512)') Code listing 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. if bs == '512': return _sha512.sha512 elif bs == '384': return _sha512.sha384 raise ValueError('unsupported hash type %s' % name) def __get_openssl_constructor(name): try: Variables name '|pbkdf2(1000,20,sha512)' builtinValueError type 'exceptions.ValueError' Context locals request session response In file: /Applications/web2py/applications/dianaappv1/controllers/default.py 1. 2. 3. 4. 5. 6. 7.
[web2py] Re: Login manually
Which web2py version? The error suggests you are using an older web2py version with newly created database of records. Massimo On Monday, 17 December 2012 14:59:02 UTC-6, Wonton wrote: Hello everyone, I'm developing a backend site with web2py. I have 2 web services, one to register a user and a second one to login the user. This is the first one: def register(user, email, password): db.auth_user.insert(username=user, email=email, password=db.auth_user.password.validate(password)) ... return 'OK' It's working ok and the users are created without problem. This is the second one: def login(user, password): response = auth.login_bare(user, password) if not response: message = 'Error' else: message = 'OK' return message With this service I have the following error: type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) I've tried to find any solution to this problem without success. Any of you has any idea of what is happening? Thank you very much and kind regards! Wonton --
[web2py] Re: Login manually
Hi Massimo!! I'm using version 2.2.1 (2012-10-21 16:57:04) stable. I dowloaded it last week. El martes, 18 de diciembre de 2012 16:26:29 UTC+1, Massimo Di Pierro escribió: Which web2py version? The error suggests you are using an older web2py version with newly created database of records. Massimo On Monday, 17 December 2012 14:59:02 UTC-6, Wonton wrote: Hello everyone, I'm developing a backend site with web2py. I have 2 web services, one to register a user and a second one to login the user. This is the first one: def register(user, email, password): db.auth_user.insert(username=user, email=email, password=db.auth_user.password.validate(password)) ... return 'OK' It's working ok and the users are created without problem. This is the second one: def login(user, password): response = auth.login_bare(user, password) if not response: message = 'Error' else: message = 'OK' return message With this service I have the following error: type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) I've tried to find any solution to this problem without success. Any of you has any idea of what is happening? Thank you very much and kind regards! Wonton --
[web2py] Re: Login manually
Can I see you models? Are you changing the validator for db.auth_user.password? Your error says: type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) I do not understand where | in |pbkdf2 would come from. On Tuesday, 18 December 2012 09:33:12 UTC-6, Wonton wrote: Hi Massimo!! I'm using version 2.2.1 (2012-10-21 16:57:04) stable. I dowloaded it last week. El martes, 18 de diciembre de 2012 16:26:29 UTC+1, Massimo Di Pierro escribió: Which web2py version? The error suggests you are using an older web2py version with newly created database of records. Massimo On Monday, 17 December 2012 14:59:02 UTC-6, Wonton wrote: Hello everyone, I'm developing a backend site with web2py. I have 2 web services, one to register a user and a second one to login the user. This is the first one: def register(user, email, password): db.auth_user.insert(username=user, email=email, password=db.auth_user.password.validate(password)) ... return 'OK' It's working ok and the users are created without problem. This is the second one: def login(user, password): response = auth.login_bare(user, password) if not response: message = 'Error' else: message = 'OK' return message With this service I have the following error: type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) I've tried to find any solution to this problem without success. Any of you has any idea of what is happening? Thank you very much and kind regards! Wonton --
[web2py] Re: Login manually
Hi again Massimo! Since I've changed very few from the basic project I will paste my code here (sorry for my comments and variable names in Spanish, if you want I could translate the code) . This is my default.py file: servicios_publicos=Service() servicios_privados=Service() def public_call(): return servicios_publicos() @auth.requires_login() def private_call(): return servicios_privados() @servicios_publicos.json def registra(usuario, email, password): respuesta = {} estado = 'OK' mensaje = '' tipoError = 0 #Comprueba si hay otro usuario con el mismo nombre if db(db.auth_user.username == usuario).count() != 0: estado = 'Error' tipoError = 1 #Comprueba si hay otro usuario con el mismo email if db(db.auth_user.email == email).count() != 0: estado = 'Error' tipoError = tipoError + 2 #Registrar if estado == 'OK': db.auth_user.insert(username=usuario, email=email, password=db. auth_user.password.validate(password)) mensaje = 'El registro se ha realizado correctamente.' else: if tipoError == 1: mensaje = 'El usuario ya existe.' elif tipoError == 2: mensaje = 'El email ya existe.' else: mensaje = 'El usuario y el email ya existen.' respuesta['estado'] = estado respuesta['mensaje'] = mensaje return respuesta @servicios_publicos.json def login(usuario, password): respuesta = {} user = auth.login_bare(usuario, password) if not user: respuesta['estado'] = 'Error' respuesta['mensaje'] = 'Nombre de usuario o contraseña incorrecta' else: respuesta['estado'] = 'OK' respuesta['mensaje'] = 'Login correcto' return respuesta And this is my db.py: if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite') else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client())) ## by default give a view/generic.extension to all actions from localhost ## none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] ## (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' # ## Here is sample code if you need for ## - email capabilities ## - authentication (registration, login, logout, ... ) ## - authorization (role based authorization) ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) ## - old style crud actions ## (more options discussed in gluon/tools.py) # from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() ## create all tables needed by auth if not custom tables auth.define_tables(username=True, signature=False) ## configure email mail = auth.settings.mailer mail.settings.server = 'here comes my SMTP server' mail.settings.sender = 'here comes my email' mail.settings.login = 'here comes my email user/password' ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. ## register with janrain.com, write your domain:api_key in private/janrain.key from gluon.contrib.login_methods.rpx_account import use_janrain use_janrain(auth, filename='private/janrain.key') If it helps you, I'm using python 2.7.1 and I launch web2py with: python web2py.py -c server.crt -k server.key and this is the trace: Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), IMAP(imaplib) El martes, 18 de diciembre de 2012 18:11:51 UTC+1, Massimo Di Pierro escribió: Can I see you models? Are you changing the validator for db.auth_user.password? Your error says: type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512) I do not understand where | in |pbkdf2 would come from. On Tuesday, 18 December 2012 09:33:12 UTC-6, Wonton wrote: Hi Massimo!! I'm using version 2.2.1 (2012-10-21 16:57:04) stable. I dowloaded it last week. El martes, 18 de diciembre de 2012 16:26:29 UTC+1, Massimo Di Pierro escribió: Which web2py version? The error suggests you are using an older web2py version with newly created database of
[web2py] Re: Login manually
Can you please check something for me: python web2py.py -S yourappname -M rows = db(db.auth_user).select(db.auth_user.password) print 'check:', any(r.passwords.startswith('|') for r in rows): does it print check: true or check: false? Massimo On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote: Hi again Massimo! Since I've changed very few from the basic project I will paste my code here (sorry for my comments and variable names in Spanish, if you want I could translate the code) . This is my default.py file: servicios_publicos=Service() servicios_privados=Service() def public_call(): return servicios_publicos() @auth.requires_login() def private_call(): return servicios_privados() @servicios_publicos.json def registra(usuario, email, password): respuesta = {} estado = 'OK' mensaje = '' tipoError = 0 #Comprueba si hay otro usuario con el mismo nombre if db(db.auth_user.username == usuario).count() != 0: estado = 'Error' tipoError = 1 #Comprueba si hay otro usuario con el mismo email if db(db.auth_user.email == email).count() != 0: estado = 'Error' tipoError = tipoError + 2 #Registrar if estado == 'OK': db.auth_user.insert(username=usuario, email=email, password=db. auth_user.password.validate(password)) mensaje = 'El registro se ha realizado correctamente.' else: if tipoError == 1: mensaje = 'El usuario ya existe.' elif tipoError == 2: mensaje = 'El email ya existe.' else: mensaje = 'El usuario y el email ya existen.' respuesta['estado'] = estado respuesta['mensaje'] = mensaje return respuesta @servicios_publicos.json def login(usuario, password): respuesta = {} user = auth.login_bare(usuario, password) if not user: respuesta['estado'] = 'Error' respuesta['mensaje'] = 'Nombre de usuario o contraseña incorrecta' else: respuesta['estado'] = 'OK' respuesta['mensaje'] = 'Login correcto' return respuesta And this is my db.py: if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite') else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client())) ## by default give a view/generic.extension to all actions from localhost ## none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] ## (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' # ## Here is sample code if you need for ## - email capabilities ## - authentication (registration, login, logout, ... ) ## - authorization (role based authorization) ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) ## - old style crud actions ## (more options discussed in gluon/tools.py) # from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() ## create all tables needed by auth if not custom tables auth.define_tables(username=True, signature=False) ## configure email mail = auth.settings.mailer mail.settings.server = 'here comes my SMTP server' mail.settings.sender = 'here comes my email' mail.settings.login = 'here comes my email user/password' ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. ## register with janrain.com, write your domain:api_key in private/janrain.key from gluon.contrib.login_methods.rpx_account import use_janrain use_janrain(auth, filename='private/janrain.key') If it helps you, I'm using python 2.7.1 and I launch web2py with: python web2py.py -c server.crt -k server.key and this is the trace: Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), IMAP(imaplib) El martes, 18 de diciembre de 2012 18:11:51 UTC+1, Massimo Di Pierro escribió: Can I see you models? Are you changing the validator for db.auth_user.password? Your error says: type 'exceptions.ValueError' unsupported hash type |pbkdf2(1000,20,sha512)
[web2py] Re: Login manually
Well, I've executed again these sentences and this is what I've got: python web2py.py -S dianaappv1 -M web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2012 Version 2.2.1 (2012-10-21 16:57:04) stable Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), IMAP(imaplib) WARNING:web2py:import IPython error; use default python shell Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type help, copyright, credits or license for more information. (InteractiveConsole) rows = db(db.auth_user).select(db.auth_user.password) print 'check:', any(r.passwords.startswith('|') for r in rows): File console, line 1 print 'check:', any(r.passwords.startswith('|') for r in rows): ^ SyntaxError: invalid syntax print 'check:', any(r.passwords.startswith('|') for r in rows) Traceback (most recent call last): File console, line 1, in module File console, line 1, in genexpr AttributeError: 'Row' object has no attribute 'passwords' check: El martes, 18 de diciembre de 2012 20:55:06 UTC+1, Massimo Di Pierro escribió: Can you please check something for me: python web2py.py -S yourappname -M rows = db(db.auth_user).select(db.auth_user.password) print 'check:', any(r.passwords.startswith('|') for r in rows): does it print check: true or check: false? Massimo On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote: Hi again Massimo! Since I've changed very few from the basic project I will paste my code here (sorry for my comments and variable names in Spanish, if you want I could translate the code) . This is my default.py file: servicios_publicos=Service() servicios_privados=Service() def public_call(): return servicios_publicos() @auth.requires_login() def private_call(): return servicios_privados() @servicios_publicos.json def registra(usuario, email, password): respuesta = {} estado = 'OK' mensaje = '' tipoError = 0 #Comprueba si hay otro usuario con el mismo nombre if db(db.auth_user.username == usuario).count() != 0: estado = 'Error' tipoError = 1 #Comprueba si hay otro usuario con el mismo email if db(db.auth_user.email == email).count() != 0: estado = 'Error' tipoError = tipoError + 2 #Registrar if estado == 'OK': db.auth_user.insert(username=usuario, email=email, password=db. auth_user.password.validate(password)) mensaje = 'El registro se ha realizado correctamente.' else: if tipoError == 1: mensaje = 'El usuario ya existe.' elif tipoError == 2: mensaje = 'El email ya existe.' else: mensaje = 'El usuario y el email ya existen.' respuesta['estado'] = estado respuesta['mensaje'] = mensaje return respuesta @servicios_publicos.json def login(usuario, password): respuesta = {} user = auth.login_bare(usuario, password) if not user: respuesta['estado'] = 'Error' respuesta['mensaje'] = 'Nombre de usuario o contraseña incorrecta' else: respuesta['estado'] = 'OK' respuesta['mensaje'] = 'Login correcto' return respuesta And this is my db.py: if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite') else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client())) ## by default give a view/generic.extension to all actions from localhost ## none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] ## (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' # ## Here is sample code if you need for ## - email capabilities ## - authentication (registration, login, logout, ... ) ## - authorization (role based authorization) ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) ## - old style crud actions ## (more options discussed in gluon/tools.py) # from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() ## create all tables needed by auth if not custom tables
[web2py] Re: Login manually
Hi again Massimo! I've tried this: check: print 'check:', any(r.password.startswith('|') for r in rows) check: True Hope this helps. El martes, 18 de diciembre de 2012 20:55:06 UTC+1, Massimo Di Pierro escribió: Can you please check something for me: python web2py.py -S yourappname -M rows = db(db.auth_user).select(db.auth_user.password) print 'check:', any(r.passwords.startswith('|') for r in rows): does it print check: true or check: false? Massimo On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote: Hi again Massimo! Since I've changed very few from the basic project I will paste my code here (sorry for my comments and variable names in Spanish, if you want I could translate the code) . This is my default.py file: servicios_publicos=Service() servicios_privados=Service() def public_call(): return servicios_publicos() @auth.requires_login() def private_call(): return servicios_privados() @servicios_publicos.json def registra(usuario, email, password): respuesta = {} estado = 'OK' mensaje = '' tipoError = 0 #Comprueba si hay otro usuario con el mismo nombre if db(db.auth_user.username == usuario).count() != 0: estado = 'Error' tipoError = 1 #Comprueba si hay otro usuario con el mismo email if db(db.auth_user.email == email).count() != 0: estado = 'Error' tipoError = tipoError + 2 #Registrar if estado == 'OK': db.auth_user.insert(username=usuario, email=email, password=db. auth_user.password.validate(password)) mensaje = 'El registro se ha realizado correctamente.' else: if tipoError == 1: mensaje = 'El usuario ya existe.' elif tipoError == 2: mensaje = 'El email ya existe.' else: mensaje = 'El usuario y el email ya existen.' respuesta['estado'] = estado respuesta['mensaje'] = mensaje return respuesta @servicios_publicos.json def login(usuario, password): respuesta = {} user = auth.login_bare(usuario, password) if not user: respuesta['estado'] = 'Error' respuesta['mensaje'] = 'Nombre de usuario o contraseña incorrecta' else: respuesta['estado'] = 'OK' respuesta['mensaje'] = 'Login correcto' return respuesta And this is my db.py: if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite') else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client())) ## by default give a view/generic.extension to all actions from localhost ## none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] ## (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' # ## Here is sample code if you need for ## - email capabilities ## - authentication (registration, login, logout, ... ) ## - authorization (role based authorization) ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) ## - old style crud actions ## (more options discussed in gluon/tools.py) # from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() ## create all tables needed by auth if not custom tables auth.define_tables(username=True, signature=False) ## configure email mail = auth.settings.mailer mail.settings.server = 'here comes my SMTP server' mail.settings.sender = 'here comes my email' mail.settings.login = 'here comes my email user/password' ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. ## register with janrain.com, write your domain:api_key in private/janrain.key from gluon.contrib.login_methods.rpx_account import use_janrain use_janrain(auth, filename='private/janrain.key') If it helps you, I'm using python 2.7.1 and I launch web2py with: python web2py.py -c server.crt -k server.key and this is the trace: Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), IMAP(imaplib) El martes, 18 de diciembre de 2012
[web2py] Re: Login manually
It prints check: False El martes, 18 de diciembre de 2012 20:55:06 UTC+1, Massimo Di Pierro escribió: Can you please check something for me: python web2py.py -S yourappname -M rows = db(db.auth_user).select(db.auth_user.password) print 'check:', any(r.passwords.startswith('|') for r in rows): does it print check: true or check: false? Massimo On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote: Hi again Massimo! Since I've changed very few from the basic project I will paste my code here (sorry for my comments and variable names in Spanish, if you want I could translate the code) . This is my default.py file: servicios_publicos=Service() servicios_privados=Service() def public_call(): return servicios_publicos() @auth.requires_login() def private_call(): return servicios_privados() @servicios_publicos.json def registra(usuario, email, password): respuesta = {} estado = 'OK' mensaje = '' tipoError = 0 #Comprueba si hay otro usuario con el mismo nombre if db(db.auth_user.username == usuario).count() != 0: estado = 'Error' tipoError = 1 #Comprueba si hay otro usuario con el mismo email if db(db.auth_user.email == email).count() != 0: estado = 'Error' tipoError = tipoError + 2 #Registrar if estado == 'OK': db.auth_user.insert(username=usuario, email=email, password=db. auth_user.password.validate(password)) mensaje = 'El registro se ha realizado correctamente.' else: if tipoError == 1: mensaje = 'El usuario ya existe.' elif tipoError == 2: mensaje = 'El email ya existe.' else: mensaje = 'El usuario y el email ya existen.' respuesta['estado'] = estado respuesta['mensaje'] = mensaje return respuesta @servicios_publicos.json def login(usuario, password): respuesta = {} user = auth.login_bare(usuario, password) if not user: respuesta['estado'] = 'Error' respuesta['mensaje'] = 'Nombre de usuario o contraseña incorrecta' else: respuesta['estado'] = 'OK' respuesta['mensaje'] = 'Login correcto' return respuesta And this is my db.py: if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite') else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client())) ## by default give a view/generic.extension to all actions from localhost ## none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] ## (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' # ## Here is sample code if you need for ## - email capabilities ## - authentication (registration, login, logout, ... ) ## - authorization (role based authorization) ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) ## - old style crud actions ## (more options discussed in gluon/tools.py) # from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() ## create all tables needed by auth if not custom tables auth.define_tables(username=True, signature=False) ## configure email mail = auth.settings.mailer mail.settings.server = 'here comes my SMTP server' mail.settings.sender = 'here comes my email' mail.settings.login = 'here comes my email user/password' ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. ## register with janrain.com, write your domain:api_key in private/janrain.key from gluon.contrib.login_methods.rpx_account import use_janrain use_janrain(auth, filename='private/janrain.key') If it helps you, I'm using python 2.7.1 and I launch web2py with: python web2py.py -c server.crt -k server.key and this is the trace: Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), IMAP(imaplib) El martes, 18 de diciembre de 2012 18:11:51 UTC+1, Massimo Di Pierro escribió: Can I see you models? Are you changing the validator for