Compare commits
No commits in common. "master" and "update-spec-link" have entirely different histories.
master
...
update-spe
13
LICENSE
13
LICENSE
@ -1,13 +0,0 @@
|
|||||||
Copyright (c) 2021-2022 Pratyush Desai and others
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
|
|
||||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
Neither the name of the author of this software nor the name of contributors to this software may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
Portions of the included source code are copyright by its original author(s) and remain subject to its associated license.
|
|
17
README.md
17
README.md
@ -1,17 +1,8 @@
|
|||||||
# IRC Web Registration
|
# IRC Web Registration
|
||||||
|
|
||||||
## Version 1
|
|
||||||
The v1 of this concept can be referenced in the [old and *not updated* README](https://git.com.de/LibertaCasa/webreg/src/branch/master/README.old.md)
|
|
||||||
|
|
||||||
The v1.1 enhancements added by [Georg Pfuetzenreuter](https://git.com.de/Georg) implements support for additional SSO integration to our KeyCloak setup.
|
|
||||||
It also works-in SSL support.
|
|
||||||
|
|
||||||
This webform available [here](https://liberta.casa/register) is purely demonstrative and does not successfully `POST` user data
|
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
This is a basic still WIP overhaul framework for registering an account on an ircd using a webform that is referenced above.
|
This is a basic still WIP framework for registering an account on an ircd using a webform.
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
@ -33,10 +24,8 @@ It is recommended to work within a virtual environment.
|
|||||||
|
|
||||||
## Installation and Setup
|
## Installation and Setup
|
||||||
|
|
||||||
Todo! Refer to the issues and the __Milestones__ and __Projects__
|
Todo!
|
||||||
for more
|
|
||||||
|
|
||||||
|
|
||||||
### Note
|
### Note
|
||||||
|
|
||||||
Only works with setups not requiring verification at this moment as stated in #4
|
Only works with setups not requiring verification at this moment.
|
||||||
|
@ -33,9 +33,6 @@ def register():
|
|||||||
flash("Illegal Character in Username. Please choose a different one one.")
|
flash("Illegal Character in Username. Please choose a different one one.")
|
||||||
elif response == "ERR_NICKNAMEINUSE":
|
elif response == "ERR_NICKNAMEINUSE":
|
||||||
flash("Username already taken. Please choose a different one!")
|
flash("Username already taken. Please choose a different one!")
|
||||||
elif response == "CAP_REFUSED":
|
|
||||||
flash("This IRCd doesn't support the draft/account-registration capability")
|
|
||||||
return redirect(webchat_url)
|
|
||||||
elif response == "SUCCESS":
|
elif response == "SUCCESS":
|
||||||
return redirect(webchat_url)
|
return redirect(webchat_url)
|
||||||
else:
|
else:
|
||||||
|
1
forms.py
1
forms.py
@ -4,7 +4,6 @@ from wtforms.validators import DataRequired, Length, EqualTo
|
|||||||
|
|
||||||
|
|
||||||
class RegistrationForm(FlaskForm):
|
class RegistrationForm(FlaskForm):
|
||||||
# clarify that it conforms with casemapping on ircd.
|
|
||||||
username = StringField('Username', validators=[DataRequired(), Length(min=1, max=32)])
|
username = StringField('Username', validators=[DataRequired(), Length(min=1, max=32)])
|
||||||
password = PasswordField('Password', validators=[DataRequired()])
|
password = PasswordField('Password', validators=[DataRequired()])
|
||||||
confirm_password = PasswordField('Confirm Password', validators=[DataRequired(), EqualTo('password')])
|
confirm_password = PasswordField('Confirm Password', validators=[DataRequired(), EqualTo('password')])
|
||||||
|
@ -5,55 +5,72 @@ import os
|
|||||||
webircpass = os.getenv("WEBIRC_PASS")
|
webircpass = os.getenv("WEBIRC_PASS")
|
||||||
|
|
||||||
def ircregister(userip, username, password, email="*"):
|
def ircregister(userip, username, password, email="*"):
|
||||||
|
|
||||||
d = irctokens.StatefulDecoder()
|
d = irctokens.StatefulDecoder()
|
||||||
e = irctokens.StatefulEncoder()
|
e = irctokens.StatefulEncoder()
|
||||||
s = socket.socket()
|
s = socket.socket()
|
||||||
|
|
||||||
|
|
||||||
# Here we assume using this only on localhost i.e. loopback
|
# Here we assume using this only on localhost i.e. loopback
|
||||||
s.connect(("127.0.0.1", 6667))
|
s.connect(("127.0.0.1", 6667))
|
||||||
|
|
||||||
|
# define the send function
|
||||||
def _send(line):
|
def _send(line):
|
||||||
print(f"> {line.format()}")
|
print(f"> {line.format()}")
|
||||||
e.push(line)
|
e.push(line)
|
||||||
while e.pending():
|
while e.pending():
|
||||||
e.pop(s.send(e.pending()))
|
e.pop(s.send(e.pending()))
|
||||||
|
|
||||||
|
# Registering connection
|
||||||
|
|
||||||
|
# WEBIRC
|
||||||
_send(irctokens.build("WEBIRC", [ webircpass, "WebregGateway", userip, userip, "secure"]))
|
_send(irctokens.build("WEBIRC", [ webircpass, "WebregGateway", userip, userip, "secure"]))
|
||||||
|
|
||||||
|
# Check for "ERROR :Invalid WebIRC password"
|
||||||
|
# Should all of this this be under a try except block?
|
||||||
lines = d.push(s.recv(1024))
|
lines = d.push(s.recv(1024))
|
||||||
if lines == None:
|
if lines == None:
|
||||||
print("!disconnected")
|
print("!disconnected")
|
||||||
return "disconnected"
|
return "disconnected"
|
||||||
elif lines.command == "ERROR" and lines.params == "Invalid WebIRC password":
|
elif lines.command == "ERROR" and lines.params == "Invalid WebIRC password":
|
||||||
return "WebIRC bad password"
|
return "WebIRC bad password"
|
||||||
|
|
||||||
|
# Inform the server that we support
|
||||||
|
# CAP 3.2
|
||||||
_send(irctokens.build("CAP", ["LS", "302"]))
|
_send(irctokens.build("CAP", ["LS", "302"]))
|
||||||
|
|
||||||
|
# REGISTER can be attempted before-connect if server supports
|
||||||
|
# but if the server responds with the corresponding FAIL we
|
||||||
|
# need to try again. We can also handle email-required using
|
||||||
|
# the same keys. How to access these key-value pairs?
|
||||||
|
# reference: https://ircv3.net/specs/extensions/account-registration.html
|
||||||
|
|
||||||
|
# NICK and USER
|
||||||
|
_send(irctokens.build("USER", ["u", "0", "*", username]))
|
||||||
|
_send(irctokens.build("NICK", [username]))
|
||||||
|
|
||||||
|
# go through all cases
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
lines = d.push(s.recv(1024))
|
|
||||||
if lines == None:
|
|
||||||
print("! disconnected")
|
|
||||||
break
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
print(f"< {line.format()}")
|
print(f"< {line.format()}")
|
||||||
# REGISTER can be attempted before-connect if server supports
|
if line.command == "432":
|
||||||
# but if the server responds with the corresponding FAIL we
|
return "ERR_ERRONEUSNICKNAME"
|
||||||
# need to try again. We can also handle email-required using
|
elif line.command == "433":
|
||||||
# the same keys. How to access these key-value pairs?
|
return "ERR_NICKNAMEINUSE"
|
||||||
# reference: https://ircv3.net/specs/extensions/account-registration.html
|
_send(irctokens.build("CAP", ["REQ", "draft/account-registration"]))
|
||||||
# do we handle if email-req but not before-connect
|
|
||||||
# also how about when `custom-account-name` may be a value
|
|
||||||
if 'draft/account-registration=before-connect' in line.params:
|
|
||||||
_send(irctokens.build("CAP", ["REQ", "draft/account-registration"]))
|
|
||||||
if line.command == "CAP" and ("NAK" in line.params):
|
if line.command == "CAP" and ("NAK" in line.params):
|
||||||
return "CAP_REFUSED"
|
return "cap refused"
|
||||||
elif line.command == "CAP" and ("ACK" in line.params):
|
elif line.command == "CAP" and ("ACK" in line.params):
|
||||||
_send(irctokens.build("CAP", ["END"]))
|
to_send = irctokens.build("CAP", ["END"])
|
||||||
_send(irctokens.build("USER", ["u", "0", "*", username]))
|
_send(to_send)
|
||||||
_send(irctokens.build("NICK", [username]))
|
if line.command == "PING":
|
||||||
if line.command == "432":
|
to_send = irctokens.build("PONG", [line.params[0]])
|
||||||
return "ERR_ERRONEUSNICKNAME"
|
_send(to_send)
|
||||||
if line.command == "433":
|
if line.command == "001":
|
||||||
return "ERR_NICKNAMEINUSE"
|
# assuming no verif reqd.
|
||||||
_send(irctokens.build("REGISTER", [username, "*", password]))
|
to_send = irctokens.build("REGISTER", ["*", email, password])
|
||||||
|
_send(to_send)
|
||||||
if line.command == "REGISTER" and ("SUCCESS" in line.params):
|
if line.command == "REGISTER" and ("SUCCESS" in line.params):
|
||||||
_send(irctokens.build("QUIT"))
|
to_send = irctokens.build("QUIT")
|
||||||
|
_send(to_send)
|
||||||
return "SUCCESS"
|
return "SUCCESS"
|
||||||
|
|
10
requirements.txt
Normal file
10
requirements.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
click==8.0.1
|
||||||
|
Flask==2.0.1
|
||||||
|
Flask-WTF==0.15.1
|
||||||
|
gunicorn==20.1.0
|
||||||
|
irctokens==2.0.0
|
||||||
|
itsdangerous==2.0.1
|
||||||
|
Jinja2==3.0.1
|
||||||
|
MarkupSafe==2.0.1
|
||||||
|
Werkzeug==2.0.1
|
||||||
|
WTForms==2.3.3
|
Loading…
Reference in New Issue
Block a user