Skip to main content

Some Functions to manage a User Database and do stuff with it!

Project description

pyusermanager

a user management libary for web services or other stuff


PyPI version Supported python versions
Black badge
Documentation status

1. Info

This Project is aimed to simplify building apis which require User authentification

1.2 Table of Contents

2. Features

  • 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

3. Plans for the Future

  • 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

4. Documentation Status

4.1 General

  • Created readthedocs page
  • How to Install
  • How to Use

4.2 Modules

  • uth_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

5. Quickstart

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 example can be found in howtouse.py

6. Changelog

v2.0.2 (git) (pypi)

Changed

  • auth_token now updates last_login attribute in database

v2.0.1 (git) (pypi)

Changed

  • alot of rewrites
  • please look at the howtouse.py and documentation!

v1.0.5 (git) (pypi)

Changed

  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyusermanager-2.0.2.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

pyusermanager-2.0.2-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file pyusermanager-2.0.2.tar.gz.

File metadata

  • Download URL: pyusermanager-2.0.2.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for pyusermanager-2.0.2.tar.gz
Algorithm Hash digest
SHA256 994ea98a81de3b386d31f3ee8d47e9f5e802a2d9a9e094ebd05001f7c6121882
MD5 7f5bbcd26e4ded6f2dddfda4a84cc448
BLAKE2b-256 5d75f465a8ccd89c2341613033d9beecfda635fc4dfa94853fd294b0f5d1d87b

See more details on using hashes here.

File details

Details for the file pyusermanager-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyusermanager-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for pyusermanager-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 100212af5f44e7b9e8e5a7276c46f7dc2d5371c43fd710bfee2f8acb98b1003c
MD5 ab3538d772fac236f39c8289f0680f5e
BLAKE2b-256 66d85f63e6480da949f792018b9f134b8160f3a9c968b4b4a8506d1915728aeb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page