Download the PHP package faaren-tech/faaren-sdk without Composer
On this page you can find all versions of the php package faaren-tech/faaren-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download faaren-tech/faaren-sdk
More information about faaren-tech/faaren-sdk
Files in faaren-tech/faaren-sdk
Package faaren-sdk
Short Description A sdk to interact with our authorization service
License MIT
Informations about the package faaren-sdk
FAAREN SDK
Installation
Customize the service_url parameter in config auth-sdk.php or set the value FAAREN_AUTH_SERVICE_URL in your .env file.
Usage
Important! If you use this library in a docker context
FAAREN_AUTH_SERVICE_URLhas to be the IP address of your machine. Otherwise it will try to find a host in its own docker network. As an alternative you can add anexternal_hostsoption to your docker-compose-container.
You can use the package everywhere by simply initializing it:
The Token-Object contains the following details, for example:
The listed permissions, subsidiary_uuid and user_uuid can be used to make your app-specific authorization.
Notifications
Mailings
You can simply trigger notifications via the Notification Service:
If an error occurs while calling the Notification Service, a \FaarenTech\FaarenSDK\Exceptions\NotificationServiceException is thrown. The exception message will contain a hint what was going wrong, e.g. an validation error:
"message": "Status 422: Notification could not be sent because: The to field is required.",
The used tokens and endpoints can be customized via you .env file. The available keys are listed in /config/faaren-sdk.php within the vendor directory or, if you have published the config, in your applications config-folder.
Middlewares
AcceptsJsonMiddleware
HasValidTokenMiddleware
You can add the middleware group faaren to all routes you like. This middleware group contains the following middlewares:
- HasValidTokenMiddleware => Checks if the given token is valid and attaches the token details to the current request. The details are available with
$request->api_token.
Using this middleware makes it easy to work with tokens. You can access the token details everywhere via the request object:
Form Requests
This package provides a BaseRequest, the FaarenRequest. This Request implementes the Illuminate\Contracts\Auth\Access\Authorizable via the Illuminate\Foundation\Auth\Access\Authorizable trait. It can be used for any FormRequest you will create in your service.
This way it is possible to authorize incoming requests directly in your form request:
In your policy you won't pass in an instance of your User. Instead you pass in an instance of your form request. The underlying policy:
Define Resources
Since version 1.1.0 we use "ResponseCollection" and "ResourceCollection" in our Resource-definitions.
To use your own Resource with our Schema, you need to extend your Resource from "ResponseResource" and not from "JsonResource" Then you need to change your "toArray" method to "toPayload" Example:
Resource Collection:
So your Resource gets mapped as YourAwesomeResourceCollection
Validation as Json in our Response-Schema
Your class needs to be extend from "FaarenRequest", and every validation error uses the schema
Handle Exceptions as Json
Simple add the AcceptsJsonMiddleware to the relevant middleware groups or as a global middleware.
Using the custom Handler is deprecated and will cause errors when you use it!