{"id":31933035,"url":"https://github.com/elonsoft/cookie_to_jwt_plug","last_synced_at":"2025-10-14T05:51:20.868Z","repository":{"id":57485768,"uuid":"222504513","full_name":"Elonsoft/cookie_to_jwt_plug","owner":"Elonsoft","description":"Converts cookie header to jwt token authorization header","archived":false,"fork":false,"pushed_at":"2020-06-30T11:05:44.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-17T16:54:58.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/Elonsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-18T17:23:44.000Z","updated_at":"2020-06-30T11:05:41.000Z","dependencies_parsed_at":"2022-09-11T15:02:58.113Z","dependency_job_id":null,"html_url":"https://github.com/Elonsoft/cookie_to_jwt_plug","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Elonsoft/cookie_to_jwt_plug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elonsoft%2Fcookie_to_jwt_plug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elonsoft%2Fcookie_to_jwt_plug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elonsoft%2Fcookie_to_jwt_plug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elonsoft%2Fcookie_to_jwt_plug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Elonsoft","download_url":"https://codeload.github.com/Elonsoft/cookie_to_jwt_plug/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elonsoft%2Fcookie_to_jwt_plug/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018011,"owners_count":26086237,"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-14T02:00:06.444Z","response_time":60,"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":[],"created_at":"2025-10-14T05:51:19.438Z","updated_at":"2025-10-14T05:51:20.848Z","avatar_url":"https://github.com/Elonsoft.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CookieToJwtPlug\n\nPuts authorization token from cookies to Authorization headers and\ndo refresh auth cookie.\n\nYou can put it in your Guardian pipline and think that you're working\nwith just jwt token.\n\n```elixir\ndefmodule YourApp.Guardian.Pipeline do\n  @moduledoc false\n\n  use Guardian.Plug.Pipeline,\n    otp_app: :your_app,\n    error_handler: YourApp.Guardian.ErrorHandler,\n    module: YourApp.Guardian\n\n  # Extract token from cookies.\n  plug CookieToJwtPlug\n\n  # If there is a session token, restrict it to an access token and validate it\n  plug Guardian.Plug.VerifySession, claims: %{\"typ\" =\u003e \"access\"}\n  # If there is an authorization header, restrict it to an access token\n  # and validate it\n  plug Guardian.Plug.VerifyHeader, claims: %{\"typ\" =\u003e \"access\"}\n  # Load the user if either of the verifications worked\n  plug Guardian.Plug.LoadResource, allow_blank: true\nend\n```\n\nAnd also you should put your cookies on authorization:\n\n```elixir\ndefmodule YourAppWeb.SomeController do\n  @moduledoc false\n\n  # The function that authenticate a user and returns a token for her.\n  import Auth, only: [authenticate_user: 1]\n\n  def login(conn, params) do\n    with {:ok, token} \u003c- authenticate_user(params) do\n      conn\n      |\u003e CookieToJwtPlug.put_session_token(token)\n      |\u003e render(\"index.html\")\n    end\n  end\nend\n```\n\n## Installation\n\nAdd this to your deps:\n\n```elixir\ndef deps do\n  [\n    {:cookie_to_jwt_plug, \"~\u003e 0.1\"}\n  ]\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felonsoft%2Fcookie_to_jwt_plug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felonsoft%2Fcookie_to_jwt_plug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felonsoft%2Fcookie_to_jwt_plug/lists"}