{"id":23806953,"url":"https://github.com/havenshen/larsign","last_synced_at":"2025-10-12T23:13:41.659Z","repository":{"id":27275540,"uuid":"113003939","full_name":"HavenShen/larsign","owner":"HavenShen","description":"Laravel signature certification with web API server.","archived":false,"fork":false,"pushed_at":"2023-07-27T09:21:59.000Z","size":127,"stargazers_count":20,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-20T07:41:20.085Z","etag":null,"topics":["api","hmac","laravel","middleware","package","signature"],"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/HavenShen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-04T06:28:03.000Z","updated_at":"2024-09-27T21:01:27.000Z","dependencies_parsed_at":"2022-08-07T12:15:52.470Z","dependency_job_id":null,"html_url":"https://github.com/HavenShen/larsign","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenShen%2Flarsign","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenShen%2Flarsign/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenShen%2Flarsign/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenShen%2Flarsign/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HavenShen","download_url":"https://codeload.github.com/HavenShen/larsign/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232133879,"owners_count":18477299,"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":["api","hmac","laravel","middleware","package","signature"],"created_at":"2025-01-01T23:16:57.069Z","updated_at":"2025-10-12T23:13:36.621Z","avatar_url":"https://github.com/HavenShen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Api Authorized Signature Middleware for Laravel 5\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/HavenShen/larsign/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/HavenShen/larsign/?branch=master)\n[![Build Status](https://scrutinizer-ci.com/g/HavenShen/larsign/badges/build.png?b=master)](https://scrutinizer-ci.com/g/HavenShen/larsign/build-status/master)\n[![Code Coverage](https://scrutinizer-ci.com/g/HavenShen/larsign/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/HavenShen/larsign/?branch=master)\n[![Build Status](https://travis-ci.org/HavenShen/larsign.svg?branch=master)](https://travis-ci.org/HavenShen/larsign)\n[![Latest Stable Version](https://poser.pugx.org/HavenShen/larsign/v/stable.svg)](https://packagist.org/packages/HavenShen/larsign)\n[![Latest Unstable Version](https://poser.pugx.org/HavenShen/larsign/v/unstable.svg)](https://packagist.org/packages/HavenShen/larsign)\n[![Latest Stable Version](https://img.shields.io/packagist/v/HavenShen/larsign.svg?style=flat-square)](https://packagist.org/packages/HavenShen/larsign)\n[![Total Downloads](https://img.shields.io/packagist/dt/HavenShen/larsign.svg?style=flat-square)](https://packagist.org/packages/HavenShen/slim-born)\n[![License](https://img.shields.io/packagist/l/HavenShen/larsign.svg?style=flat-square)](https://packagist.org/packages/HavenShen/larsign)\n\n## About\n\nThe `larsign` package authorized signature server.\n\n## Features\n\n* Handles larsign requests\n\n## Installation\n\n### Laravel\n\nRequire the `havenshen/larsign` package in your `composer.json` and update your dependencies:\n```sh\n$ composer require havenshen/larsign\n```\n\nAdd the `HavenShen\\Larsign\\LarsignServiceProvider` to your `config/app.php` providers array:\n```php\nHavenShen\\Larsign\\LarsignServiceProvider::class,\n```\n\nAdd the `HavenShen\\Larsign\\LarsignFacade` to your `config/app.php` aliases array:\n```php\n'Larsign' =\u003e HavenShen\\Larsign\\LarsignFacade::class,\n```\n\n### Lumen\n\nRequire the `havenshen/larsign` package in your `composer.json` and update your dependencies:\n```sh\n$ composer require havenshen/larsign\n```\n\nRegister the package with lumen in `bootstrap/app.php` with the following:\n```php\n$app-\u003eregister(HavenShen\\Larsign\\LarsignServiceProvider::class);\n```\n\n## Global usage\n\nTo allow Larsign for all your routes, add the `HandleLarsign` middleware in the `$middleware` property of  `app/Http/Kernel.php` class:\n\n```php\nprotected $middleware = [\n    // ...\n    \\HavenShen\\Larsign\\HandleLarsign::class,\n];\n```\n\n## Group middleware\n\nIf you want to allow Larsign on a specific middleware group or route, add the `HandleLarsign` middleware to your group:\n\n```php\nprotected $middlewareGroups = [\n    'web' =\u003e [\n       // ...\n    ],\n\n    'api' =\u003e [\n        // ...\n        \\HavenShen\\Larsign\\HandleLarsign::class,\n    ],\n];\n```\n\n## Application route middleware\n\nIf you want to allow Larsign on a specific application middleware or route, add the `HandleLarsign` middleware to your application route:\n\n```php\nprotected $routeMiddleware = [\n    // ...\n    'auth.larsign' =\u003e \\HavenShen\\Larsign\\HandleLarsign::class,\n];\n```\n\n## Configuration\n\nThe defaults are set in `config/larsign.php`. Copy this file to your own config directory to modify the values. If you're using Laravel, you can publish the config using this command:\n\n```sh\n$ php artisan vendor:publish --provider=\"HavenShen\\Larsign\\LarsignServiceProvider\"\n```\n    \nIf you're using Lumen, Copy the configuration `larsign.php` from `vendor/havenshen/larsign/config/larsign.php` to your `config/` directory\n\n```php\nreturn [\n    /*\n     |--------------------------------------------------------------------------\n     | Larsign\n     |--------------------------------------------------------------------------\n     |\n     */\n    'headerName' =\u003e env('LARSIGN_HEADER_NAME', 'Larsign'),\n    'accessKey' =\u003e env('LARSIGN_ACCESS_KEY', ''),\n    'secretKey' =\u003e env('LARSIGN_SECRET_KEY', ''),\n];\n```\n\nAdd api route in `routes/api.php` Copy this.\n\n```php\nRoute::middleware(['auth.larsign'])-\u003egroup(function () {\n    Route::get('/larsign', function () {\n    return [\n        'message' =\u003e 'done.'\n    ]);\n});\n```\nor\n\n```php\nRoute::get('/larsign', function () {\n    return [\n        'message' =\u003e 'done.'\n    ];\n})-\u003emiddleware('auth.larsign');\n```\n## Client\n\nGenerate `Larsign` signatures\n\n1. Assume the following management credentials:\n\n```shell\nAccessKey = \"test\"\nSecretKey = \"123456\"\n```\n\n2. Call interface address:\n\n```shell\nurl = \"https://larsign.dev/api/v1/test?page=1\"\n```\n\n3. The original string to be signed:\n\u003e note: the time-stamping followed by a newline [currenttime + voucher valid seconds]\n\n```shell\nsigningStr = \"/api/v1/test?page=1\\n1510986405\"\n```\n\n4. Base64 url safe encode:\n\n```shell\nsigningStrBase64UrlSafeEncode = \"L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1\"\n```\n\n5. `hmac_sha1` carries `SecretKey` encryption then base64 url safe encode:\n\n```shell\nsign = \"MLKnFIdI-0TOQ4mHn5TyCcmWACU=\"\n```\n\n\n6. The final administrative credentials are:\n\u003e note: stitching `headerName` Space `AccessKey`:`sign`:`signingStrBase64UrlSafeEncode`\n\n```shell\nlarsignToken = \"Larsign test:MLKnFIdI-0TOQ4mHn5TyCcmWACU=:L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1\"\n```\n\n7. Add http header:\n\u003e note: header key in `config/larsign.php -\u003e headerName` \n\n```shell\nLarsign:Larsign test:MLKnFIdI-0TOQ4mHn5TyCcmWACU=:L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1\n```\n\n## Client signature authorization failed\n\n```shell\nHttp Response: 403\n```\n\n## Testing\n\n```shell\n$ phpunit\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavenshen%2Flarsign","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhavenshen%2Flarsign","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavenshen%2Flarsign/lists"}