25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Support old scram records before xmpp's 651050f9 and ejabberd's e5cad9be6 (#3680)

This commit is contained in:
Badlop 2021-09-27 17:05:42 +02:00
parent dd359a7328
commit d205e6ff1f

View File

@ -299,6 +299,20 @@ export(_Server) ->
["username=%(LUser)s", ["username=%(LUser)s",
"server_host=%(LServer)s", "server_host=%(LServer)s",
"password=%(Password)s"])]; "password=%(Password)s"])];
(Host, #passwd{us = {LUser, LServer},
password = {scram, StoredKey1, ServerKey, Salt, IterationCount}})
when LServer == Host ->
Hash = sha,
StoredKey = scram_hash_encode(Hash, StoredKey1),
[?SQL("delete from users where username=%(LUser)s and %(LServer)H;"),
?SQL_INSERT(
"users",
["username=%(LUser)s",
"server_host=%(LServer)s",
"password=%(StoredKey)s",
"serverkey=%(ServerKey)s",
"salt=%(Salt)s",
"iterationcount=%(IterationCount)d"])];
(Host, #passwd{us = {LUser, LServer}, password = #scram{} = Scram}) (Host, #passwd{us = {LUser, LServer}, password = #scram{} = Scram})
when LServer == Host -> when LServer == Host ->
StoredKey = scram_hash_encode(Scram#scram.hash, Scram#scram.storedkey), StoredKey = scram_hash_encode(Scram#scram.hash, Scram#scram.storedkey),