-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added way to generate signed url for horizon request
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\URL; | ||
|
||
class MakeHorizonSignedUrl extends Command | ||
{ | ||
protected $signature = 'denhac:make-horizon-signed-url'; | ||
|
||
protected $description = 'Create a signed URL to populate the secret cookie and get access to horizon'; | ||
|
||
public function handle() | ||
{ | ||
$url = URL::temporarySignedRoute('horizon-signed-url', now()->addMinutes(5)); | ||
$this->info($url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Symfony\Component\HttpFoundation\Cookie; | ||
|
||
class HorizonSignedUrlController extends Controller | ||
{ | ||
public function __invoke(Request $request) | ||
{ | ||
if (! $request->hasValidSignature()) { | ||
abort(401); | ||
} | ||
|
||
return response("success")->cookie(Cookie::create( | ||
'horizon', | ||
setting('horizon.password'), | ||
now()->addYears(5) // It's annoying to generate again when you need it. Access is revoked for everyone by changing the password. | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters