{"id":18325977,"url":"https://github.com/mthaler/http-basic-auth","last_synced_at":"2025-04-09T15:54:29.036Z","repository":{"id":146920192,"uuid":"378414718","full_name":"mthaler/http-basic-auth","owner":"mthaler","description":"Example code showing how to implement HTTP basic auth in Go","archived":false,"fork":false,"pushed_at":"2021-06-19T13:51:11.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-05T19:05:07.785Z","etag":null,"topics":["golang","http-basic-auth"],"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/mthaler.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-06-19T13:07:40.000Z","updated_at":"2021-06-19T14:05:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab697179-27de-4aa2-ae36-7bc97e61b3a1","html_url":"https://github.com/mthaler/http-basic-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthaler%2Fhttp-basic-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthaler%2Fhttp-basic-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthaler%2Fhttp-basic-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthaler%2Fhttp-basic-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mthaler","download_url":"https://codeload.github.com/mthaler/http-basic-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230957543,"owners_count":18306456,"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":["golang","http-basic-auth"],"created_at":"2024-11-05T19:05:11.832Z","updated_at":"2024-12-23T11:42:49.833Z","avatar_url":"https://github.com/mthaler.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# http-basic-auth\n\nThe simplest form of web authentication is HTTP basic authentication. The request contains a header field in the form of Authorization: Basic \u003ccredentials\u003e where credentials is the Base64 encoding of ID and password joined by a single colon :, e.g. `Authorisation: Basic dGVzdDpzZWNyZXQ=`\n\n## Server\n    \nThe server will check if the `Authorization` header field is present and if the value is a valid username / password combination.\n\n### Examples\n \nThe [httpie](https://httpie.io/) is a user-friendly HTTP client that can be used to test the API:\n\n#### Missing `Authorization` header\n\n```bash\n$ http http://localhost:8080\nHTTP/1.1 401 Unauthorized\nContent-Length: 36\nContent-Type: application/json\nDate: Sat, 19 Jun 2021 13:16:34 GMT\nWww-Authenticate: Basic realm=\"Give username and password\"\n\n{\n    \"message\": \"No basic auth present\"\n}\n\n```\n\n#### Valid `Authorization` header\n       \n```bash\n$ http http://localhost:8080 \"Authorization:Basic dGVzdDpzZWNyZXQ=\"\nHTTP/1.1 200 OK\nContent-Length: 39\nContent-Type: application/json\nDate: Sat, 19 Jun 2021 13:38:01 GMT\n\n{\n    \"message\": \"welcome to golang world!\"\n}\n\n```\n    \n`dGVzdDpzZWNyZXQ=` is the Base64 encoded `test:secret` string.\n    \n## Client\n  \nThe client demonstrates how to set the `Authorization` header required for HTTP basic authentication.\n    \n## Credits\n    \nThe code is from [How to Implement HTTP Basic Auth in Go](https://blog.umesh.wtf/how-to-implement-http-basic-auth-in-gogolang).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmthaler%2Fhttp-basic-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmthaler%2Fhttp-basic-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmthaler%2Fhttp-basic-auth/lists"}