Implement manual authentication mode

This commit is contained in:
Mark Veidemanis 2022-08-14 13:13:05 +01:00
parent f7d390da32
commit 060ee4f0d5
3 changed files with 22 additions and 4 deletions

View File

@ -668,5 +668,5 @@ class API(object):
num = int(num)
if num not in main.network[net].relays.keys():
return dumps({"success": False, "reason": f"no relay {num} on {net}"})
regproc.enableAuthentication(net, num)
regproc.enableAuthentication(net, num, jump=False, run_now=True)
return dumps({"success": True})

View File

@ -43,11 +43,13 @@ def provisionAuthenticationData(num, nick, network, security, auth, password):
user = nick.lower()
if auth == "sasl":
commands["sasl"] = []
commands["status"].append("UnloadMod nickserv")
commands["status"].append("LoadMod sasl")
commands["sasl"].append("Mechanism plain")
commands["sasl"].append("Set %s %s" % (nick, password))
elif auth == "ns":
commands["nickserv"] = []
commands["status"].append("UnloadMod sasl")
commands["status"].append("LoadMod nickserv")
commands["nickserv"].append("Set %s" % password)
inst = modules.regproc.selectInst(network)

View File

@ -114,15 +114,31 @@ def confirmRegistration(net, num, negativepass=None):
main.saveConf("network")
def enableAuthentication(net, num):
def attemptManualAuthentication(net, num):
sinst = substitute(net, num)
obj = main.network[net]
identifymsg = sinst["identifymsg"]
entity = sinst["entity"]
name = f"{net}{num}"
if name not in main.IRCPool:
return
main.IRCPool[name].msg(entity, identifymsg)
def enableAuthentication(net, num, jump=True, run_now=False):
obj = main.network[net]
nick = main.alias[num]["nick"]
security = obj.security
auth = obj.auth
password = obj.aliases[num]["password"]
name = f"{net}{num}"
if name not in main.IRCPool:
return
# uname = main.alias[num]["nick"] + "/" + net
password = main.network[net].aliases[num]["password"]
provision.provisionAuthenticationData(num, nick, net, security, auth, password) # Set up for auth
main.IRCPool[net + str(num)].msg(main.config["Tweaks"]["ZNC"]["Prefix"] + "status", "Jump")
if jump:
main.IRCPool[name].msg(main.config["Tweaks"]["ZNC"]["Prefix"] + "status", "Jump")
if run_now:
attemptManualAuthentication(net, num)
if selectInst(net)["check"] is False:
confirmRegistration(net, num)