3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-28 13:42:37 +01:00

Allow specifying login blocks that are local to certain networks

This commit is contained in:
James Lu 2017-08-07 16:16:17 -07:00
parent 21a39de0b4
commit 8059f3f7fc
2 changed files with 12 additions and 0 deletions

View File

@ -15,6 +15,15 @@ from pylinkirc.log import log
def _login(irc, source, username):
"""Internal function to process logins."""
logindata = conf.conf['login'].get('accounts', {}).get(username, {})
network_filter = logindata.get('networks')
if network_filter and irc.name not in network_filter:
irc.error("You are not authorized to log in to %r on this network." % username)
log.warning("(%s) Failed login to %r from %s (wrong network: networks filter says %r but we got %r)", irc.name, username, irc.get_hostmask(source), ', '.join(network_filter), irc.name)
return
irc.users[source].account = username
irc.reply('Successfully logged in as %s.' % username)
log.info("(%s) Successful login to %r by %s",

View File

@ -92,6 +92,9 @@ login:
# (plain text) for backwards compatibility.
encrypted: true
# Optional: allows limiting this login to users from certain networks only (case sensitive).
#networks: ["network1", "network2"]
permissions:
# Permissions are described in more detail in example-permissions.yml, if you want to
# customize permissions further.