This Project is aimed to simplify building apis which require User authentification
- login
- registration
- Token generation
- Token Verification
- Different Token Types
- Auth_Token -> Used for user verification
- ResetCode -> Used to auth password Resets
- ActivationCode -> Used to activate user Accounts
- Custom Exceptions
- MissingUserExceptions
- NotInitedException
- AlreadyExistsException
- TokenMissingException
-
Refactor db_functions.py (v.2.0.0) - Custom Return Object instead of dicts
-
fix Code Smells -
implement token verification for other tokens than auth_token - implement propper logging (v.2.1.0)
- writing Tests
- Token Module
- Config Module
- Perm Module
- UserFunctions
- Login Functions
-
Created readthedocs page - How to Install
- How to Use
- auth_type_enum
- custom_exceptions
- data_classes
- ldap_stuff
- login_class
- perms_class
- user_funcs
- Token
- token_base_class
- token_auth_class
- token_reset_class
- token_activation_class
- Config
- config_base_class
- config_ad_class
- config_db_class
- config_general_class
from pyusermanager import *
from pyusermanager.Config import *
from pyusermanager.Config.db_providers import *
import pyusermanager.Token as Token
# Create DB-Config
db_cfg = MYSQL_Provider(
host="127.0.0.1", port=3306, user="test", passwd="test1234", db="users"
)
# setup general config
cfg = General_Config(auto_activate_accounts=False)
# connect to db
cfg.bind(db_cfg)
#creating user
try:
user(cfg, "testuser").create("password")
except PyUserExceptions.AlreadyExistsException:
print("user already exists")
#if login was successfull we want to create an auth token and print it
if login(cfg,'testuser','password'):
token = Token.Auth(cfg,username="testuser")
token.create("127.0.0.1",valid_days=1)
print(f"Token: {token.token}")
testtoken = Token.Auth(cfg,token=token.token)
print(f"trying to verify Token: {testtoken.token}\nreturnes: {testtoken.verify('127.0.0.1')}")
#creating a perm and assigning it to a user
testperm = Perm(cfg,"testperm")
testperm.create()
print(f"tyring to assign it to testuser: {testperm.assign_to_user('testuser')}")
more examples can be found in howtouse.py
- AD_Config now has the attribute ca_file. If this is specified it will create an TLS Context needed for ldaps connections
- fixed ip not updating on successfull login in function create of Token.Auth class
- added AuthProvider Class so we have an app wide possibility to check groups and other stuff
- avatar folder is now part of the general config
- added DBProviders enum to pyusermanager.Config.db_providers so we can get the fitting db provider by the specified name
- fixed some typos in the readme
- fixed some typos in howtouse.py
- an ad user will now get ad groups on every login (will remove groups set by hand!)
- new exception ADLoginProhibited which will be raised if an already existing ad user tries to login after ad logins where disabled
- fixed bug in activation token creation
- you can now set the lifetime of a token with set_lifetime on the token object
- auth_token now updates last_login attribute in database
- alot of rewrites
- please look at the howtouse.py and documentation!
- get_extended_info not takes an extra optional arg (include_email) if its not None it will return the user email in the user_dict