aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2021-09-27 17:05:42 +0200
committerBadlop <badlop@process-one.net>2021-09-27 17:12:17 +0200
commitd205e6ff1ff32c075afea8b3189edc5f3c0c1ab0 (patch)
tree84224cdfbc751debb4b7500cd640078c100e1e1b /src
parentAdd indexes from 95fa43aa to the old-to-new MySQL schema update script (diff)
Support old scram records before xmpp's 651050f9 and ejabberd's e5cad9be6 (#3680)
Diffstat (limited to 'src')
-rw-r--r--src/ejabberd_auth_sql.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ejabberd_auth_sql.erl b/src/ejabberd_auth_sql.erl
index 1f7106c59..e51bf276c 100644
--- a/src/ejabberd_auth_sql.erl
+++ b/src/ejabberd_auth_sql.erl
@@ -299,6 +299,20 @@ export(_Server) ->
["username=%(LUser)s",
"server_host=%(LServer)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})
when LServer == Host ->
StoredKey = scram_hash_encode(Scram#scram.hash, Scram#scram.storedkey),