{"id":17256611,"url":"https://github.com/princemaple/elixir-jwt","last_synced_at":"2025-04-09T16:21:18.870Z","repository":{"id":18441094,"uuid":"83643051","full_name":"princemaple/elixir-jwt","owner":"princemaple","description":"Yet Another JWT Lib for Elixir","archived":false,"fork":false,"pushed_at":"2025-03-08T04:58:37.000Z","size":140,"stargazers_count":16,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T16:21:03.282Z","etag":null,"topics":["elixir","jwt"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/yajwt","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/princemaple.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":"2017-03-02T06:30:06.000Z","updated_at":"2025-03-08T04:57:48.000Z","dependencies_parsed_at":"2023-01-13T19:49:57.582Z","dependency_job_id":"e8a9ff05-c4f8-466e-948e-9186e05c6277","html_url":"https://github.com/princemaple/elixir-jwt","commit_stats":{"total_commits":133,"total_committers":7,"mean_commits":19.0,"dds":"0.48120300751879697","last_synced_commit":"bcf2e207c86ef72e6525ade3378c10aa7a2c7113"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princemaple%2Felixir-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princemaple%2Felixir-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princemaple%2Felixir-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princemaple%2Felixir-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/princemaple","download_url":"https://codeload.github.com/princemaple/elixir-jwt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065287,"owners_count":21041872,"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":["elixir","jwt"],"created_at":"2024-10-15T07:14:51.247Z","updated_at":"2025-04-09T16:21:18.833Z","avatar_url":"https://github.com/princemaple.png","language":"Elixir","readme":"# Yet another JWT lib for Elixir\n\nThis is a rewrite of [json_web_token_ex](https://github.com/garyf/json_web_token_ex)\nwith [jwt_claims_ex](https://github.com/garyf/jwt_claims_ex) merged in,\nboth created by [@garyf](https://github.com/garyf).\n\nMany things were simplified during the rewrite, code was cleaned up as well.\n\n## Installation\n\nThe package can be installed by adding `yajwt` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:yajwt, \"~\u003e 1.0\"}]\nend\n```\n\n## Usage\n\n### JWT.sign(claims, options)\n\nReturns a JSON Web Token string\n\n`claims` (required) map\n\n`options` (required) map\n\n* **alg** (optional, default: `\"HS256\"`)\n* **key** (required unless alg is \"none\")\n\nInclude any JWS JOSE header parameters ([RFC 7515][rfc7515]) in the options map\n\nExample\n\n```elixir\n\n# sign with default algorithm, HMAC SHA256\njwt = JWT.sign(%{foo: \"bar\"}, %{key: \"gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C\"})\n\n# sign with RSA SHA256 algorithm\nprivate_key = JWT.Algorithm.RsaUtil.private_key(\"path/to/\", \"key.pem\")\nopts = %{\n  alg: \"RS256\",\n  key: private_key\n}\n\njwt = JWT.sign(%{foo: \"bar\"}, opts)\n\n# unsecured token (algorithm is \"none\")\njwt = JWT.sign(%{foo: \"bar\"}, %{alg: \"none\"})\n\n```\n\n### JWT.verify(jwt, options)\n\nReturns a tuple, either:\n* \\{:ok, claims\\}, a JWT claims set map, if the Message Authentication Code (MAC), or signature, is verified\n* \\{:error, exception}, otherwise\n\n`\"jwt\"` (required) is a JSON web token string\n\n`options` (required) map\n\n* **alg** (optional, default: `\"HS256\"`)\n* **key** (required unless alg is \"none\")\n\nExample\n\n```elixir\n\nsecure_jwt_example = \"eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt.cGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n\n# verify with default algorithm, HMAC SHA256\n{:ok, claims} = JWT.verify(secure_jwt_example, %{key: \"gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C\"})\n\n# Or with the bang version\nclaims = JWT.verify!(secure_jwt_example, %{key: \"gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C\"})\n\n# verify with RSA SHA256 algorithm\nopts = %{\n  alg: \"RS256\",\n  key: \u003c RSA public key \u003e\n}\n\n{:ok, claims} = JWT.verify(jwt, opts)\n\n# unsecured token (algorithm is \"none\")\nunsecured_jwt_example = \"eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt.\"\n\n{:ok, claims} = JWT.verify(unsecured_jwt_example, %{alg: \"none\"})\n\n```\n\n### Supported encryption algorithms\n\nalg Param Value | Digital Signature or MAC Algorithm\n------|------\nHS256 | HMAC using SHA-256 per [RFC 2104][rfc2104]\nHS384 | HMAC using SHA-384\nHS512 | HMAC using SHA-512\nRS256 | RSASSA-PKCS-v1_5 using SHA-256 per [RFC3447][rfc3447]\nRS384 | RSASSA-PKCS-v1_5 using SHA-384\nRS512 | RSASSA-PKCS-v1_5 using SHA-512\nES256 | ECDSA using P-256 and SHA-256 per [DSS][dss]\nES384 | ECDSA using P-384 and SHA-384\nES512 | ECDSA using P-521 and SHA-512\nnone | No digital signature or MAC performed (unsecured)\n\n### Registered claim names\n\nThe following claims are supported. They are validated when the JWT is verified.\n* **iss** (Issuer)\n* **sub** (Subject)\n* **aud** (Audience)\n* **exp** (Expiration Time)\n* **nbf** (Not Before)\n* **iat** (Issued At)\n* **jti** (JWT ID)\n\n[rfc2104]: http://tools.ietf.org/html/rfc2104\n[rfc3447]: http://tools.ietf.org/html/rfc3447\n[rfc7515]: http://tools.ietf.org/html/rfc7515\n[rfc7516]: http://tools.ietf.org/html/rfc7516\n[rfc7518]: http://tools.ietf.org/html/rfc7518\n[rfc7519]: http://tools.ietf.org/html/rfc7519\n[dss]: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf\n\n[thomson-postel]: https://tools.ietf.org/html/draft-thomson-postel-was-wrong-00\n\n[travis]: https://travis-ci.org/garyf/json_web_token_ex\n[ci_img]: https://travis-ci.org/garyf/json_web_token_ex.svg?branch=master\n[hex_docs]: http://hexdocs.pm/json_web_token\n[hd_img]: http://img.shields.io/badge/docs-hexpm-blue.svg\n\n[jwt_claims]: https://github.com/garyf/jwt_claims_ex\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprincemaple%2Felixir-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprincemaple%2Felixir-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprincemaple%2Felixir-jwt/lists"}