{"id":13507975,"url":"https://github.com/lexmag/blaguth","last_synced_at":"2025-03-21T20:32:04.342Z","repository":{"id":22820529,"uuid":"26167427","full_name":"lexmag/blaguth","owner":"lexmag","description":"Basic Access Authentication in Plug applications","archived":false,"fork":false,"pushed_at":"2018-05-17T11:05:21.000Z","size":15,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-13T19:06:02.668Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lexmag.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}},"created_at":"2014-11-04T12:16:10.000Z","updated_at":"2023-09-01T10:57:21.000Z","dependencies_parsed_at":"2022-08-21T13:30:17.109Z","dependency_job_id":null,"html_url":"https://github.com/lexmag/blaguth","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexmag%2Fblaguth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexmag%2Fblaguth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexmag%2Fblaguth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexmag%2Fblaguth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lexmag","download_url":"https://codeload.github.com/lexmag/blaguth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221818284,"owners_count":16885715,"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":["elixir"],"created_at":"2024-08-01T02:00:44.756Z","updated_at":"2024-10-28T10:44:40.493Z","avatar_url":"https://github.com/lexmag.png","language":"Elixir","funding_links":[],"categories":["Framework Components"],"sub_categories":[],"readme":"# Blaguth\n\n[![Build Status](https://travis-ci.org/lexmag/blaguth.svg)](https://travis-ci.org/lexmag/blaguth)\n[![Hex Version](https://img.shields.io/hexpm/v/blaguth.svg \"Hex Version\")](https://hex.pm/packages/blaguth)\n\n\n[Basic Access Authentication](http://tools.ietf.org/html/rfc2617) in Plug applications.\n\n## Installation\n\nAdd Blaguth as a dependency to your `mix.exs` file:\n\n```elixir\ndefp deps do\n  [{:blaguth, \"~\u003e 1.2.0\"}]\nend\n```\n\nAfter you are done, run `mix deps.get` in your shell to fetch the dependencies.\n\n## Usage\n\nAdd Blaguth on top of a Plug Stack as follows:\n\n```elixir\ndefmodule CavePlug do\n  import Plug.Conn\n  use Plug.Builder\n\n  plug Blaguth, realm: \"Secret\",\n    credentials: {\"Ali Baba\", \"Open Sesame\"}\n\n  plug :index\n\n  def index(conn, _opts) do\n    send_resp(conn, 200, \"Hello Ali Baba\")\n  end\nend\n```\n\nIf you need more precise control over authentication process:\n\n```elixir\ndefmodule AdvancedPlug do\n  import Plug.Conn\n  use Plug.Router\n\n  plug Blaguth\n\n  plug :match\n  plug :dispatch\n\n  get \"/\" do\n    send_resp(conn, 200, \"Everyone can see me!\")\n  end\n\n  get \"/secret\" do\n    if authenticated?(conn.assigns) do\n      send_resp(conn, 200, \"I'm only accessible if you know the password\")\n    else\n      Blaguth.halt_with_login(conn, \"Secret\")\n    end\n  end\n\n  defp authenticated?(%{credentials: {user, pass}}) do\n    User.authenticate(user, pass)\n  end\nend\n```\n\n## License\n\nThis software is licensed under [the ISC license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexmag%2Fblaguth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flexmag%2Fblaguth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexmag%2Fblaguth/lists"}