Download the PHP package black-bits/key-secret-api-authentication without Composer
On this page you can find all versions of the php package black-bits/key-secret-api-authentication. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download black-bits/key-secret-api-authentication
More information about black-bits/key-secret-api-authentication
Files in black-bits/key-secret-api-authentication
Package key-secret-api-authentication
Short Description Key Secret Api Authentication extension for Laravel
License MIT
Homepage https://github.com/black-bits/key-secret-api-authentication
Informations about the package key-secret-api-authentication
KeySecretApiAuthentication
Key Secret Api Authentication extension for Laravel
How to use
1. Require the package
2. Extend your model (with key and secret fields)
In our case we want a project model, that has a key and a secret field, for api authentication. Therefore a user can have different projects, each with it's own key-secret pair for authentication. Instead of "extends Model", use "extends KeySecretAuthenticatableModel".
3. Configure config/auth.php
Change the guard for api to the following...
... and add a new provider "key_secret" with reference to your Model
4. Modify MiddlewareGroup in App\Http\Kernel.php
Change the MiddlewareGroup in the Kernel as you would for usage for api_token. Set the "auth" to "auth:api".
5. Start Using it
In "routes/api.php" create a route and start using it.
Add a new Header to your API Call with a key "Authorization" and a value "Bearer xyz". xyz should be replaced with your base64_encoded key:secret pair.
ToDo's
- The token should be refactored to use jwt.