Implement manual authentication mode

This commit is contained in:
Mark Veidemanis 2022-08-14 13:13:05 +01:00
parent eba2c387f0
commit b5e78bc4de
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 22 additions and 4 deletions

View File

@ -668,5 +668,5 @@ class API(object):
num = int(num) num = int(num)
if num not in main.network[net].relays.keys(): if num not in main.network[net].relays.keys():
return dumps({"success": False, "reason": f"no relay {num} on {net}"}) 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}) return dumps({"success": True})

View File

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

View File

@ -114,15 +114,31 @@ def confirmRegistration(net, num, negativepass=None):
main.saveConf("network") 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] obj = main.network[net]
nick = main.alias[num]["nick"] nick = main.alias[num]["nick"]
security = obj.security security = obj.security
auth = obj.auth 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 # 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 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: if selectInst(net)["check"] is False:
confirmRegistration(net, num) confirmRegistration(net, num)