A collection of tools for user authentication and data management. The library is released under the MIT License and the documentation is generated by an AI trained by OpenAI.
Project description
Table of Contets
- sixauth
- Installation
- Usage
- Instancing
- Remote or Local Connections
- Setting Values
- Signing Up
- Logging In
- Saving Data
- Loading Data
- Deleting Data
- Removing User
- Exceptions
- sixauth.main
- License and Disclaimer
- Authors
sixauth
sixauth is a collection of tools for user authentication and data management. The library is released under the MIT License and the documentation is generated by an AI trained by OpenAI.
The sixauth
module provides a simple way to handle user authentication and data storage on a remote server or your local machine. The AuthSesh
class allows you to sign up, log in, and manage their data in the database. For more details and examples, see the AuthSesh class documentation.
Installation
You can install sixauth using Python's built-in package manager:
$ pip install sixauth
Or by downloading this repo and moving the sixauth folder where its needed.
Usage
Instancing
To use the AuthSesh
class, you first need to create an instance of the class. There are two ways to do this, with a context manager or without.
With Context Manager
The AuthSesh
class can be used as a context manager:
from sixauth import AuthSesh
with AuthSesh() as auth:
# ...
This will automatically log out and terminate the session when the context ends.
Without Context Manager
The AuthSesh
class can also be used without a context manager:
from sixauth import AuthSesh
auth = AuthSesh()
# ...
When you are done with the instance, you have to use the terminate()
method to save your work and properly close connections:
auth.terminate()
IMPORTANT: If you do not do this, nothing you do will save.
Remote or Local Connections
When creating a AuthSesh
instance there are a few options for where the instance will connect to. You can only pick from one of these, if you provide an address and a path, it will connect to the server and disreguard the path given.
Current Working Directory
The simplest is connecting to a database in the current working directory of your script:
AuthSesh()
This will create a database.db file in the current working directory if one is not already there.
Local Folder
Next is connecting to a database in a path specified as a paramater:
AuthSesh(Path="pathto/database/folder")
This will create a database.db file in the specified path if one is not already there, it will not make the folder if it doesnt exsist though.
Servers
Lastly, connecting to a remote server:
AuthSesh(Address="0.0.0.0:5678")
This will establish a secure connection to the remote server provided. If you want to host a server look at Hosting a Server.
Setting Values
In order to authenticate a user we need their name and password. You do that with the set_vals()
method:
auth.set_vals("username", "password")
You can call this method at anytime to change the user. However if login()
is not called before attempting to manage data, it will still be connected to the previous user.
Signing Up
Once a username and password are set, you use the signup()
method to sign up:
auth.signup()
If the signup is successful, you then have to login to actually manage user data.
Logging In
Once you're ready to login, you can use the login()
method to log in to the server:
auth.login()
If the login is successful, you can start managing the database.
Saving Data
After you've seccessfully logged in, you use the save()
mathod to save data into the database:
auth.save("user_data/profile", {"name": "John Doe", "email": "johndoe@example.com"})
Data in the database is stored in a dictonary and parsed based on the the path provided.
Loading Data
You access data in the database with the load()
method:
data = auth.load("user_data/profile")
This will will return the data in the specified location, if no location is provided, it will return the whole dictionary.
Deleting Data
To delete data in the database, you use the delete()
method:
auth.delete("user_data/profile")
Removing User
Finally, if you'd like to delete the user from the database, you use the remove()
method:
auth.remove()
Exceptions
The AuthSesh
class raises the following exceptions:
AuthenticationError
: Raised if there is an error authenticating the user.DataError
: Raised if there is an error accessing or modifying the data on the server.LocationError
: Raised if the specified location does not exist on the server.PasswordError
: Raised if the password is incorrect or invalid.UsernameError
: Raised if the username is invalid or already in use.
sixauth.main
The sixauth.main
module provides all of the functionallity of the sixauth
module, and then some. The AuthSesh
class is basically just a wrapper for all the functions in this module. If you wish to use any of the raw functions in this module, it is recomended that you already have a very strong understanding of authentication, databases, and all the jazz. I tried my best to explain what happens in the comments of each of the functions, you can read them here.
Hosting a Server
This module provides a very basic python server for AuthSesh
instances to connect to. You can start it with the server()
function:
from sixauth.main import server
server("0.0.0.0", 5678)
This will start a server in the console on port 5678
and will look for all incoming ip addresses. There are also a few keyword debug booleans, debug
and log_senseitive_info
. The keyword option, cache_threshold
, sets how long, in seconds, a user has to be inactive on the server before their cache position is deleted.
License and Disclaimer
The sixauth library is licensed under the MIT License, which means it is free to use and distribute for both personal and commercial purposes. The documentation for the library has been generated by an AI trained by OpenAI, and may not be entirely accurate or up-to-date. It is recommended to consult the source code of the library for the most accurate information.
Authors
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
Built Distribution
File details
Details for the file sixauth-1.0.2.tar.gz
.
File metadata
- Download URL: sixauth-1.0.2.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10ab970d3b468e1f205366a26dce9c8db11cb8ffeca08007821b6148d945f6ea |
|
MD5 | 5381806b92adfa9dbb868ef53ff7e10d |
|
BLAKE2b-256 | 5a01043de5ea4da86142203adbf754e100c85da4281c294e2c6abdde74fdfbbe |
File details
Details for the file sixauth-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: sixauth-1.0.2-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3478976c865ff1af8e0470872d8bac8fe2bd9f375d4d49c2f8570bf7fa3693f |
|
MD5 | 3c5befd1000c0e9003e290e66e1ac2b9 |
|
BLAKE2b-256 | 80f8e1798c1a08f5855abff73cf8a36f539aa2b926fbd99e56c117600adf9639 |