3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +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): def _login(irc, source, username):
"""Internal function to process logins.""" """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.users[source].account = username
irc.reply('Successfully logged in as %s.' % username) irc.reply('Successfully logged in as %s.' % username)
log.info("(%s) Successful login to %r by %s", log.info("(%s) Successful login to %r by %s",

View File

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