1 | <?php |
||
2 | /** |
||
3 | * src/SecurityTxtController.php. |
||
4 | * |
||
5 | * @author Austin Heap <[email protected]> |
||
6 | * @version v0.4.0 |
||
7 | */ |
||
8 | declare(strict_types=1); |
||
9 | |||
10 | namespace AustinHeap\Security\Txt; |
||
11 | |||
12 | use Response; |
||
13 | |||
14 | /** |
||
15 | * SecurityTxtController. |
||
16 | * |
||
17 | * @link https://github.com/austinheap/laravel-security-txt |
||
18 | * @link https://packagist.org/packages/austinheap/laravel-security-txt |
||
19 | * @link https://austinheap.github.io/laravel-security-txt/classes/AustinHeap.Security.Txt.SecurityTxtController.html |
||
20 | * @link https://securitytext.org/ |
||
21 | */ |
||
22 | class SecurityTxtController extends \Illuminate\Routing\Controller |
||
23 | { |
||
24 | /** |
||
25 | * Show the security.txt file. |
||
26 | * |
||
27 | * @return Response |
||
28 | */ |
||
29 | 2 | public function show() |
|
30 | { |
||
31 | 2 | if (! config('security-txt.enabled', false)) { |
|
32 | 1 | abort(404); |
|
33 | } |
||
34 | |||
35 | 1 | return Response::make( |
|
36 | 1 | app('SecurityTxt')->fetch(), |
|
37 | 1 | 200, |
|
38 | 1 | ['Content-Type' => 'text/plain'] |
|
39 | ); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Redirect to the proper location of the security.txt file. |
||
44 | * |
||
45 | * @return Response |
||
46 | */ |
||
47 | 2 | public function redirect() |
|
48 | { |
||
49 | 2 | if (! config('security-txt.enabled', false)) { |
|
50 | 1 | abort(404); |
|
51 | } |
||
52 | |||
53 | 1 | return redirect()->route('security.txt'); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
54 | } |
||
55 | } |
||
56 |