コード例 #1
0
    def test_encrypt_verify(self):
        test_passwd = 'test_password_1234'

        cipher = Auth.encrypt_passwd(test_passwd)

        self.assertTrue(Auth.verify_passwd(test_passwd, cipher))
        self.assertFalse(Auth.verify_passwd('test_password_123', cipher))
コード例 #2
0
    def test_validate_valid_emails(self):
        valid = [
            '*****@*****.**',
            '*****@*****.**',
            244 * 'a' + '@google.com',  # Max chars (255)
            'abc123.+%%[email protected]',
        ]

        for email in valid:
            self.assertTrue(Auth.validate_email(email))
コード例 #3
0
    def test_validate_valid_usernames(self):
        valid = [
            'David',  # Min chars (5)
            'abcdeabcdeabcdeabcdeabcde',  # Max chars (25)
            's3662167',  # Start with letter
            'a__--013495-__-_9',  # All allowed chars, end with number
        ]

        for uname in valid:
            self.assertTrue(Auth.validate_username(uname))
コード例 #4
0
    def test_validate_invalid_usernames(self):
        invalid = [
            '5Davlid',  # Starting with number
            'asdf',  # Lower than min chars (5)
            'asdfasdfasdfasdfasdfasdfas',  # Greater than max chars (25)
            'aaaaaa;%a',  # Contains invalid chars
            'asdfasdf_',  # Doesnt end with number/letter
        ]

        for uname in invalid:
            self.assertFalse(Auth.validate_username(uname))
コード例 #5
0
    def test_validate_invalid_emails(self):
        invalid = [
            'invalid@google@com',
            '[email protected]',
            'invalid',
            'invalid@something',
            245 * 'a' + '@google.com',  # Max chars (255) + 1
            'invalid@gmail%.com'
        ]

        for email in invalid:
            self.assertFalse(Auth.validate_email(email))
コード例 #6
0
def login():
    if logged_in(session):
        return redirect('/admin')

    if request.method == 'GET' or 'ajax' not in request.form:
        form = LoginForm()
        return render_template('login.bs.html', form=form)

    if 'user' not in request.form or 'pass' not in request.form:
        return '{"auth_succes":false}'

    user = request.form['user']
    pass_ = request.form['pass']

    if not Auth.verify_passwd(pass_, app.config['ADMIN_PASSWORD']):
        return '{"auth_succes":false}'

    if user != app.config['ADMIN_USERNAME']:
        return '{"auth_success":false}'

    session['auth_success'] = True

    return '{"auth_success":true}'
コード例 #7
0
# vim: set et sw=4 ts=4 sts=4:

from config import CONFIG_RP
from class_.Auth import Auth
from class_.DBInterface import DBInterface
from class_.Reception import Reception
from class_.FaceRecognition import FaceRecognition

dbi = DBInterface(CONFIG_RP['db'])
auth = Auth(dbi)
fr = FaceRecognition()

reception_pi = Reception(config=CONFIG_RP,
                         dbi=dbi,
                         auth=auth,
                         face_recognition=fr)

reception_pi.start()
コード例 #8
0
while True:
    pw = getpass('Password: '******'No password entered, exiting')
        exit()

    cf = getpass('Confirm')

    if pw != cf:
        print('Passwords do not match, please try again')
        continue

    #try:
    cipher = Auth.encrypt_passwd(pw)
    #except:
    #    print('Invalid password format, please choose a different password')
    #    continue

    break

if cipher is None:
    print('Failed, please try again')
    exit()

print('Do NOT store this in config.py')
print('Store this in admin_webapp/instance/config.py')
print('Restart after ensuring you have the following lines:\n')
print('ADMIN_USERNAME = "******"')
print('ADMIN_PASSWORD = "******"')