Skip to content

Commit

Permalink
Merge pull request #681 from systemli/lua-dovecot-fix-quota
Browse files Browse the repository at this point in the history
Dovecot Lua auth: Various fixes
  • Loading branch information
y3n4 authored Dec 3, 2024
2 parents cba92cd + 162d50c commit 21d767f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions contrib/checkpasswd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function auth_userdb_lookup(request)
attributes["uid"] = data.body.uid

if data.body.quota ~= "" then
attributes["userdb_quota_rule"] = data.body.quota
attributes["quota_rule"] = data.body.quota
end
-- Only return mailcrypt attributes if mailcrypt is enabled for user:
if data.body.mailCrypt == 2 then
Expand All @@ -123,7 +123,7 @@ function auth_password_verify(request, password)
}
http_request:add_header("Content-Type","application/json")
http_request:add_header("Authorization","Bearer " .. env_userli_token)
http_request:set_payload(string.format('{"password": "%s"}', password))
http_request:set_payload(json.encode({password = password}))
local http_response = http_request:submit()

if http_response:status() == 200 then
Expand Down
6 changes: 5 additions & 1 deletion src/Controller/DovecotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ public function lookup(
} else {
$mailCryptReported = 0;
}

[$username, $domain] = explode('@', $user->getEmail());

$customQuota = $user->getQuota();
$customQuotaString = $customQuota !== null ? sprintf('*:storage=%dM', $customQuota) : "";

return $this->json([
'message' => self::MESSAGE_SUCCESS,
'body' => [
Expand All @@ -72,7 +76,7 @@ public function lookup(
'mailCryptPublicKey' => $user->getMailCryptPublicKey() ?? "",
'gid' => $this->mailGid,
'uid' => $this->mailUid,
'quota' => $user->getQuota() ?? "",
'quota' => $customQuotaString,
]
], Response::HTTP_OK);
}
Expand Down

0 comments on commit 21d767f

Please sign in to comment.