PHP code example of marshmallow / ip-access
1. Go to this page and download the library: Download marshmallow/ip-access library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
marshmallow / ip-access example snippets
return [
'enabled' => env('IPACCESS_ENABLED', true),
'whitelist_env' => env('IPACCESS_ENV', 'production'),
'whitelist' => [
'range' => [
'127.0.0.*',
],
'list' => [
'127.0.0.1',
]
],
'redirect_to' => env('IPACCESS_DENIED_URL', null),
'response_status' => env('IPACCESS_DENIED_STATUS', 403),
'response_message' => env('IPACCESS_DENIED_MESSAGE', 'Access not Allowed'),
];
'except' => [
'webhook/*',
],
'except' => [
'webhook/*' => [
'secret' => [
'source' => 'header',
'key' => 'x-webhook-secret',
'value' => 'TEST_SECRET_HEADER',
],
],
],
/** This request will be allowed by the config above. */
Http::withHeaders([
"x-webhook-secret" => "TEST_SECRET_HEADER"
])->get("https://marshmallow.dev/webhook/is/open");
'except' => [
'webhook/*' => [
'secret' => [
'source' => 'body',
'key' => 'secret',
'value' => 'TEST_SECRET_BODY',
],
],
],
/** These requests will be allowed by the config above. */
Http::get("https://marshmallow.dev/webhook/is/open?secret=TEST_SECRET_BODY");
Http::get("https://marshmallow.dev/webhook/is/open", [
"secret" => "TEST_SECRET_BODY"
]);
Http::post("https://marshmallow.dev/webhook/is/open", [
"secret" => "TEST_SECRET_BODY"
]);
Gate::define('viewNova', function ($user) {
return IpAccess::hasBackofficeAccess();
}
return [
'use_nova' => true,
];
bash
php artisan vendor:publish --provider="Marshmallow\IpAccess\IpAccessServiceProvider"
bash
php artisan migrate
bash
php artisan marshmallow:resource IpAccess IpAccess
bash
php artisan ip-access:uninstall