Download the PHP package endropie/lumen-micro-serve without Composer
On this page you can find all versions of the php package endropie/lumen-micro-serve. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package lumen-micro-serve
lumen-micro-serve
Simple microservice for Lumen Framework.
- Authentication on Auth-Service.
- Authorization on other services.
- Model Filterable [soon].
- Model JSON resource [soon].
Installation
Standard Composer package installation:
Usage
Authentication on Auth-Service
-
Publish the config file. This will create a
config/jwt.php
file for basic configuration options. -
Add a new auth guard to your auth config file using a
jwt
driver. -
Protect your API routes using this new guard.
- Use provided
AuthorizableToken
trait from this package on your Auth model (eg. User).
You now have access to token()
method on your User model, eg:
You should probably return this token via Login Controller or User Resource.
Authorization on other services.
-
Publish the config file. This will create a
config/jwt.php
file for basic configuration options. - Protect your API routes using this new guard.
You now have access to auth()
helper function, eg:
You should probably return this token via Login Controller or User Resource.
Configuration
This package provides simple configuration via config/jwt.php
file after you publish the config. Let's go over each configuration option.
secret-key
- Secret key to use when encoding / decoding tokens. It should be a random string. Remember, if you change this key all active JWT tokens will be invalidated.hash-algo
- Hashing algorithm. List of supported ones are in the config file. You probably don't need to change this.expiration
- Default token expiration time in minutes. You can set it tonull
and the tokens will never expire.claims
- Default claims that will be applied to all tokens (besides the required ones needed for decoding and validation).
This was global configuration for all tokens. Besides that, library provides a local per-model configuration via HasJwt
trait helper methods.
getJwtId()
- It should return the model unique key used to retrieve that model from database. It defaults to model primary key.getJwtValidFromTime()
- It should returnnull
(default) or a Carbon instance. You can use that if you want to create tokens which are not active right away.getJwtValidUntilTime()
- It should returnnull
or a Carbon instance. This sets the JWT expiration time which, by default, uses theexpiration
option from the config file.getJwtCustomClaims()
- Should return a key/value array of extra custom claims that you want to be a part of your token. By default it's an empty array.
You can also use configuration directly on the token()
method which then overrides all other configurations, eg:
You don't need to override all configuration options, just the ones that you wish to change.
Request
Token is extracted from the request in one of three ways:
- From
Authorization: Bearer {token}
header (most common). - From URL query param
token
. - From request payload using
token
field name.
All versions of lumen-micro-serve with dependencies
illuminate/auth Version ^8.0|^9.0
illuminate/contracts Version ^8.0|^9.0
illuminate/database Version ^8.0|^9.0
illuminate/http Version ^8.0|^9.0
illuminate/support Version ^8.0|^9.0