Skip to main content

A simple authentication package for Flask applications

Project description

Flask LAC

A simple authentication package for Flask applications.

Installation

To install the package, use pip:

pip install git+https://github.com/botsarefuture/flask_lac

Usage

Initialization

First, initialize the AuthPackage with your Flask app:

from flask import Flask
from flask_lac import AuthPackage

app = Flask(__name__)
auth = AuthPackage(app, auth_service_url="https://auth.luova.club", app_id="your_app_id")

[!IMPORTANT] To get your app_id, register as a user on the authentication service and create a new application.

Routes

The package provides several routes for authentication:

  • /login: Redirects to the external authentication service.
  • /auth_callback: Handles the authentication callback.
  • /secured_route: A secured route that requires user authentication.

Example

Here is an example of how to use the package in your Flask application:

from flask import Flask, render_template
from flask_lac import AuthPackage, login_required

app = Flask(__name__)
auth = AuthPackage(app, auth_service_url="https://auth.luova.club", app_id="your_app_id")

@app.route('/')
def index():
    return "Welcome to the Flask LAC example!"

@app.route('/secured')
@login_required
def secured():
    return render_template('secured.html', username=auth._user._info.username)

if __name__ == '__main__':
    app.run(debug=True)

User Authentication

The User class handles user authentication and information retrieval:

from flask_lac.user import User

user = User()
if user.is_authenticated():
    print("User is authenticated")
else:
    print("User is not authenticated")

License

This project is licensed under the MIT License.

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

flask_lac-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_lac-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file flask_lac-0.1.0.tar.gz.

File metadata

  • Download URL: flask_lac-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for flask_lac-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e42a3ec4347b6a6f345a3dff062d5985015b249d8735e652ed1488028e6a4397
MD5 5c1db0ea53944a6b368f750a7669e6a5
BLAKE2b-256 67f04a77155bdcec1cf33732cf46fc8a8992e32d57730c1b75b72aa157d1b5c4

See more details on using hashes here.

File details

Details for the file flask_lac-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flask_lac-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for flask_lac-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e407b9de16106561824f962ddfd3686800309ea9ee08cadc28d53791d1693c7a
MD5 7cbb3c25903b8953c1251b9aa1fc981c
BLAKE2b-256 e5c0f1e901d63736bd7f565d6448473adab65faa2e7a4fe7e6b6bec18a505681

See more details on using hashes here.

Supported by

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