"Invalid salt" error when trying to login with the manually changes password

1,833 views
Skip to first unread message

Михаил Савушкин

unread,
Jun 8, 2016, 7:16:58 AM6/8/16
to tryton
Hello!
I'm having this responce from server when trying to login to tryton 4.0 via SAO:
{"id": 0, "error": ["Invalid salt", "None\n"]}

The unusual thing about my tryton installation is that i created a DB from the template (db with all official modules installed) to cut the time of installation. And then i had to change admin password, so i've tried 2 approaches:
1) Execute SQL directly:
"UPDATE res_user SET password_hash='%s' WHERE login='admin';" % password_hash
where password_hash was generated by the same chunk of code copy-pasted from trytond, i.e.:
password = self.admin_user_pswd
if isinstance(password, unicode):
  password
= password.encode('utf-8')
hash_
= bcrypt.hashpw(password, bcrypt.gensalt()).decode('utf-8')
return '$.join(['bcrypt', hash_])

2) Change password via trytond instance:
trytond_config.update_etc(os.environ.get('TRYTOND_CONFIG'))
database_name
= os.environ.get('DATABASE_NAME')

# register trytond's modules
trytond_register_classes
()

# create database connection and initialize pool
database_class
= trytond_backend.get('Database')
database_class
(database_name).connect()

pool
= TrytondPool(database_name)
pool
.init()

 
# use dedicated anonymous transaction to get user
with TrytondTransaction().start(database_name, 0) as tr:
  user_cls
= pool.get('res.user')
  admin
= user_cls.search([['login', '=', 'admin']], limit=1)[0]
  user_cls
.set_password(
    users
=[admin],
    name
=None,
    value
=u'admin',
 
)
tr
.commit()

No luck with both.

Trytond is running inside docker container with all the pip packages installed "globally" inside it, no virtualenvs. 
Same Trytond server but with pre-runned command
trytond-admin -c $TRYTOND_CONFIG -d $DATABASE_NAME -v --all
works absolutely fine.

Password hashes for working and not working cases are similar:
bcrypt$2a$12$Lsg7t0E.MtCiv9qZfkJwNeL/9xGnd.DfXXTX6JTbdP81EO..oJZSu <-- this is from not working instance
bcrypt$2a$12$w9nYLlF39hAXh2S3JT53JuqMuMjvLvfXM7cDXTLbNjJha4Sw4OkpO
<-- this is from working one

And the other confusing thing is that this error pops up with any password specified, valid or not.
The request hits the right DB, as far as i can tell, since it looks this way in the logs:
[2016-06-08 10:42:54,822] INFO werkzeug 172.31.24.247 - - [08/Jun/2016 10:42:54] "POST /i5b7446a6d09e498/ HTTP/1.1" 200 -
                                                                                             
^-- my DB name



I'm really confused, and will highly appreciate any help!


Cédric Krier

unread,
Jun 8, 2016, 8:05:04 AM6/8/16
to tryton
On 2016-06-08 04:00, Михаил Савушкин wrote:
> Hello!
> I'm having this responce from server when trying to login to tryton 4.0 via
> SAO:
> {"id": 0, "error": ["Invalid salt", "None\n"]}
>
> Trytond is running inside docker container with all the pip packages
> installed "globally" inside it, no virtualenvs.
> Same Trytond server but with pre-runned command
> trytond-admin -c $TRYTOND_CONFIG -d $DATABASE_NAME -v --all
> works absolutely fine.
>
> Password hashes for working and not working cases are similar:
> bcrypt$2a$12$Lsg7t0E.MtCiv9qZfkJwNeL/9xGnd.DfXXTX6JTbdP81EO..oJZSu <-- this
> is from not working instance
> bcrypt$2a$12$w9nYLlF39hAXh2S3JT53JuqMuMjvLvfXM7cDXTLbNjJha4Sw4OkpO <-- this
> is from working one
>
> And the other confusing thing is that this error pops up with any password
> specified, valid or not.
> The request hits the right DB, as far as i can tell, since it looks this
> way in the logs:
> [2016-06-08 10:42:54,822] INFO werkzeug 172.31.24.247 - - [08/Jun/2016 10:42
> :54] "POST /i5b7446a6d09e498/ HTTP/1.1" 200 -
>
> ^-- my DB name

It looks like something similar to
https://stackoverflow.com/questions/34548846/flask-bcrypt-valueerror-invalid-salt/36465345#36465345

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
Reply all
Reply to author
Forward
0 new messages