{"id":24110760,"url":"https://github.com/janlisse/zio-jwt-validator","last_synced_at":"2025-02-28T05:31:46.562Z","repository":{"id":78700869,"uuid":"574227854","full_name":"janlisse/zio-jwt-validator","owner":"janlisse","description":"A ZIO based library for validating JWT tokens. Includes fetching JWKS keys and claim validation.","archived":false,"fork":false,"pushed_at":"2024-12-29T00:21:51.000Z","size":38,"stargazers_count":1,"open_issues_count":15,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-11T01:33:38.036Z","etag":null,"topics":["authenication","jwks","jwt","scala","validation","zio"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/janlisse.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-12-04T20:12:17.000Z","updated_at":"2024-02-13T15:24:44.000Z","dependencies_parsed_at":"2025-01-11T01:33:42.159Z","dependency_job_id":"5a35aa1d-8cf8-411f-be4e-71f63b6786f4","html_url":"https://github.com/janlisse/zio-jwt-validator","commit_stats":{"total_commits":45,"total_committers":2,"mean_commits":22.5,"dds":"0.33333333333333337","last_synced_commit":"d1b7ad4fd9ab11e316ecbb67b7d4057db0b6977c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlisse%2Fzio-jwt-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlisse%2Fzio-jwt-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlisse%2Fzio-jwt-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlisse%2Fzio-jwt-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janlisse","download_url":"https://codeload.github.com/janlisse/zio-jwt-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241106168,"owners_count":19910766,"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":["authenication","jwks","jwt","scala","validation","zio"],"created_at":"2025-01-11T01:33:27.788Z","updated_at":"2025-02-28T05:31:46.541Z","avatar_url":"https://github.com/janlisse.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zio-jwt-validator\n\n[![CI/CD](https://github.com/janlisse/zio-jwt-validator/actions/workflows/ci.yml/badge.svg)](https://github.com/janlisse/zio-jwt-validator/actions/workflows/ci.yml)\n\nA [ZIO](https://zio.dev/) based library for validating JWT tokens. Includes fetching keys from JWKS and claim validation.\n\n### What this is\nYou want to protect your Scala backend API using signed JWT tokens?  \nYou don't want to hardcode public keys needed for token signature verification?  \nYou want to use JWKS over HTTPS to retrieve a matching public key?  \nYou want to perform additional validation of JWT claims, e.g. `audience` and `issuer`?  \nYou want a Scala library that implements all of this?  \nThen `zio-jwt-validator` might be for you.\n\nIt is based on zio, [zio-json](https://github.com/zio/zio-json), [zio-http](https://github.com/zio/zio-http) (for the http client) and [jwt-scala](https://jwt-scala.github.io/jwt-scala/jwt-core-jwt.html) for JWT token parsing\nand signature verification.\n\n### Installation\n\n```scala\nlibraryDependencies += \"io.github.janlisse\" %% \"zio-jwt-validator\" % \"0.1.0\"\n```\n\n### Status\n- Only validation of RSA signed tokens is currently supported, which works fine with an Authentication Provider like\n[Auth0](https://auth0.com/)\n- Validation of elliptic curve signatures will be added soon\n- Symmetric keys are not supported for the time being\n\n### Usage\nHere is a simple program to validate a JWT token using `JwtValidator`:\n```scala\n  val program = for {\n    _ \u003c- JwtValidator.validate(jwtToken)\n    _ \u003c- ZIO.logInfo(\"Successfully validated token.\")\n  } yield ()\n```\nAll sorts of possible validation errors will be returned through the error type of the returned ZIO.\nThere is a hierarchy of error types derived from `JwtValidationError`.\n\nIn order to run this program you need to provide a [ZLayer](https://zio.dev/reference/contextual/zlayer/) for a `JwtValidator`\nand a `JwksFetcher`. Note: It is recommended to use the cached version of JwksFetcher which caches the retrieved JWKS, via: `JwksFetcherLive.cached(...)`.\nIt allows to configure a custom `cacheTTL`, the default is 10 minutes.\nIf you don't want any chaching at all you can still use: `JwksFetcherLive.uncached(...)`\n\n```scala\n  val run = program.provide(\n    JwksFetcherLive.cached(\n      \"/Users/jan/.sdkman/candidates/java/current/lib/security/cacerts\",\n      \"changeit\"\n    ),\n    JwtValidatorLive.layer(\"https://your.auth.provider/.well-known/jwks.json\",)\n  )\n```\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanlisse%2Fzio-jwt-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanlisse%2Fzio-jwt-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanlisse%2Fzio-jwt-validator/lists"}