{"id":21700398,"url":"https://github.com/articulate/authentic-rb","last_synced_at":"2025-07-22T18:33:41.756Z","repository":{"id":56842661,"uuid":"154184642","full_name":"articulate/authentic-rb","owner":"articulate","description":"Proper validation of JWT's against JWK's. Inspired by  https://github.com/articulate/authentic.","archived":false,"fork":false,"pushed_at":"2020-07-28T04:17:47.000Z","size":42,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":54,"default_branch":"master","last_synced_at":"2025-06-26T11:49:39.355Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":false,"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/articulate.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":"2018-10-22T17:17:46.000Z","updated_at":"2021-02-11T18:44:26.000Z","dependencies_parsed_at":"2022-09-01T06:31:45.774Z","dependency_job_id":null,"html_url":"https://github.com/articulate/authentic-rb","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/articulate/authentic-rb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/articulate%2Fauthentic-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/articulate%2Fauthentic-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/articulate%2Fauthentic-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/articulate%2Fauthentic-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/articulate","download_url":"https://codeload.github.com/articulate/authentic-rb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/articulate%2Fauthentic-rb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266552505,"owners_count":23947174,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-25T20:14:12.856Z","updated_at":"2025-07-22T18:33:41.718Z","avatar_url":"https://github.com/articulate.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# authentic-rb\n\nRuby clone of [@authentic/authentic](https://github.com/articulate/authentic). A simple library to validate JWTs against JWKs.\n\n## Installation\n\n``` bash\ngem install authentic-rb\n```\n\n... or with [Bundler](https://bundler.io/man/bundle-add.1.html):\n\n```bash\nbundle add authentic-rb\n```\n\n## Usage\n\nInstantiate `Authentic::Validator` with an options hash, which must contain an `iss_whitelist` array listing the `token.payload.iss` values you will accept. For example:\n\n| Provider | Sample `iss_whitelist` |\n| -------- | ------------------- |\n| [Auth0](https://auth0.com/) | `[ 'https://${tenant}.auth0.com/' ]` |\n| [Okta](https://www.okta.com/) | `[ 'https://${tenant}.oktapreview.com/oauth2/${authServerId}' ]` |\n\nThere are two basic entry points for validation. `ensure_valid` and `valid`. `valid` basically wraps `ensure_valid`, catches any errors it raises, and returns a simple boolean for those that prefer that idiom. Here are some examples of both:\n\n***Note**: JWKs are cached in memory at the instance level. Instantiating a new instance of `Authentic::Validator` will result in a cold cache, resulting in two HTTP requests to get OIDC config then subsequently the issuer's JWKs. Generally it is best to instantiate this at the Application level thus making use of the JWK cache.*\n\n```ruby\nrequire 'authentic'\n\n# Ensure you pass along your ISS whitelist when instantiating the validator\nopts = { iss_whitelist: ['https://articulate.auth0.com/'] }\nvalidator = Authentic::Validator.new(opts)\n\n# Simply returns true or false based on validity\nvalid = validator.valid?(request.cookies[:token])\n\n# Raises errors when it cannot validate a given token.\nbegin\n    # returns the decoded JWT\n    jwt = validator.ensure_valid(request.cookies[:token])\nrescue InvalidToken, InvalidKey, RequestError, ExpiredToken, InvalidIssuer\n    # do stuff\nend\n```\n\n# Response Status Codes\n\nAccording to the OAuth spec invalid or expired tokens should produce a 401 response and insufficient access (either via scope or aud/iss claim) should produce a 403. This means that all errors except `InvalidIssuer` should produce a 401 status code, and an invalid issuer should produce a 403.\n\n## Options\n\nInstantiate `Authentic::Validator` with an options hash, which must contain an `iss_whitelist` array listing the `token.payload.iss` values you will accept. For example:\n\n| Name            | Default | Required | Notes                                                        |\n| --------------- | ------- | -------- | -------------------------------------------------------------|\n| iss_whitelist   | N/A     | y        |                                                              |\n| cache_max_age   | `'10h'` | n        | Supports seconds, minutes, and hours. Example `'10h 30m 60s'`|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farticulate%2Fauthentic-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farticulate%2Fauthentic-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farticulate%2Fauthentic-rb/lists"}