{"id":19322630,"url":"https://github.com/picatz/jose","last_synced_at":"2025-04-22T19:31:38.748Z","repository":{"id":43741643,"uuid":"460203702","full_name":"picatz/jose","owner":"picatz","description":"🔏 JavaScript Object Signing and Encryption (JOSE)","archived":false,"fork":false,"pushed_at":"2025-01-03T02:50:50.000Z","size":106,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T03:05:37.392Z","etag":null,"topics":["golang","jose","jwe","jwk","jws","jwt"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/picatz.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}},"created_at":"2022-02-16T22:48:59.000Z","updated_at":"2025-01-03T02:50:54.000Z","dependencies_parsed_at":"2024-06-20T07:12:04.885Z","dependency_job_id":"ffac44b1-2e77-46c6-a9f0-0b142abd7b09","html_url":"https://github.com/picatz/jose","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/picatz%2Fjose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picatz%2Fjose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picatz%2Fjose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picatz%2Fjose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/picatz","download_url":"https://codeload.github.com/picatz/jose/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250308415,"owners_count":21409264,"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","jose","jwe","jwk","jws","jwt"],"created_at":"2024-11-10T01:41:53.566Z","updated_at":"2025-04-22T19:31:37.980Z","avatar_url":"https://github.com/picatz.png","language":"Go","readme":"# JOSE [![Go Reference](https://pkg.go.dev/badge/github.com/picatz/jose.svg)](https://pkg.go.dev/github.com/picatz/jose) [![Go Report Card](https://goreportcard.com/badge/github.com/picatz/jose)](https://goreportcard.com/report/github.com/picatz/jose) [![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0) \n\nJavaScript Object Signing and Encryption ([JOSE](https://datatracker.ietf.org/wg/jose/documents/)) implemented in Go.\n\n## Installation\n\n```console\n$ go get github.com/picatz/jose@latest\n```\n\n## Example Usage\n\n```go\n// Create a public/private key pair (ECDSA)\nprivate, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)\nif err != nil {\n\tpanic(err)\n}\n\n// Create a JWT token, sign it with the private key.\ntoken, err := jwt.New(\n\theader.Parameters{\n\t\theader.Type:      jwt.Type,\n\t\theader.Algorithm: jwa.ES256,\n\t},\n\tjwt.ClaimsSet{\n\t\t\"sub\":  \"1234567890\",\n\t\t\"name\": \"John Doe\",\n\t},\n\tprivate,\n)\nif err != nil {\n\tpanic(err)\n}\n\nmux := http.NewServeMux()\n\nmux.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\tbearerToken, err := jwt.FromHTTPAuthorizationHeader(r)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\ttoken, err = jwt.ParseAndVerify(bearerToken, jwt.WithKey(\u0026private.PublicKey))\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tsub, err := token.Claims.Get(jwt.Subject)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif sub != \"1234567890\" {\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tname, err := token.Claims.Get(\"name\")\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(fmt.Sprintf(\"Welcome back, %s!\", name)))\n})\n\nfmt.Println(\"Listening on http://127.0.0.1:8080\")\n\nfmt.Printf(\"Try running: curl http://127.0.0.1:8080 -H 'Authorization: Bearer %s' -v\\n\", token)\n\nerr = http.ListenAndServe(\"127.0.0.1:8080\", mux)\nif err != nil {\n\tpanic(err)\n}\n```\n\n## RFCs\n\n- [RFC7515](https://datatracker.ietf.org/doc/html/rfc7515) (**JWS**) JSON Web Signature\n- [RFC7516](https://datatracker.ietf.org/doc/html/rfc7516) (**JWE**) JSON Web Encryption\n- [RFC7517](https://datatracker.ietf.org/doc/html/rfc7517) (**JWK**) JSON Web Key\n- [RFC7518](https://datatracker.ietf.org/doc/html/rfc7518) (**JWA**) JSON Web Algorithms\n- [RFC7519](https://datatracker.ietf.org/doc/html/rfc7519) (**JWT**) JSON Web Token\n\n## History\n\n[JOSE](https://datatracker.ietf.org/wg/jose/documents/) was developed by an IETF [working group](https://www.ietf.org/how/wgs/), \n started in 2011. The group set out to develop a [JSON](https://datatracker.ietf.org/doc/html/rfc4627) syntax that could be \nused by applications to describe \"secure data objects\". It has become a well known, standardized mechanism for integrity protection \nand encryption, as well as the format for keys and algorithm identifiers to support interoperability of security services for \nprotocols that use JSON.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicatz%2Fjose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpicatz%2Fjose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicatz%2Fjose/lists"}