{"id":23881,"library":"imia","title":"imia","description":"Full stack authentication library for ASGI frameworks. Version 0.5.3, requires Python >=3.8.0. Active development with regular minor releases.","status":"active","version":"0.5.3","language":"python","source_language":"en","source_url":"https://github.com/alex-oleshkevich/imia","tags":["authentication","asgi","starlette","fastapi","security"],"install":[{"cmd":"pip install imia","lang":"bash","label":"Default install"},{"cmd":"pip install imia[sqlalchemy]","lang":"bash","label":"With SQLAlchemy support"}],"dependencies":[{"reason":"Optional, for SQLAlchemy user provider","package":"sqlalchemy","optional":true},{"reason":"Optional, required when using SQLAlchemy with aiosqlite","package":"aiosqlite","optional":true}],"imports":[{"note":"","wrong":"","symbol":"AuthenticationMiddleware","correct":"from imia import AuthenticationMiddleware"},{"note":"","wrong":"","symbol":"LoginManager","correct":"from imia import LoginManager"},{"note":"","wrong":"","symbol":"ImpersonateAuthenticator","correct":"from imia.contrib.impersonate import ImpersonateAuthenticator"},{"note":"","wrong":"","symbol":"InMemoryUserProvider","correct":"from imia.providers import InMemoryUserProvider"},{"note":"","wrong":"","symbol":"SQLAlchemyUserProvider","correct":"from imia.contrib.sqlalchemy import SQLAlchemyUserProvider"},{"note":"authenticate was added in 0.5.1 under imia.authentication module; top-level import does not exist.","wrong":"from imia import authenticate","symbol":"authenticate","correct":"from imia.authentication import authenticate"}],"quickstart":{"code":"from imia import AuthenticationMiddleware, LoginManager\nfrom imia.providers import InMemoryUserProvider\nfrom starlette.applications import Starlette\nfrom starlette.responses import JSONResponse\nfrom starlette.routing import Route\nimport os\n\n# Define a user provider (must implement find_by_id with connection arg)\nclass MyUserProvider(InMemoryUserProvider):\n    async def find_by_id(self, connection, user_id):\n        # InMemoryUserProvider already does this, but override for custom logic\n        return await super().find_by_id(connection, user_id)\n\nprovider = MyUserProvider({\n    '1': {'id': '1', 'name': 'Alice'},\n    '2': {'id': '2', 'name': 'Bob'},\n})\n\nlogin_manager = LoginManager(provider)\n\nasync def homepage(request):\n    user = request['user']\n    return JSONResponse({'user': user['name'] if user else None})\n\napp = Starlette(routes=[Route('/', homepage)])\napp.add_middleware(AuthenticationMiddleware, login_manager=login_manager)","lang":"python","description":"Minimal ASGI app with imia authentication middleware using in-memory user storage."},"warnings":[{"fix":"Update all UserProvider method signatures to include connection: HTTPConnection as first parameter.","message":"In v0.5.1, UserProvider methods (e.g., find_by_id, find_by_login) now require an HTTPConnection instance as the first argument. Old custom providers will fail with TypeError.","severity":"breaking","affected_versions":">=0.5.1"},{"fix":"Install with pip install imia[sqlalchemy] if using SQLAlchemy support.","message":"In v0.5.3, sqlalchemy and aiosqlite are no longer core dependencies; they are optional extras. Installing imia without extras will not include these libraries.","severity":"deprecated","affected_versions":">=0.5.3"},{"fix":"Use 'from imia.authentication import authenticate'.","message":"The authenticate function (added in v0.5.1) is in imia.authentication module, not at package root. Importing from imia.authenticate will fail.","severity":"gotcha","affected_versions":">=0.5.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Update method to: async def find_by_id(self, connection: HTTPConnection, user_id: Any): ...","cause":"UserProvider method signature change in v0.5.1: now expects connection as first argument.","error":"TypeError: find_by_id() missing 1 required positional argument: 'user_id'"},{"fix":"Upgrade imia to v0.5.1 or later: pip install imia>=0.5.1","cause":"The 'authentication' module was added in v0.5.1. Using an older version of imia.","error":"ModuleNotFoundError: No module named 'imia.authentication'"},{"fix":"Install imia with the sqlalchemy extra: pip install imia[sqlalchemy]","cause":"Since v0.5.3, sqlalchemy is an optional dependency. It is not installed by default.","error":"ModuleNotFoundError: No module named 'sqlalchemy'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}