deegitalbe / server-authorization
Simple server authorization for communicating between our projects.
Installs: 5 013
Dependents: 7
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.5
- dev-main
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- dev-issue-11-Adding_a_small_README_to_help_usage
- dev-issue-9-✨_Adding_AuthorizedServerCredential_setting_up_automatically_needed_header_value_for_requests
- dev-issue-7-✨Adding_AuthorizedServer_middleware_authenticating_incoming_requests
- dev-issue-5-✨_Log_an_error_if_there_is_no_authorization_key_defined_in_config
- dev-issue-3-🎉_Basic_package_with_config
This package is auto-updated.
Last update: 2024-10-29 06:19:36 UTC
README
This package is used to authenticate NON CRITICAL requests between our applications.
Installation
composer require deegitalbe/server-authorization
Configuration
Environment
You should define secret key in your .env
file :
TRUSTUP_SERVER_AUTHORIZATION=your_secret_key
Publish configuration
If you want to have more control about configuration, publish it :
php artisan vendor:publish --provider="Deegitalbe\ServerAuthorization\Providers\ServerAuthorizationServiceProvider" --tag="config"
Middleware authenticating incoming request
You can add this middleware to any route that should be protected :
Deegitalbe\ServerAuthorization\Http\Middleware\AuthorizedServer
Credential setting up outgoing request
if you use my client to make requests, you can use this Credential to automatically authenticate your request :
Deegitalbe\ServerAuthorization\Credential\AuthorizedServerCredential
Customizing credential
If you need more control, extend credential this way :
use Henrotaym\LaravelApiClient\Contracts\RequestContract;
use Deegitalbe\ServerAuthorization\Credential\AuthorizedServerCredential;
class MyCustomCredential extends AuthorizedServerCredential {
/**
* Preparing request.
*
* @param RequestContract $request
* @return void
*/
public function prepare(RequestContract &$request)
{
parent::prepare($request);
// your custom code here...
}
}