{"id":45001822,"url":"https://github.com/cattlecloud/webtools","last_synced_at":"2026-02-18T22:36:20.670Z","repository":{"id":337694055,"uuid":"1149171312","full_name":"cattlecloud/webtools","owner":"cattlecloud","description":"Package webtools is a collection of helper functions, types, and abstractions for building standalone websites in Go.","archived":false,"fork":false,"pushed_at":"2026-02-10T19:57:16.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-10T22:54:37.821Z","etag":null,"topics":["go","oauth","session","web"],"latest_commit_sha":null,"homepage":"https://cattlecloud.net/go/webtools","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cattlecloud.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-03T19:59:37.000Z","updated_at":"2026-02-10T19:57:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cattlecloud/webtools","commit_stats":null,"previous_names":["cattlecloud/webtools"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/cattlecloud/webtools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cattlecloud%2Fwebtools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cattlecloud%2Fwebtools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cattlecloud%2Fwebtools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cattlecloud%2Fwebtools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cattlecloud","download_url":"https://codeload.github.com/cattlecloud/webtools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cattlecloud%2Fwebtools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29597246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T22:25:43.180Z","status":"ssl_error","status_checked_at":"2026-02-18T22:25:42.766Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["go","oauth","session","web"],"created_at":"2026-02-18T22:36:20.542Z","updated_at":"2026-02-18T22:36:20.654Z","avatar_url":"https://github.com/cattlecloud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webtools\n\nPackage webtools is a collection of helper functions, types, and abstractions\nfor building standalone websites. In particular, sites that make use of oauth\nbased sessions for user identity and authentication.\n\n### Getting Started\n\nThe `webtools` packages can be added to a Go project with `go get`.\n\n```shell\ngo get cattlecloud.net/go/webtools@latest\n```\n\n```go\nimport \"cattlecloud.net/go/webtools\"\n```\n\n### Package Contents\n\n#### package webtools\n\nFor setting common headers with correct values on `http.ResponseWriter` objects,\nincluding:\n\n- `Content-Type`\n\n```go\nwebtools.SetContentType(w, webtools.ContentTypeRSS)\n```\n\n- `X-Robots-Tag`\n\n```go\nwebtools.SetRobotsTag(w, webtools.RobotsYesIndex)\n```\n\n- `Cache-Control`\n\n```go\nwebtools.SetCacheControl(w, 24 * time.Hour)\n```\n\n- `Authorization`\n\n```go\nwebtools.SetBasicAuth(w, \"admin\", \"passw0rd\")\n```\n\nAlso helps with crafting `net/url.URL` values with correctly encoded URL\nparamter values.\n\n##### creating a url\n\n```go\nu := webtools.CreateURL(\"example.org\", \"/some/path\", map[string]string {\n  \"token\": \"abc123\",\n  \"page\":  \"2\",\n})\n```\n\n#### package webtools/middles\n\nProvides a generic sessions `http.Handler` which can be used to set and validate\nuser sessions. The primary interface is (optionally) implemented by using the\n`oauth` and `identity` packages in this module.\n\n```go\ntype Sessions[I identity.UserIdentity] interface {\n\tCreate(I, time.Duration) *http.Cookie\n\tMatch(I, *conceal.Text) error\n}\n```\n\n#### package webtools/httpclient\n\nProvides a sharable `http.Client` that sets sensible values for maintaining a\npool of idle connections.\n\n```go\nclient := httpclient.Get()\n```\n\n#### package webtools/middles/identity\n\nProvides a set of generic structs used for marshaling identity. The interfaces\nare (optionally) implemented by using the `oauth` and `identity` packages in\nthis module.\n\n```go\ntype UserIdentity any\n\ntype UserData[I UserIdentity] interface {\n\tIdentity() I\n\tToken() *conceal.Text\n}\n\ntype UserSession[I UserIdentity] interface {\n\tIdentity() I\n\tActive() bool\n}\n```\n\n#### package webtools/middles/oauth\n\nProvides implementations for cookie creation, session management, and TTL\nenabled session token caching. Intended to be used as the implementation details\nof the `middles` and `identity` packages, and by using the `nonces`, `applekeys`,\n`googlekeys`, and `microsoftkeys` packages as OAuth provider token validators.\n\n##### \n\n#### package webtools/middles/oauth/nonces\n\nProvides an implementation to manage `nonce` values used during the OAuth token\nexchange. The primary interface enables you to `Create` a nonce, and then\n`Consume` the nonce exactly once. \n\n```go\ntype Mint interface {\n\tCreate() *conceal.Text\n\tConsume(*conceal.Text) error\n}\n```\n\n#### package webtools/middles/oauth/applekeys\n\nProvides an interface and implementation for validation JWT token claims as\nissued by Apple.\n\n```go\ntype Validator interface {\n\tValidate(string) (*Claims, error)\n}\n```\n\n#### package webtools/middles/oauth/googlekeys\n\nProvides an interface and implementation for validation JWT token claims as\nissued by Google.\n\n```go\ntype Validator interface {\n\tValidate(string) (*Claims, error)\n}\n```\n#### package webtools/middles/oauth/microsoftkeys\n\nProvides an interface and implementation for validation JWT token claims as\nissued by Microsoft.\n\n```go\ntype Validator interface {\n\tValidate(string) (*Claims, error)\n}\n```\n\n### Notes on OAuth\n\nThe implementation details of what belongs in your `http.Handler` are currently\nnot a part of this suite of packages.\n\nFirstly, you'll need to enable CSRF protection, which the Go standard library\nhas good support for as of Go 1.25; e.g.\n\n```go\ncsrf := http.NewCrossOriginProtection()\n_ = csrf.AddTrustedOrigin(\"https://appleid.apple.com\")\n\n// ...\n\nserver := \u0026http.Server{\n\tAddr:    address,\n\tHandler: csrf.Handler(router),\n}\n```\n\nFor getting users logged in via their oauth provider, you'll need to have\nhandler(s) that go through the oauth handshake.\n\n### License\n\nThe `cattlecloud.net/go/webtools` module is opensource under the [BSD-3-Clause](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcattlecloud%2Fwebtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcattlecloud%2Fwebtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcattlecloud%2Fwebtools/lists"}