1. Go to this page and download the library: Download alvinfadli/access-lock 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/ */
return [
// Bcrypt hash of the access password (set via Artisan command).
'password_hash' => env('ACCESS_LOCK_PASSWORD_HASH', null),
// Session key used to track unlocked state.
'session_key' => 'access_lock_unlocked',
// URL prefix for the unlock page routes (/access-lock by default).
'route_prefix' => 'access-lock',
// Bypass conditions — see "Bypass Conditions" section below.
'bypass' => [
'query' => [],
'headers' => [],
],
// Setup API token TTL (in seconds)
'api' => [
'token_ttl' => env('ACCESS_LOCK_API_TOKEN_TTL', 120),
],
];
// config/access-lock.php
'bypass' => [
// All listed query keys must be present and non-empty to bypass.
// e.g. visiting /?ssoKey=anything&userId=123 will unlock the session.
'query' => [
'ssoKey',
'userId',
],
// All listed header names must be present and non-empty to bypass.
// e.g. sending X-SSO-Key: anything will unlock the session.
'headers' => [
'X-SSO-Key',
],
],
// Returns true if a password hash has been configured.
access_lock_active(): bool
// Returns true if the current visitor has already unlocked access.
access_lock_unlocked(): bool
// Verifies a plain-text password against the configured hash.
access_lock_verify(string $password): bool
use AlvinFadli\AccessLock\Support\PasswordManager;
PasswordManager::setPassword('my-plain-text-password');
bash
php artisan access-lock:set-password
bash
php artisan config:clear
POST /api/access-lock/unlock
Content-Type: application/json
{ "password": "your-staging-password" }