How to blacklist a list of user for authenticated smtp sasl via multimap list ?

49 views
Skip to first unread message

charlesg...@gmail.com

unread,
Mar 2, 2018, 4:10:42 AM3/2/18
to rspamd
Hi,

In my lua/rspamd.local.lua, I add this :

rspamd_config.UID_BLACKLIST = {
        callback = function(task)
                local uname = task:get_user()
                if string.match(uname, '(.+)@.*') == 'baduser' then
                        rspamd_logger.infox(task, "Unauthorized LDAP user %s",uname)
                        return true
                end
        end,
        score = 0.01,
        description = 'SMTP SASL user blacklisted',
        group = 'authentication'
}    

and in file local.d/force_actions.conf :

  UID_BLACKLIST_FOUND {
    action = "reject";
    expression = "UID_BLACKLIST";
    honor_action = ["reject"];
  }

This worked fine for 1 user, but how do this for a list of user than I can edited with the web interface like a multipmap list ?

Thanks

Andrew Lewis

unread,
Mar 2, 2018, 4:22:50 PM3/2/18
to rsp...@googlegroups.com
Hi,

> This worked fine for 1 user, but how do this for a list of user than I can
> edited with the web interface like a multipmap list ?

Adding support for something along these lines to multimap might be
reasonable but you could use a rule.

You could register and check a map from Lua:

local banned_users_map = rspamd_config:add_map({
type = 'set',
url = '/var/lib/rspamd/banned_users.map',
description = 'User blacklist'
})

rspamd_config.BANNED_USER = {
callback = function (task)
local user = task:get_user()
if not user then return end
if not banned_users_map then return end
local localpart, domain = string.match(user, '(.+)@(.+)')
if not localpart then
localpart = user
end
if banned_users_map:get_key(localpart) then
task:set_pre_result('reject', 'You are forbidden')
return true
end
end,
type = 'prefilter',
}

Best,
-AL.

charlesg...@gmail.com

unread,
Mar 3, 2018, 9:27:43 AM3/3/18
to rspamd
Thank you, it works very well.
This is exactly what I was looking for.
Reply all
Reply to author
Forward
0 new messages