Skip to content

ateachment/SimpleAuthService

Repository files navigation

SimpleAuthService

Development of a JWT-based web application with Flask for teaching purposes

Supports login with

  • User name and password
  • Google account
  • Second-factor authentication with time-based one-time password TOTP

Includes:

  • simple UI
  • authentification web service
  • pytest file
  • OpenAPI description file
  • MySql init file

Installation

  1. Use the package manager [pip](https://pip.pypa.io/en/stable/) to install requirements.
    pip install -r requirements.txt
  2. Start MySQL/MariaDB server and run SQL script initdb.sql
  3. Copy or rename settings-template.py to settings.py and enter the appropriate connection data for the database (can be taken from initdb.sql).
  4. Create a key pair for asynchronous encryption:

    Private key:

    openssl genrsa -aes256 -out private_key.pem 2048

    Generation of the corresponding public key:

    openssl rsa -pubout -in private_key.pem -out public_key.pem

    Also copy the two keys together with the used password into the settings.py file. (Caution. Do not lose any character or add too much - not even a line break).

  5. Register the application as a client with Google as an authentication provider:

    Google developers credentials page
    https://console.developers.google.com/apis/credentials (Google account required.)

    This will provide you with a Google Client ID and a Google Client Key. Both are also copied to settings.py.

Program start

python simpleAuthService.py

Open https://127.0.0.1:5000 with the browser

Testing

Start the test program with

pytest testSimpleAuthService.py

and/or
open openapi.yaml in https://editor.swagger.io/ and test the web service with the Swagger editor.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published