{"id":17055634,"url":"https://github.com/ansrivas/chi-jwt-go","last_synced_at":"2025-04-12T17:10:51.606Z","repository":{"id":35000634,"uuid":"108610391","full_name":"ansrivas/chi-jwt-go","owner":"ansrivas","description":"A very naive but almost complete method of jwt-authentication using chi and jwt-go","archived":false,"fork":false,"pushed_at":"2022-05-31T21:56:37.000Z","size":1622,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-05T02:51:47.618Z","etag":null,"topics":["chi","golang","jwt","jwt-go"],"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/ansrivas.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}},"created_at":"2017-10-28T01:26:31.000Z","updated_at":"2023-03-04T09:42:05.000Z","dependencies_parsed_at":"2022-09-04T07:50:52.454Z","dependency_job_id":null,"html_url":"https://github.com/ansrivas/chi-jwt-go","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/ansrivas%2Fchi-jwt-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansrivas%2Fchi-jwt-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansrivas%2Fchi-jwt-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansrivas%2Fchi-jwt-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ansrivas","download_url":"https://codeload.github.com/ansrivas/chi-jwt-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239952639,"owners_count":19723924,"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":["chi","golang","jwt","jwt-go"],"created_at":"2024-10-14T10:18:44.236Z","updated_at":"2025-02-21T19:31:08.493Z","avatar_url":"https://github.com/ansrivas.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"chi-jwt\n---\n\nUsing jwt-go with go-chi:\n\nInstall\n---\n\n* Clone the project and run\n\n `go get -u github.com/ansrivas/chi-jwt-go`\n\n* Create a directory named `keys` and copy the keys from the repository\n\n* Execute your program as `chi-jwt-go -keyPath keys`\n\n* Install [httpie](https://github.com/jakubroztocil/httpie) ( super awesome curl alternative )\n\n* Authenticate to the service:\n\n```\n$ http POST localhost:8080/login username=\"someone\" password=\"p@assword\"\n\nHTTP/1.1 200 OK\nContent-Length: 439\nContent-Type: text/plain; charset=utf-8\nDate: Sat, 28 Oct 2017 01:12:20 GMT\nStrict-Transport-Security: max-age=63072000; includeSubDomains\n\n{\"token\":\"some-token\"}\n```\n\n* Use `token` from previous output after `Bearer \u003ctoken_here\u003e` in below example.\n\n```\n$ http GET localhost:8080/resource Authorization:\"Bearer \u003ctoken-from-previous-step\u003e\"\n\nHTTP/1.1 200 OK\nContent-Length: 46\nContent-Type: text/plain; charset=utf-8\nDate: Sat, 28 Oct 2017 01:16:55 GMT\nStrict-Transport-Security: max-age=63072000; includeSubDomains\n\n{\"data\":\"Gained access to protected resource\"}\n```\n\nReferences\n---\n\n1. \u003chttp://www.giantflyingsaucer.com/blog/?p=5994\u003e\n2. \u003chttps://gist.github.com/kiyor/7817632\u003e\n3. \u003chttps://github.com/ianmcmahon/encoding_ssh\u003e\n4. \u003chttps://github.com/XOfSpades/authentication/blob/69bdcf4131c38bfbe31b26be120ad95f4816a5ae/README.md\u003e\n\nCreate keys\n------\n\n### .p12 format keys\n\n### Private key\n\n`keytool -genkeypair -keystore jwtsig-test-prv-ks.p12 -storetype pkcs12 -alias jwtsigtest -keyalg RSA -keysize 2048 -sigalg SHA384withRSA -dname \"CN=jwtsigtest,OU=Auth Test,O=private purpose,L=Cologne,ST=NRW,C=DE\" -validity 3652`\n\n### Public key\n\n`keytool -exportcert -alias jwtsigtest -file jwtsig-test-pub.cert -storetype pkcs12 -keystore jwtsig-test-prv-ks.p12 -rfc`\n\n`keytool -importcert -alias jwtsigtest -file jwtsig-test-pub.cert -storetype pkcs12 -keystore jwtsig-test-pub-ks.p12`\n\n`rm jwtsig-test-pub.cert`\n\n### Convert to .pem format from p12 format, this is what we will use\n\n### Private key\n\n`openssl pkcs12 -in jwtsig-test-prv-ks.p12 -nocerts -out jwtsig-test-prv-ks.pem -nodes`\n\n### Public key\n\nGenerate certificate:\n\n`openssl pkcs12 -in jwtsig-test-pub-ks.p12 -out jwtsig-test-pub-cert.pem`\n\nDetermine public key from certificate file:\n\n`openssl x509 -in jwtsig-test-pub-cert.pem -pubkey -noout \u003e jwtsig-test-pub-ks.pem`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansrivas%2Fchi-jwt-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fansrivas%2Fchi-jwt-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansrivas%2Fchi-jwt-go/lists"}