Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix template directory doesn't copy into lib add added main #52

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions nativeauthenticator/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
class UserInfo(Base):
__tablename__ = 'users_info'
id = Column(Integer, primary_key=True, autoincrement=True)
username = Column(String, nullable=False)
password = Column(String, nullable=False)
username = Column(String(128), nullable=False)
password = Column(String(128), nullable=False)
is_authorized = Column(Boolean, default=False)
email = Column(String)
email = Column(String(128))

@classmethod
def find(cls, db, username):
Expand All @@ -23,8 +23,9 @@ def find(cls, db, username):
def is_valid_password(self, password):
"""Checks if a password passed matches the
password stored"""
encoded_pw = bcrypt.hashpw(password.encode(), self.password)
return encoded_pw == self.password
check_pwd = self.password.encode() if type(self.password) != bytes else self.password
encoded_pw = bcrypt.hashpw(password.encode(), check_pwd)
return encoded_pw == check_pwd

@classmethod
def change_authorization(cls, db, username):
Expand All @@ -35,6 +36,8 @@ def change_authorization(cls, db, username):

@validates('email')
def validate_email(self, key, address):
if not address:
return
assert re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
address)
return address
19 changes: 16 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
from setuptools import setup, find_packages

setup(
pjoin = os.path.join

setup_args = dict(
name='jupyterhub-nativeauthenticator',
version='0.0.1',
description='JupyterHub Native Authenticator',
Expand All @@ -11,7 +14,17 @@
packages=find_packages(),
install_requires=['jupyterhub>=0.8', 'bcrypt'],
package_data={
'templates': ['*.html'],
'common-credentials': ['common-credentials.txt'],
'nativeauthenticator': [
pjoin('templates', '*.html'),
'common-credentials.txt'
],
}
)


def main():
setup(**setup_args)


if __name__ == '__main__':
main()