Skip to main content

A simple authentication package for Flask applications

Project description

Flask LAC

Flask LAC is a authentication package for Flask applications.

[!NOTE] This package requires a running instance of the authentication service.

Features

This

Installation

To install the package, use pip:

pip install 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-1.0.0.tar.gz (9.3 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-1.0.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flask_lac-1.0.0.tar.gz
Algorithm Hash digest
SHA256 df7b73aeac82cee32ea7b38b35ff1d79d687ad50eeb788db652e356ba3b6b2d0
MD5 399cf30900019be91f838657fb4a18ed
BLAKE2b-256 a6366e9fd1b22ae49bca06e83fee74351e5269ba01c4ecba9cfe77058f8e6fc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flask_lac-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 422b08170dcf6ac84a996d6b6682cf68e68ec698ccc143bfe35da0e8aeb51e1d
MD5 286211d373edaddcfe070a959c18e421
BLAKE2b-256 a67cf98aca612cf5d8cbc885ee1a623ea70a31fed9d1e4ddbeeb759724beb2d2

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