From c4351d61c6d98014ff74bf7d6733af858b247eea Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 19 Nov 2016 17:16:04 -0800 Subject: [PATCH] Add command line mkpasswd utility & encrypted password example --- example-conf.yml | 8 ++++++-- pylink-mkpasswd | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 pylink-mkpasswd diff --git a/example-conf.yml b/example-conf.yml index 2830175..2e7189b 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -49,9 +49,13 @@ login: accounts: # Creates an account with username "user1". user1: - # Defines the password for the user. - password: "somestring" + # Defines the password for the user. You can encrypt passwords using the + # 'mkpasswd' command or the 'pylink-mkpasswd' utility included with PyLink. + password: "$6$rounds=617998$BwHhwX4wB5R0H9uw$Lyo.4icYjVSnSCDsjNIO5Ap5LAcyqLspBcUqVR0qlIB9o6vKU.WyrttHZum4dVW35cuc2wGP2SKa5Bv/svdiv1" + # Determines whether the password given is in plain-text. Defaults to false + # (plain text) for backwards compatibility. + encrypted: true servers: # Please note: these are only EXAMPLE link blocks. You should edit them and diff --git a/pylink-mkpasswd b/pylink-mkpasswd new file mode 100755 index 0000000..a2da79a --- /dev/null +++ b/pylink-mkpasswd @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +""" +Password hashing utility for PyLink IRC Services. +""" + +import passlib +from passlib.apps import custom_app_context as pwd_context + +if __name__ == '__main__': + import argparse + + parser = argparse.ArgumentParser(description='Hashes a password for use with PyLink IRC Services.') + parser.add_argument('password', help='specifies the password to hash') + args = parser.parse_args() + + assert args.password, "Password cannot be empty!" + print(pwd_context.encrypt(args.password))