Mercurial > prosody-modules
comparison mod_auth_phpbb3/mod_auth_phpbb3.lua @ 6346:c400892603ce
Updating phpbb3 authentication module for argon2 password support.
| author | Ganiman <ganiman@ganiman.com> |
|---|---|
| date | Tue, 28 Oct 2025 16:29:47 -0400 |
| parents | 28d99ffa3c06 |
| children |
comparison
equal
deleted
inserted
replaced
| 6345:8a131d44fc7f | 6346:c400892603ce |
|---|---|
| 9 local saslprep = require "util.encodings".stringprep.saslprep; | 9 local saslprep = require "util.encodings".stringprep.saslprep; |
| 10 local DBI = require "DBI" | 10 local DBI = require "DBI" |
| 11 local md5 = require "util.hashes".md5; | 11 local md5 = require "util.hashes".md5; |
| 12 local uuid_gen = require "util.uuid".generate; | 12 local uuid_gen = require "util.uuid".generate; |
| 13 local have_bcrypt, bcrypt = pcall(require, "bcrypt"); -- available from luarocks | 13 local have_bcrypt, bcrypt = pcall(require, "bcrypt"); -- available from luarocks |
| 14 local argon2 = require("argon2") | |
| 14 | 15 |
| 15 local connection; | 16 local connection; |
| 16 local params = module:get_option("sql"); | 17 local params = module:get_option("sql"); |
| 17 | 18 |
| 18 local resolve_relative_path = require "core.configmanager".resolve_relative_path; | 19 local resolve_relative_path = require "core.configmanager".resolve_relative_path; |
| 177 end | 178 end |
| 178 local function phpbbCheckHash(password, hash) | 179 local function phpbbCheckHash(password, hash) |
| 179 if #hash == 32 then return hash == md5(password, true); end -- legacy PHPBB2 hash | 180 if #hash == 32 then return hash == md5(password, true); end -- legacy PHPBB2 hash |
| 180 if #hash == 34 then return hashCryptPrivate(password, hash) == hash; end | 181 if #hash == 34 then return hashCryptPrivate(password, hash) == hash; end |
| 181 if #hash == 60 and have_bcrypt then return bcrypt.verify(password, hash); end | 182 if #hash == 60 and have_bcrypt then return bcrypt.verify(password, hash); end |
| 183 if #hash == 97 then return argon2.verify(hash, password); end | |
| 182 module:log("error", "Unsupported hash: %s", hash); | 184 module:log("error", "Unsupported hash: %s", hash); |
| 183 return false; | 185 return false; |
| 184 end | 186 end |
| 185 local function phpbbCreateHash(password) | 187 local function phpbbCreateHash(password) |
| 186 local random = uuid_gen():sub(-6); | 188 local random = uuid_gen():sub(-6); |
