diff --git a/coremods/corecommands.py b/coremods/corecommands.py index 9b5bb5c..0c30d9f 100644 --- a/coremods/corecommands.py +++ b/coremods/corecommands.py @@ -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", diff --git a/example-conf.yml b/example-conf.yml index 37dbb12..9f27718 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -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.