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 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.2.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.2.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_lac-0.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 62b4c01bd1af62796ba25087c46e7a56fca3bec9e20baa9b8e651d7ab533fcb4
MD5 7f8a33e97c3c520093e6da8a9f9e681f
BLAKE2b-256 ec010f05c3e1c19f65605145763533854b23cae4467f500fc3b44036439398c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flask_lac-0.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3288c4cd1656774dcf7f032c767f4f5bc45abd4d803174e12e729f95b2e30625
MD5 a24ff49be4991b497c60aba262fe3ead
BLAKE2b-256 0a9a6d58e600303758e96f23cb95cc6b968c06617144c47a9185a3bb3a5ecc8f

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