{"id":15887939,"url":"https://github.com/iwpnd/fiber-key-auth","last_synced_at":"2025-03-20T09:30:23.538Z","repository":{"id":57632866,"uuid":"412803391","full_name":"iwpnd/fiber-key-auth","owner":"iwpnd","description":"fiber api key authentication middleware","archived":false,"fork":false,"pushed_at":"2024-05-04T14:06:52.000Z","size":1999,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T15:39:39.343Z","etag":null,"topics":["api","gofiber","golang","security"],"latest_commit_sha":null,"homepage":"","language":"Go","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/iwpnd.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-02T13:24:34.000Z","updated_at":"2024-07-10T13:28:49.000Z","dependencies_parsed_at":"2024-03-10T10:37:40.323Z","dependency_job_id":"3ee7a8e7-04b2-4624-9d45-06d0693babab","html_url":"https://github.com/iwpnd/fiber-key-auth","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwpnd%2Ffiber-key-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwpnd%2Ffiber-key-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwpnd%2Ffiber-key-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwpnd%2Ffiber-key-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iwpnd","download_url":"https://codeload.github.com/iwpnd/fiber-key-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244585556,"owners_count":20476756,"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":["api","gofiber","golang","security"],"created_at":"2024-10-06T06:05:46.964Z","updated_at":"2025-03-20T09:30:23.239Z","avatar_url":"https://github.com/iwpnd.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\nOn deployment inject API keys authorized to use your service. Every call to a private\nendpoint of your service has to include a `header['x-api-key']` attribute that is\nvalidated against the API keys (starting with: `API_KEY_`) in your environment.\nIf it is present, a request is authorized. If it is not fiber returns `401 Unauthorized`.\nUse this either as a middleware the usage.\n\n## Built With\n\n- [fiber](https://github.com/gofiber/fiber/v2)\n\n\u003c!-- GETTING STARTED --\u003e\n\n## Getting Started\n\n### Installation\n\n```sh\ngo get github.com/iwpnd/fiber-key-auth\n```\n\n## Usage\n\nAs Middleware:\n\n```go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/iwpnd/fiber-key-auth\"\n  \"github.com/gofiber/fiber/v2\"\n)\n\nos.Setenv(\"API_KEY_TEST\", \"valid\")\n\nfunc main() {\n    app := fiber.New()\n\n    app.Use(keyauth.New())\n\n    // or optionally with structured error message\n    // app.Use(keyauth.New(WithStructuredErrorMsg()))\n\n    app.Get(\"/\", func(c *fiber.Ctx) error {\n        return c.SendString(\"Hello, World 👋!\")\n    })\n\n    app.Listen(\":3000\")\n}\n```\n\nNow try to access your `/` route.\n\n```bash\ncurl localhost:3000\n\n\u003e\u003e \"no api key\" # or {\"message\": \"no api key\"}\n\ncurl localhost:3000 -H \"x-api-key: invalid\"\n\n\u003e\u003e \"invalid api key\" # or {\"message\": \"invalid api key\"}\n\ncurl localhost:3000 -H \"x-api-key: valid\"\n\n\u003e\u003e \"Hello, World 👋!\"\n```\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n\u003c!-- CONTACT --\u003e\n\n## Contact\n\nBenjamin Ramser - [@imwithpanda](https://twitter.com/imwithpanda) - ahoi@iwpnd.pw  \nProject Link: [https://github.com/iwpnd/fiber-key-auth](https://github.com/iwpnd/fiber-key-auth)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwpnd%2Ffiber-key-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiwpnd%2Ffiber-key-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwpnd%2Ffiber-key-auth/lists"}