{"id":16019456,"url":"https://github.com/tofran/ecto_sessions","last_synced_at":"2025-10-13T22:15:06.012Z","repository":{"id":57600913,"uuid":"472914607","full_name":"tofran/ecto_sessions","owner":"tofran","description":"👤 Elixir database backed sessions with Ecto.","archived":false,"fork":false,"pushed_at":"2024-03-31T19:27:37.000Z","size":152,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T09:03:07.905Z","etag":null,"topics":["ecto","elixir","sessions"],"latest_commit_sha":null,"homepage":"https://ecto-sessions-demo.tofran.com","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tofran.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}},"created_at":"2022-03-22T19:46:23.000Z","updated_at":"2023-03-21T22:54:44.000Z","dependencies_parsed_at":"2024-03-31T20:27:11.763Z","dependency_job_id":"61f4eb08-ba67-45e7-9658-0f01fe7af5d5","html_url":"https://github.com/tofran/ecto_sessions","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"4fd3a694276d3fd5ea5998528bf7a10c8c90683c"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tofran/ecto_sessions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tofran%2Fecto_sessions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tofran%2Fecto_sessions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tofran%2Fecto_sessions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tofran%2Fecto_sessions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tofran","download_url":"https://codeload.github.com/tofran/ecto_sessions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tofran%2Fecto_sessions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009181,"owners_count":26084555,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ecto","elixir","sessions"],"created_at":"2024-10-08T17:04:27.714Z","updated_at":"2025-10-13T22:15:05.998Z","avatar_url":"https://github.com/tofran.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ecto Sessions\n\n**Database backend sessions with Ecto.**\n\n[![ecto_sessions in hex.pm](https://img.shields.io/hexpm/v/ecto_sessions?style=flat)](https://hex.pm/packages/ecto_sessions)\n[![ecto_sessions documentation](https://img.shields.io/badge/hex.pm-docs-green.svg?style=flat)](https://hexdocs.pm/ecto_sessions/)\n\n`ecto_sessions` helps you easily and securely manage database backed sessions\nin your Ecto project.\n\nIt might be used, for example to manage authorization via cookies or API keys.\nThe medium you will use the sessions is up to the application implementation.\nEx: session id to be used in a Cookie or `X-Api-Token` for a REST API.\n\nUsing database backed session, might be very helpful in some scenarios.\nIt has quite a few benefits and drawbacks comparing to signed sessions,\nfor example `JWT` or signed cookies. It might also be used in combination\nwith them.\n\nAdvantages:\n\n- Ability to query active sessions for a given user.\n  Ex: list the devices where a user has a valid session or lit the active\n  API keys for a given project.\n- Full control of the validity: at any time your application will be able to\n  control if a given session is valid, change their expiration and even\n  revalidate expired tokens.\n- Ability to store arbitrary data, without increasing the token size.\n  Ex: Device/token name, permissions, metadata, etc.\n\nDisadvantages:\n\n- Depending on the design, you might be adding a database query on each\n  request - just like traditional sessions;\n  Note that you can use a separate database, and furthermore this code\n  might also be adapted for different backends, like key-value stores.\n- Clients and other services will not be able to inspect the contents\n  of the token. This might be useful for example to predict if a token\n  is expired before making a request.\n  This might also be considered an advantage in scenarios you don't want\n  to give any control to the client.\n\nOne design that allows you to have the benefits of stateless and\nstateful sessions combined, is to have _short-lived signed tokens_,\nand database backed sessions for _long-lived refresh tokens_.\n\n## Demo\n\nThis repository includes a full phoenix demo project inside the `./demo` directory.\nThere's a hosted live version available at [ecto-sessions-demo.tofran.com](https://ecto-sessions-demo.tofran.com/),\nfeel free to play with it and see how it works/what features it enables.\n\n## Installation\n\nThe package can be installed by adding `ecto_sessions`\nto your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:ecto_sessions, \"\u003e 0.0.0\"}\n  ]\nend\n```\n\nThen, in your ecto app create the following module:\n\n```elixir\ndefmodule MyApp.Sessions do\n  use EctoSessions,\n    repo: MyApp.Repo\nend\n```\n\nRefer to [EctoSessions module documentation](https://hexdocs.pm/ecto_sessions/EctoSessions.html) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftofran%2Fecto_sessions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftofran%2Fecto_sessions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftofran%2Fecto_sessions/lists"}