Metadata-Version: 2.1
Name: flask_lac
Version: 0.1.0
Summary: A simple authentication package for Flask applications
Home-page: https://github.com/botsarefuture/flask_lac
Author: Verso Vuorenmaa
Author-email: verso@luova.club
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: Flask>=1.1.2
Requires-Dist: Requests>=2.24.0
Requires-Dist: Werkzeug>=1.0.1

# Flask LAC

A simple authentication package for Flask applications.

## Installation

To install the package, use pip:

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

## Usage

### Initialization

First, initialize the `AuthPackage` with your Flask app:

```python
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:

```python
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:

```python
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.
