Skip to main content

Simple auth decorators for Flask, FastAPI, and Django — powered by easy-auth.dev

Project description

⚡ EasyAuth SDK

auth made so eassyy

One line to protect a route. One line to get user data. That's the whole integration.

🌐 easy-auth.dev  |  📦 EasyAuth Server  |  📖 Full Docs & Self-Hosting


You already have an app. Here's the entire auth layer:

# Flask
@app.route("/dashboard")
@login_required                          # ← done
def dashboard(token):
    return "You're in."
# FastAPI
@app.get("/dashboard")
async def dashboard(token: str = Depends(login_required)):   # ← done
    return {"status": "in"}
# Django
@easyauth_login_required                 # ← done
def dashboard(request, token):
    return JsonResponse({"status": "in"})

No sessions. No JWT setup. No middleware. One line.


Setup

Drop the files into your project, open the SDK file for your framework, and fill in three fields:

connector = LoginConnector(
    username     = "your_username",
    service_name = "your_service_name",
    api_key      = "your_api_key",       # ← from your EasyAuth dashboard
)

That's the entire setup. Now import into your app:

# Flask
from easyauth_flask import login_required, login_required_redirect, fetch_user_data, connector
# FastAPI
from fastapi import Depends
from easyauth_fastapi import login_required, make_login_required_redirect, fetch_user_data, UserData, connector
# Django
from easyauth_django import (
    login_required as easyauth_login_required,
    login_required_redirect as easyauth_login_required_redirect,
    fetch_user_data,
    connector,
    # class-based views
    LoginRequiredMixin, LoginRequiredRedirectMixin, FetchUserDataMixin,
)

Every route in your app can now be protected.


Protect a route

@login_required
def dashboard(token):
    ...

Unauthenticated → 401. Authenticated → gets through. Token injected automatically.


Get user data

@fetch_user_data
def profile(username, user_data, token):
    return jsonify({"hello": username, "data": user_data})

username, user_data, and token — all injected. No API calls, no parsing, just use them.


Redirect instead of 401?

@login_required_redirect(redirect_url="/login")
def dashboard(token):
    ...

Same thing, just sends the user to your login page instead.


Tokens? Handled.

First visit        →  token arrives in URL  →  saved to cookie automatically
Every visit after  →  cookie used silently  →  nothing to do
Token expires      →  401 or redirect       →  user logs in again

You never touch a cookie or a session.


Write user data

connector.send_or_update_user_data(token, {"plan": "pro", "onboarded": True})

One call. Comes back in user_data on every @fetch_user_data request.


⚠️ Django note: Django ships its own login_required. Always import with an alias: from easyauth_django import login_required as easyauth_login_required


Want to know more?

The EasyAuth server repo has the full picture — how the auth flow works, security details, self-hosting guide, and API reference if you want to build your own integration.


auth made so eassyy ⚡

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

easy_auth_sdk-0.1.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

easy_auth_sdk-0.1.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file easy_auth_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: easy_auth_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for easy_auth_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f9d367500f4d007244987c624fd1011b833e5e00c2f7445688a62ca4b797e395
MD5 338b55426eb86b8b371a97b5886570ae
BLAKE2b-256 cb59edff534e21b10f2798ace1ca632d61d8062a101d479c3dd655f2ae18d7b4

See more details on using hashes here.

File details

Details for the file easy_auth_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: easy_auth_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for easy_auth_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8be71277bb93de9117ff7b0323bbcb71592eb6c69891e103fd3f86f2136728f0
MD5 6d68cd32cb3362d20c43b899f0b3cc8c
BLAKE2b-256 a9edafb4dc269298a0d8f9f6a9c1406c4885beb5037759beacd297f358301e67

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