An open API service indexing awesome lists of open source software.

https://github.com/humansinput/authsystem

Tcl library that handles user authorization and registration. Uses TDBC to access the database.
https://github.com/humansinput/authsystem

Last synced: 5 months ago
JSON representation

Tcl library that handles user authorization and registration. Uses TDBC to access the database.

Awesome Lists containing this project

README

          

# AuthSystem
A module for use in Tcl 8.5/8.6 programs that provides handy API for creating and authorizating users.

Depends on TDBC (for now) and Tcllib.

## Usage
[squares]
- ``authsys::use ``: Tells AuthSystem to use this TDBC connection to read/write user data from the specified table. The specified table must contain ``authsys_username`` and ``authsystem_password`` columns, while the rest (if any) must be either optional or have a default value.
- ``authsys::register ``: Creates a user with the specified username and password. If a user exists or the username contains invalid characters, an error is thrown.
- ``authsys::passwordcorrect ``: Checks if the specified username and password are correct. If yes, returns ``1``, otherwise, returns ``0``.
- ``authsys::exists ``: Checks if the specified user is already registered. If yes, returns ``1``, otherwise, returns ``0``.
- ``authsys::authtoken []``: Creates an auth token that can be used to create user sessions. Useful for web apps, you should store the returned value as a cookie. By default, the returned token is valid for 3 days, but you can optionally specify a different number of days as the third argument. Returns a string.
- ``authsys::tokencorrect ``: Returns ``1`` if the token is valid, otherwise, returns ``0``.

## Example
See ``demo.tcl`` (requires TDBC Sqlite3 driver to be present on your system to run).

## License
As always, MIT License.