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-0.8.9.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-0.8.9-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_lac-0.8.9.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-0.8.9.tar.gz
Algorithm Hash digest
SHA256 eed0bbdefc5a635ad5846f0d341d5cdc44baab1b5d9f811dd137a3b0a96e54eb
MD5 58b666542c0a09fe56c4100da2d0cdde
BLAKE2b-256 abfbb9cefda14c5b37732d6c9398f5b62d31b9b969a697afba69074821e14c69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flask_lac-0.8.9-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-0.8.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6f4546fd25f344c9bd7ecb1afdb8b84a990015a557359af1adca9a7405fa6fcf
MD5 04fdc27849c43630bf34b7b354d35716
BLAKE2b-256 afa7a8e32ec7611414975852de444276e62b0ca1a8bf667fb6dc933e09fe8917

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