{"id":22941711,"url":"https://github.com/plaidweb/authl","last_synced_at":"2025-07-20T22:35:06.609Z","repository":{"id":47453364,"uuid":"162322538","full_name":"PlaidWeb/Authl","owner":"PlaidWeb","description":"A library for managing federated identity","archived":false,"fork":false,"pushed_at":"2025-06-19T04:56:43.000Z","size":1819,"stargazers_count":37,"open_issues_count":16,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-04T00:05:50.973Z","etag":null,"topics":["backend","federated-authentication","federated-identity","flask","hacktoberfest","identity","indieauth","oauth","oauth2-client","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PlaidWeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-18T17:20:00.000Z","updated_at":"2025-06-19T04:55:42.000Z","dependencies_parsed_at":"2023-01-31T05:15:45.104Z","dependency_job_id":"bb8d7636-cd82-4e9c-acf4-c03d112ff9f3","html_url":"https://github.com/PlaidWeb/Authl","commit_stats":{"total_commits":258,"total_committers":3,"mean_commits":86.0,"dds":"0.019379844961240345","last_synced_commit":"15bba32883ca371143419e63f61d885a87cf0788"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/PlaidWeb/Authl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlaidWeb%2FAuthl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlaidWeb%2FAuthl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlaidWeb%2FAuthl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlaidWeb%2FAuthl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlaidWeb","download_url":"https://codeload.github.com/PlaidWeb/Authl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlaidWeb%2FAuthl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266210928,"owners_count":23893343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","federated-authentication","federated-identity","flask","hacktoberfest","identity","indieauth","oauth","oauth2-client","python"],"created_at":"2024-12-14T13:44:47.264Z","updated_at":"2025-07-20T22:35:06.594Z","avatar_url":"https://github.com/PlaidWeb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Authl\nA Python library for managing federated identity\n\n[![Documentation Status](https://readthedocs.org/projects/authl/badge/?version=latest)](https://authl.readthedocs.io/en/latest/?badge=latest)\n\n## About\n\nAuthl is intended to make it easy to add federated identity to Python-based web\napps without requiring the creation of site-specific user accounts, but also\nwithout requiring the user to choose from a myriad of buttons or links to select\nany specific login provider.\n\nAll it should take is a single login form that asks for how the user wants to be\nidentified.\n\n## Current state\n\nThe basic API works, and provides an easy drop-in set of endpoints for\n[Flask](http://flask.pocoo.org).\n\nCurrently supported authentication mechanisms:\n\n* Directly authenticating against email using a magic link\n* Federated authentication against Fediverse providers\n    ([Mastodon](https://joinmastodon.org/), [Pleroma](https://pleroma.social))\n* Federated authentication against [IndieAuth](https://indieauth.net/)\n* Silo authentication against [Twitter](https://twitter.com/)\n* Test/loopback authentication for development purposes\n\nPlanned functionality:\n\n* Pluggable OAuth mechanism to easily support additional identity providers such as:\n    * OpenID Connect (Google et al)\n    * Facebook\n    * GitHub\n* OpenID 1.x (Wordpress, LiveJournal, Dreamwidth, etc.)\n* A more flexible configuration system\n\n## Rationale\n\nIdentity is hard, and there are so many competing standards which try to be the\nbe-all end-all Single Solution. OAuth and OpenID Connect want lock-in to silos,\nIndieAuth wants every user to self-host their own identity site, and OpenID 1.x\nhas fallen by the wayside. Meanwhile, users just want to be able to log in with\nthe social media they're already using (siloed or not).\n\nAny solution which requires all users to have a certain minimum level of\ntechnical ability is not a workable solution.\n\nAll of these solutions are prone to the so-called \"[NASCAR\nproblem](https://indieweb.org/NASCAR_problem)\" where every supported login\nprovider needs its own UI. But being able to experiment with a more unified UX\nmight help to fix some of that.\n\n## Documentation\n\nFull API documentation is hosted on [readthedocs](https://authl.readthedocs.io).\n\n## Usage\n\nBasic usage is as follows:\n\n1. Create an Authl object with your configured handlers\n\n    This can be done by instancing individual handlers yourself, or you can use\n    `authl.from_config`\n\n2. Make endpoints for initiation and progress callbacks\n\n    The initiation callback receives an identity string (email address/URL/etc.)\n    from the user, queries Authl for the handler and its ID, and builds a\n    callback URL for that handler to use. Typically you'll have a single\n    callback endpoint that includes the handler's ID as part of the URL scheme.\n\n    The callback endpoint needs to be able to receive a `GET` or `POST` request\n    and use that to validate the returned data from the authorization handler.\n\n    Your callback endpoint (and generated URL thereof) should also include\n    whatever intended forwarding destination.\n\n3. Handle the `authl.disposition` object types accordingly\n\n    A `disposition` is what should be done with the agent that initiated the\n    endpoint call. Currently there are the following:\n\n    * `Redirect`: return an HTTP redirection to forward it along to another URL\n    * `Notify`: return a notification to the user that they must take another\n      action (e.g. check their email)\n    * `Verified`: indicates that the user has been verified; set a session\n      cookie (or whatever) and forward them along to their intended destination\n    * `Error`: An error occurred; return it to the user as appropriate\n\n## Flask usage\n\nTo make life easier with Flask, Authl provides an `authl.flask.AuthlFlask`\nwrapper. You can use it from a Flask app with something like the below:\n\n```python\nimport uuid\nimport logging\n\nimport flask\nimport authl.flask\n\nlogging.basicConfig(level=logging.INFO)\nLOGGER = logging.getLogger(__name__)\n\napp = flask.Flask('authl-test')\n\napp.secret_key = str(uuid.uuid4())\nauthl = authl.flask.AuthlFlask(\n    app,\n    {\n        'SMTP_HOST': 'localhost',\n        'SMTP_PORT': 25,\n        'EMAIL_FROM': 'authl@example.com',\n        'EMAIL_SUBJECT': 'Login attempt for Authl test',\n        'INDIELOGIN_CLIENT_ID': authl.flask.client_id,\n        'TEST_ENABLED': True,\n        'MASTODON_NAME': 'authl testing',\n        'MASTODON_HOMEPAGE': 'https://github.com/PlaidWeb/Authl'\n    },\n    tester_path='/check_url'\n)\n\n\n@app.route('/')\n@app.route('/some-page')\ndef index():\n    \"\"\" Just displays a very basic login form \"\"\"\n    LOGGER.info(\"Session: %s\", flask.session)\n    LOGGER.info(\"Request path: %s\", flask.request.path)\n\n    if 'me' in flask.session:\n        return 'Hello {me}. Want to \u003ca href=\"{logout}\"\u003elog out\u003c/a\u003e?'.format(\n            me=flask.session['me'], logout=flask.url_for(\n                'logout', redir=flask.request.path[1:])\n        )\n\n    return 'You are not logged in. Want to \u003ca href=\"{login}\"\u003elog in\u003c/a\u003e?'.format(\n        login=flask.url_for('authl.login', redir=flask.request.path[1:]))\n\n\n@app.route('/logout/')\n@app.route('/logout/\u003cpath:redir\u003e')\ndef logout(redir=''):\n    \"\"\" Log out from the thing \"\"\"\n    LOGGER.info(\"Logging out\")\n    LOGGER.info(\"Redir: %s\", redir)\n    LOGGER.info(\"Request path: %s\", flask.request.path)\n\n    flask.session.clear()\n    return flask.redirect('/' + redir)\n```\n\nThis will configure the Flask app to allow IndieLogin, Mastodon, and email-based\nauthentication (using the server's local sendmail), and use the default login\nendpoint of `/login/`. The `index()` endpoint handler always redirects logins\nand logouts back to the same page when you log in or log out (the `[1:]` is to\ntrim off the initial `/` from the path). The logout handler simply clears the\nsession and redirects back to the redirection path.\n\nThe above configuration uses Flask's default session lifetime of one month (this\ncan be configured by setting `app.permanent_session_lifetime` to a `timedelta`\nobject, e.g. `app.permanent_session_lifetime = datetime.timedelta(hours=20)`).\nSessions will also implicitly expire whenever the application server is\nrestarted, as `app.secret_key` is generated randomly at every startup.\n\n### Accessing the default stylesheet\n\nIf you would like to access `authl.flask`'s default stylesheet, you can do it by\npassing the argument `asset='css'` to the login endpoint. For example, if you\nare using the default endpoint name of `authl.login`, you can use:\n\n```python\nflask.url_for('authl.login', asset='css')\n```\n\nfrom Python, or e.g.\n\n```html\n\u003clink rel=\"stylesheet\" href=\"{{url_for('authl.login', asset='css')}}\"\u003e\n```\n\nfrom a Jinja template.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaidweb%2Fauthl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplaidweb%2Fauthl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaidweb%2Fauthl/lists"}