Skip to main content

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

  • 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

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

6. Changelog

v2.0.10 (git) (pypi)

Added

  • AD_Config now has the attribute ca_file. If this is specified it will create an TLS Context needed for ldaps connections

v2.0.8 (git) (pypi)

Bugfixes

  • fixed ip not updating on successfull login in function create of Token.Auth class

v2.0.7 (git) (pypi)

Changed

  • added AuthProvider Class so we have an app wide possibility to check groups and other stuff

v2.0.6 (git) (pypi)

Changed

  • avatar folder is now part of the general config

v2.0.5 (git) (pypi)

Changed

  • 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

v2.0.4 (git) (pypi)

Changed

  • 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

v2.0.3 (git) (pypi)

Changed

  • fixed bug in activation token creation
  • you can now set the lifetime of a token with set_lifetime on the token object

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

Release files for pyusermanager 2.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyusermanager 2.0.10
File Size Uploaded
pyusermanager-2.0.10.tar.gz 16.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyusermanager 2.0.10
File Interpreter ABI Platform
pyusermanager-2.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 39.0 kB

Release files / pyusermanager-2.0.10.tar.gz

Download URL pyusermanager-2.0.10.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
821da608dec9f0faff6238e79620a2d8a2bd1d04352d0f06a4cae00b3bd178cf
BLAKE2b-256 checksum
How to use checksums
4bcaca2fd4ef13d4595692f0e106eb0d9f39925453a6a38641a410c9c2770967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.2

Release files / pyusermanager-2.0.10-py3-none-any.whl

Download URL pyusermanager-2.0.10-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee19550b337c941065ea6dd8b4f0c277194a3802614824fec1ac5716a42366b6
BLAKE2b-256 checksum
How to use checksums
fdce201c0525a287dc718d4a669d72aae9365926b24129abac1cf5433f2c78e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

2.0.10 This release

2 release files

2.0.9

1 release file

2.0.8

1 release file

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

3 release files

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page