Commit b3f1c0f4 authored by Alasdair Keyes's avatar Alasdair Keyes

Flesh Out Readme

parent af7137ec
# redirecttoken-laravel
Laravel integration for the redirecttoken PHP package
\ No newline at end of file
Laravel integration for the redirecttoken PHP package
## Description
This package implements the redirecttoken (https://gitlab.com/alasdairkeyes/redirecttoken) for the Laravel framework.
This redirects website visitors to the URI with a 302 redirect. If an invalid request is received a 400 response is returned.
## Installation
## Configuration
* Publish the config
`php artisan vendor:publish --provider="RedirectToken\Laravel\Providers\RedirectTokenServiceProvider" --tag=config`
* Update your environment with a secret at least 10 characters long. This is a minimum length, the longer the string, the better.
`REDIRECT_TOKEN_SECRET=MyIncrediblySecureSecret`
* If you're using config caching, refresh your cache
`php artisan config:cache`
* Add the Service Provider
If you're using Laravel >=5.5 you can stop here. The Service Provider will auto-load.
For Lumen and Laravel <5.5 add the Class to your `app/config.php` config file
```
return [
// Other configurations above...
'providers' => [
// Other providers above...
RedirectToken\Laravel\Providers\RedirectTokenServiceProvider::class,
// Other providers below...
],
// Other configurations below...
];
```
## Example
In your template just add the following directive into your `href` value
`<a href="@redirectUrl('https://www.somewebsite.com')">Redirect To Some Website</a>`
## Extending functionality
The following settings can be updated by updating your `.env` file
### Forwarding Path
By default the forwarding path in your application is `/fwd`. This can be changed by using the following
`REDIRECT_TOKEN_PATH=/forwarder`
### Hashing Algorithm
This uses the `sha256` hashing algorithm to generate the token. This can be changed with
`REDIRECT_TOKEN_HASH_ALGO=sha512`
### Query keys
The default query string generated uses the query parameters `uri` and `token`
This can be changed with
`REDIRECT_TOKEN_URI_QUERY_KEY=redirectto`
`REDIRECT_TOKEN_TOKEN_QUERY_KEY=checksum`
### Custom error page
You can customize the page returned when an invalid redirect request is received by creating a `resources/views/errors/400.blade.php`
### Events
The following events are used
* When a valid redirect is received - `RedirectToken\Laravel\Event\ValidRedirectRequest`
* When an invalid redirect is received `RedirectToken\Laravel\Event\InvalidRedirectRequest`
You can listen and handle these events by adding the following to the `$listen` variable in `app/Providers/EventServiceProvider.php`
```
protected $listen = [
'RedirectToken\Laravel\Event\ValidRedirectRequest' => [
'App\Listeners\ValidRedirect',
]
];
```
Some example listeners are included and can be added to your app with the following command
`php artisan vendor:publish --provider="RedirectToken\Laravel\Providers\RedirectTokenServiceProvider" --tag=listeners`
## Site
https://gitlab.com/alasdairkeyes/redirecttoken
## Author
* Alasdair Keyes - https://akeyes.co.uk/
## License
Released under GPL V3 - See included license file.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment