{"id":14966325,"url":"https://github.com/yiisoft/auth-jwt","last_synced_at":"2025-10-27T13:31:54.417Z","repository":{"id":37086147,"uuid":"221271627","full_name":"yiisoft/auth-jwt","owner":"yiisoft","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-20T13:13:52.000Z","size":134,"stargazers_count":34,"open_issues_count":1,"forks_count":11,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-10-29T14:35:33.800Z","etag":null,"topics":["auth","authentication","hacktoberfest","jwt-authentication","middleware","psr-15","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2019-11-12T17:15:09.000Z","updated_at":"2024-08-20T13:13:54.000Z","dependencies_parsed_at":"2023-12-13T03:37:40.054Z","dependency_job_id":"9c199d52-f680-4490-b7fe-c044a5d0b31c","html_url":"https://github.com/yiisoft/auth-jwt","commit_stats":{"total_commits":101,"total_committers":16,"mean_commits":6.3125,"dds":0.693069306930693,"last_synced_commit":"da295032b28935eace5da5f129219b78a32acb39"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":"yiisoft/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fauth-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fauth-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fauth-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fauth-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/auth-jwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238049046,"owners_count":19407975,"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":["auth","authentication","hacktoberfest","jwt-authentication","middleware","psr-15","yii3"],"created_at":"2024-09-24T13:36:13.210Z","updated_at":"2025-10-27T13:31:54.102Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Auth JWT\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/auth-jwt/v)](https://packagist.org/packages/yiisoft/auth-jwt)\n[![Total Downloads](https://poser.pugx.org/yiisoft/auth-jwt/downloads)](https://packagist.org/packages/yiisoft/auth-jwt)\n[![Build status](https://github.com/yiisoft/auth-jwt/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/auth-jwt/actions/workflows/build.yml)\n[![Code Coverage](https://codecov.io/gh/yiisoft/auth-jwt/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/auth-jwt)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fauth-jwt%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/auth-jwt/master)\n[![static analysis](https://github.com/yiisoft/auth-jwt/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/auth-jwt/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/auth-jwt/coverage.svg)](https://shepherd.dev/github/yiisoft/auth-jwt)\n[![psalm-level](https://shepherd.dev/github/yiisoft/auth-jwt/level.svg)](https://shepherd.dev/github/yiisoft/auth-jwt)\n\nThe package provides [JWT authentication](https://tools.ietf.org/html/rfc7519) method for [Yii Auth](https://github.com/yiisoft/auth/).\n\n## Requirements\n\n- PHP 8.1 or higher.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/auth-jwt\n```\n\n## General usage\n\n### Configuring within Yii\n\n1. Set JWT parameters in your `params.php` config file:\n\n    ```php\n    'yiisoft/auth-jwt' =\u003e [\n        'algorithms' =\u003e [\n            // your signature algorithms\n        ],\n        'serializers' =\u003e [\n            // your token serializers\n        ],\n        'key' =\u003e [\n            'secret' =\u003e 'your-secret',\n            'file' =\u003e 'your-certificate-file',\n        ],\n    ],\n    ```\n\n2. Setup definitions, required for `\\Yiisoft\\Auth\\Middleware\\Authentication` middleware in a config, for example,\n   in `config/web/auth.php`:\n\n    ```php\n    /** @var array $params */\n\n    use Yiisoft\\Auth\\Jwt\\TokenManagerInterface;\n    use Yiisoft\\Auth\\Jwt\\TokenManager;\n    use Yiisoft\\Auth\\AuthenticationMethodInterface;\n    use Yiisoft\\Auth\\Jwt\\JwtMethod;\n\n    return [\n        KeyFactoryInterface::class =\u003e [\n            'class' =\u003e FromSecret::class,\n            '__construct()' =\u003e [\n                $params['yiisoft/auth-jwt']['key']['secret']\n            ],\n        ],\n        \n        AuthenticationMethodInterface::class =\u003e JwtMethod::class,\n    ];\n    ```\n\n   \u003e Note: Don't forget to declare your implementations of `\\Yiisoft\\Auth\\IdentityInterface` and `\\Yiisoft\\Auth\\IdentityRepositoryInterface`.\n\n3. Use `Yiisoft\\Auth\\Middleware\\Authentication` middleware.\n   Read more about middlewares in the [middleware guide](https://github.com/yiisoft/docs/blob/master/guide/en/structure/middleware.md).\n\n### Configuring independently\n\nYou can configure `Authentication` middleware manually:\n\n```php\n/** @var \\Yiisoft\\Auth\\IdentityRepositoryInterface $identityRepository */\n$identityRepository = getIdentityRepository();\n\n$tokenRepository = $container-\u003eget(\\Yiisoft\\Auth\\Jwt\\TokenRepositoryInterface::class);\n\n$authenticationMethod = new \\Yiisoft\\Auth\\Jwt\\JwtMethod($identityRepository, $tokenRepository);\n\n$middleware = new \\Yiisoft\\Auth\\Middleware\\Authentication(\n    $authenticationMethod,\n    $responseFactory, // PSR-17 ResponseFactoryInterface.\n    $failureHandler // Optional, \\Yiisoft\\Auth\\Handler\\AuthenticationFailureHandler by default.\n);\n```\n\n## Documentation\n\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for\nthat. You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Auth JWT is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fauth-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fauth-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fauth-jwt/lists"}