{"id":19133586,"url":"https://github.com/hashload/horse-basic-auth","last_synced_at":"2026-03-01T19:02:29.578Z","repository":{"id":43824715,"uuid":"197097160","full_name":"HashLoad/horse-basic-auth","owner":"HashLoad","description":"Middleware for Basic Authentication in HORSE","archived":false,"fork":false,"pushed_at":"2023-08-04T13:57:44.000Z","size":45,"stargazers_count":53,"open_issues_count":1,"forks_count":15,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-14T00:32:24.973Z","etag":null,"topics":["auth","authentication","basic","basic-authentication","horse","middleware"],"latest_commit_sha":null,"homepage":"https://horse.hashload.com","language":"Pascal","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/HashLoad.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}},"created_at":"2019-07-16T01:21:28.000Z","updated_at":"2024-02-15T23:31:40.000Z","dependencies_parsed_at":"2023-09-25T23:32:46.324Z","dependency_job_id":null,"html_url":"https://github.com/HashLoad/horse-basic-auth","commit_stats":{"total_commits":38,"total_committers":7,"mean_commits":5.428571428571429,"dds":0.2894736842105263,"last_synced_commit":"20a2ba1810a6732818413372ec7aed7100239c6a"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-basic-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-basic-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-basic-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-basic-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HashLoad","download_url":"https://codeload.github.com/HashLoad/horse-basic-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240214566,"owners_count":19766263,"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":["auth","authentication","basic","basic-authentication","horse","middleware"],"created_at":"2024-11-09T06:23:00.447Z","updated_at":"2025-11-12T19:03:10.265Z","avatar_url":"https://github.com/HashLoad.png","language":"Pascal","readme":"# horse-basic-auth\n\u003cb\u003ehorse-basic-auth\u003c/b\u003e is an official middleware for working with basic authentication in APIs developed with the \u003ca href=\"https://github.com/HashLoad/horse\"\u003eHorse\u003c/a\u003e framework.\n\u003cbr\u003eWe created a channel on Telegram for questions and support:\u003cbr\u003e\u003cbr\u003e\n\u003ca href=\"https://t.me/hashload\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/telegram-join%20channel-7289DA?style=flat-square\"\u003e\n\u003c/a\u003e\n\n## ⚙️ Installation\nInstallation is done using the [`boss install`](https://github.com/HashLoad/boss) command:\n``` sh\nboss install horse-basic-auth\n```\nIf you choose to install manually, simply add the following folders to your project, in *Project \u003e Options \u003e Resource Compiler \u003e Directories and Conditionals \u003e Include file search path*\n```\n../horse-basic-auth/src\n```\n\n## ✔️ Compatibility\nThis middleware is compatible with projects developed in:\n- [X] Delphi\n- [X] Lazarus\n\n## ⚡️ Quickstart Delphi\n```delphi\nuses \n  Horse, \n  Horse.BasicAuthentication, // It's necessary to use the unit\n  System.SysUtils;\n\nbegin\n  // It's necessary to add the middleware in the Horse:\n  THorse.Use(HorseBasicAuthentication(\n    function(const AUsername, APassword: string): Boolean\n    begin\n      // Here inside you can access your database and validate if username and password are valid\n      Result := AUsername.Equals('user') and APassword.Equals('password');\n    end));\n    \n  // The default header for receiving credentials is \"Authorization\".\n  // You can change, if necessary:\n  // THorse.Use(HorseBasicAuthentication(MyCallbackValidation, THorseBasicAuthenticationConfig.New.Header('X-My-Header-Authorization')));\n\n  // You can also ignore routes:\n  // THorse.Use(HorseBasicAuthentication(MyCallbackValidation, THorseBasicAuthenticationConfig.New.SkipRoutes(['/ping'])));\n\n  THorse.Get('/ping',\n    procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)\n    begin\n      Res.Send('pong');\n    end);\n\n  THorse.Listen(9000);\nend;\n```\n\n## ⚡️ Quickstart Lazarus\n```delphi\n{$MODE DELPHI}{$H+}\n\nuses\n  {$IFDEF UNIX}{$IFDEF UseCThreads}\n  cthreads,\n  {$ENDIF}{$ENDIF}\n  Horse,\n  Horse.BasicAuthentication, // It's necessary to use the unit\n  SysUtils;\n\nprocedure GetPing(Req: THorseRequest; Res: THorseResponse; Next: TNextProc);\nbegin\n  Res.Send('Pong');\nend;\n\nfunction DoLogin(const AUsername, APassword: string): Boolean;\nbegin\n  // Here inside you can access your database and validate if username and password are valid\n  Result := AUsername.Equals('user') and APassword.Equals('password');\nend;\n\nbegin\n  // It's necessary to add the middleware in the Horse:\n  THorse.Use(HorseBasicAuthentication(DoLogin));\n\n  // The default header for receiving credentials is \"Authorization\".\n  // You can change, if necessary:\n  // THorse.Use(HorseBasicAuthentication(MyCallbackValidation, THorseBasicAuthenticationConfig.New.Header('X-My-Header-Authorization')));\n\n  // You can also ignore routes:\n  // THorse.Use(HorseBasicAuthentication(MyCallbackValidation, THorseBasicAuthenticationConfig.New.SkipRoutes(['/ping'])));\n\n  THorse.Get('/ping', GetPing);\n\n  THorse.Listen(9000);\nend.\n```\n\n## 📌 Status Code\nThis middleware can return the following status code:\n* [401](https://httpstatuses.com/401) - Unauthorized\n* [500](https://httpstatuses.com/500) - InternalServerError\n\n## ⚠️ License\n`horse-basic-auth` is free and open-source middleware licensed under the [MIT License](https://github.com/HashLoad/horse-basic-auth/blob/master/LICENSE). \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashload%2Fhorse-basic-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashload%2Fhorse-basic-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashload%2Fhorse-basic-auth/lists"}