{"id":13508007,"url":"https://github.com/sajmoon/mellon","last_synced_at":"2026-02-18T21:02:42.313Z","repository":{"id":30142619,"uuid":"33692748","full_name":"sajmoon/mellon","owner":"sajmoon","description":"Authentication module for Plug applications","archived":false,"fork":false,"pushed_at":"2016-04-07T21:50:01.000Z","size":26,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T18:43:40.489Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/sajmoon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-09T21:04:43.000Z","updated_at":"2023-09-01T10:54:38.000Z","dependencies_parsed_at":"2022-08-17T20:05:33.152Z","dependency_job_id":null,"html_url":"https://github.com/sajmoon/mellon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sajmoon/mellon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajmoon%2Fmellon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajmoon%2Fmellon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajmoon%2Fmellon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajmoon%2Fmellon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sajmoon","download_url":"https://codeload.github.com/sajmoon/mellon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajmoon%2Fmellon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-08-01T02:00:45.320Z","updated_at":"2026-02-18T21:02:42.282Z","avatar_url":"https://github.com/sajmoon.png","language":"Elixir","funding_links":[],"categories":["Framework Components"],"sub_categories":[],"readme":"Mellon\n======\n\n[![Build Status](https://travis-ci.org/sajmoon/mellon.svg?branch=master)](https://travis-ci.org/sajmoon/mellon)\n\nAn authentication module for Plug applications.\n\n## Intallation\n```elixir\ndefp deps do\n  [{:mellon, \"~\u003e 0.1.1\"}]\nend\n```\n\n## How to use\n\nSee /examples for a working example.\n\n```elixir\ndefmodule MyApp do\n  import Plug.Conn\n  use Plug.Builder\n\n  plug Mellon, validator: {MyApp, :validate, []}, header: \"X-AUTH\"\n\n  plug :index\n\n  def validate({conn, token}) do\n    case token do\n      \"ValidToken\" -\u003e {:ok, {\"userdata\"}, conn}\n      _ -\u003e {:error, [], conn}\n  end\n\n  def index(conn, _opts) do\n    send_resp(conn, 200, \"Secure area\")\n  end\nend\n```\n\nTo authenticated for this example using curl you might do the following:\n\n```bash\ncurl --header \"X-AUTH: Token: ValidToken\" localhost:4000/hello\n```\n\n## Configuration\nYou can configure some parameters while initializing Mellon.\n\n**Required**\n\n`validator`: The function that validates the token. Must return {:ok, userdata, conn} if valid and {:error, conn} if not.\n\n**Optional**\n\n`header`: The http header used for tokens. Will default to  'Authorization'.\n\n`block`: Boolean representing if we should return a 401 and stop the chain, if the user is unauthenticated. set block: false, and you can handle displaying a message, oredirecting from the controller.\n\n\n## Return object from validator\nThe validator can return some options.\n\nAll requests that are authenticated should return\n```\n{:ok, cargo, conn}\n```\n\ncargo can be any object that you would like to pass along. it will be assigned to the request so you can access it later in your controller.\nIt will be assigned to `:credentials`. To access it later you could do the following: `conn.assigns[:credentials]`.\n\nIf authentication fails you should return `{:error, options, conn}`.\n\nWhere options is a `Keyword` containing `status:` and `message`.\nBoth are optional.\n\nIn case you want a custom Unauthenticated message include `[message: 'Get out of here!']`\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajmoon%2Fmellon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsajmoon%2Fmellon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajmoon%2Fmellon/lists"}