{"id":36993147,"url":"https://github.com/bytesfield/key-manager","last_synced_at":"2026-01-13T23:45:20.576Z","repository":{"id":62498655,"uuid":"368198753","full_name":"bytesfield/key-manager","owner":"bytesfield","description":"Key Manager is a Laravel Package for generating public and private key pairs storing, retrieving and authenticating using the private key.","archived":false,"fork":false,"pushed_at":"2021-05-24T22:04:15.000Z","size":890,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-24T12:55:24.916Z","etag":null,"topics":["encryption-key","keymanager","keys-pairs"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/bytesfield.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-17T13:37:49.000Z","updated_at":"2025-02-25T07:13:46.000Z","dependencies_parsed_at":"2022-11-02T12:01:34.547Z","dependency_job_id":null,"html_url":"https://github.com/bytesfield/key-manager","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bytesfield/key-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesfield%2Fkey-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesfield%2Fkey-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesfield%2Fkey-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesfield%2Fkey-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytesfield","download_url":"https://codeload.github.com/bytesfield/key-manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesfield%2Fkey-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["encryption-key","keymanager","keys-pairs"],"created_at":"2026-01-13T23:45:19.845Z","updated_at":"2026-01-13T23:45:20.561Z","avatar_url":"https://github.com/bytesfield.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"/images/preview.jpg\" alt=\"Key Manager Preview\"\u003e\u003c/p\u003e\n\n# Key Manager\n\n[![Version](https://poser.pugx.org/bytesfield/key-manager/v)](//packagist.org/packages/bytesfield/key-manager)\n[![License](https://poser.pugx.org/bytesfield/key-manager/license)](//packagist.org/packages/bytesfield/key-manager)\n[![StyleCI](https://github.styleci.io/repos/368198753/shield?branch=main)](https://github.styleci.io/repos/368198753?branch=main)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bytesfield/key-manager/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/bytesfield/key-manager/?branch=main)\n[![Build Status](https://scrutinizer-ci.com/g/bytesfield/key-manager/badges/build.png?b=main)](https://scrutinizer-ci.com/g/bytesfield/key-manager/build-status/main)\n[![Total Downloads](https://poser.pugx.org/bytesfield/key-manager/downloads)](//packagist.org/packages/bytesfield/key-manager)\n\n\nKey Manager is a Laravel Package for generating public and private key pairs storing, retrieving and authenticating requests using the private key value.\n\n## Installation\n\n[PHP](https://php.net) 7.4+ and [Composer](https://getcomposer.org) are required.\n\nTo get the latest version of Key Manager, simply require it\n\n```bash\ncomposer require bytesfield/key-manager\n```\n\nOr add the following line to the require block of your `composer.json` file.\n\n```\n\"bytesfield/key-manager\": \"1.0.*\"\n```\n\nYou'll then need to run `composer install` or `composer update` to download it and have the autoloader updated.\n\nOnce KeyManager is installed, you need to register the service provider. Open up `config/app.php` and add the following to the `providers` key.\n\n```php\n'providers' =\u003e [\n    ...\n    Bytesfield\\KeyManager\\KeyManagerServiceProvider::class,\n    ...\n]\n```\n\n\u003e If you use **Laravel \u003e= 5.5** you can skip this step and go to [**`configuration`**](https://github.com/bytesfield/key-manager#configuration)\n\n-   `Bytesfield\\KeyManager\\KeyManagerServiceProvider::class,`\n\nAlso, register the Facade like so:\n\n```php\n'aliases' =\u003e [\n    ...\n    'KeyManager' =\u003e Bytesfield\\KeyManager\\Facades\\KeyManager::class,\n    ...\n]\n```\n\n## Configuration\n\nYou can publish the configuration file using this command:\n\n```bash\nphp artisan key-manager:install\n```\n\nThis publishes a configuration-file named `keymanager.php` with some sensible defaults will be placed in your `config` directory and two migration files `create_key_clients_table` and `create_key_api_credentials_table` placed in your `database\\migrations` directory:\n\n```php\n\u003c?php\n\nreturn [\n\n    /**\n     * Generated API Encryption Key\n     *\n     */\n    'api_encryption_key' =\u003e env('API_ENCRYPTION_KEY'),\n\n];\n```\n\nThen run this command to migrate your database\n\n```bash\nphp artisan migrate\n```\n\n## Usage\n\nGenerate API Encryption Key by running this command on your terminal\n\n```bash\nphp artisan encryption:generate\n```\n\nThis will generate an encryption key in your .env:\n\n```php\nAPI_ENCRYPTION_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\n```\n\n_If you are using a hosting service like heroku, ensure to add the above details to your configuration variables._\n\n#### Using KeyManager Facade\n\nImport the KeyManager Facade\n\n```php\nuse Bytesfield\\KeyManager\\Facades\\KeyManager;\n```\n\nCreate a Key Client\n\n```php\n\nKeyManager::createClient(string $name, string $type);\n// Optional\nKeyManager::createClient(string $name, string $type, string $status);\n```\n\nThis creates a client with `public` and `private` keys pairs\n\nNote : `$status` param can either be `active` or `suspended` while `$type` is dependent on what you want e.g `user` or `admin`.\n\nGet Private Key\n\n```php\nKeyManager::getPrivateKey(int $clientId);\n```\n\nChange Key Pairs\n\n```php\nKeyManager::changeKeys(int $clientId);\n```\n\nSuspend a client\n\n```php\nKeyManager::suspendClient(int $clientId);\n```\n\nActivate a Client\n\n```php\nKeyManager::activateClient(int $clientId);\n```\n\nSuspend an API Credential\n\n```php\nKeyManager::suspendApiCredential(int $clientId);\n```\n\nActivate an API Credential\n\n```php\nKeyManager::activateApiCredential(int $clientId);\n```\n\n#### Injecting KeyManager or KeyManagerInterface in a constructor\n\nImport the KeyManager or KeyManagerInterface\n\n```php\nuse Bytesfield\\KeyManager\\KeyManager;\n```\n\n```php\npublic function __construct(KeyManager $keyManager)\n{\n    $this-\u003ekeyManager = $keyManager;\n}\n```\n\nOr\n\n```php\nuse Bytesfield\\KeyManager\\KeyManagerInterface;\n```\n\n```php\npublic function __construct(KeyManagerInterface $keyManager)\n{\n    $this-\u003ekeyManager = $keyManager;\n}\n```\n\nCreate a Key Client\n\n```php\n\n$this-\u003ekeyManager-\u003ecreateClient(string $name, string $type);\n// Optional\n$this-\u003ekeyManager-\u003ecreateClient(string $name, string $type, string $status);\n```\n\nThis creates a client with `public` and `private` keys pairs\n\nNote : `$status` param can either be `active` or `suspended` while `$type` is dependent on what you want e.g `user` or `admin`.\n\nGet Private Key\n\n```php\n$this-\u003ekeyManager-\u003egetPrivateKey(int $clientId);\n```\n\nChange Key Pairs\n\n```php\n$this-\u003ekeyManager-\u003echangeKeys(int $clientId);\n```\n\nSuspend a Client\n\n```php\n$this-\u003ekeyManager-\u003esuspendClient(int $clientId);\n```\n\nActivate a Client\n\n```php\n$this-\u003ekeyManager-\u003eactivateClient(int $clientId);\n```\n\nSuspend an API Credential\n\n```php\n$this-\u003ekeyManager-\u003esuspendApiCredential(int $clientId);\n```\n\nActivate an API Credential\n\n```php\n$this-\u003ekeyManager-\u003eactivateApiCredential(int $clientId);\n```\n\n#### Using Commands\n\nYou can use commands to perform these actions too.\n\nCreate a Key Client\n\n```bash\n\nclient:create {name} {type}\n\n```\n\nOr\n\n```bash\n\nclient:create {name} {type} {status=active}\n```\n\nThis creates a client with `public` and `private` keys pairs\n\nNote : `$status` param can either be `active` or `suspended` while `$type` is dependent on what you want e.g `user` or `admin`.\n\nGet Private Key\n\n```bash\nclient:getkey {clientId}\n```\n\nChange Key Pairs\n\n```bash\nclient:changekey {clientId}\n```\n\nSuspend a client\n\n```bash\nclient:suspend {clientId}\n```\n\nActivate a Client\n\n```bash\nclient:activate {clientId}\n```\n\nSuspend an API Credential\n\n```bash\nclient:suspend-key {clientId}\n```\n\nActivate an API Credential\n\n```bash\nclient:activate-key {clientId}\n```\n\n#### Using the middleware to protect your routes.\n\nIn your route add `auth.client` middleware\n\n```php\nRoute::get('test', function(){\n    return \"Hello world\";\n})-\u003emiddleware('auth.client');\n```\n\nOr\n\nIn your controller add `auth.client`\n\n```php\npublic function __construct(){\n    $this-\u003emiddleware('auth.client');\n}\n```\n\nThis Middleware Authenticates a client's request with a valid private key value `api-auth-key` which is to be passed to the request header.\n\n### Testing\n\n```bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email abrahamudele@gmail instead of using the issue tracker.\n\n## Credits\n\n-   [Abraham Udele](https://github.com/bytesfield) \u003cbr/\u003e\nFind me on\n\u003ca href=\"https://twitter.com/SaintAbrahams/\"\u003eTwitter.\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/in/abraham-udele-246003130/\"\u003eLinkedin.\u003c/a\u003e\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytesfield%2Fkey-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytesfield%2Fkey-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytesfield%2Fkey-manager/lists"}