-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.php
69 lines (56 loc) · 1.71 KB
/
routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
declare(strict_types=1);
use Illuminate\Http;
use Illuminate\Routing;
use System\Behaviors\SettingsModel;
use Vdlp\SecurityTxt\Models;
/** @var Routing\Router $router */
$router = resolve(Routing\Router::class);
$router->get('/.well-known/security.txt', static function () {
/** @var SettingsModel $settings */
$settings = Models\Settings::instance();
$contents = sprintf(
"Contact: %s\n",
$settings->getSettingsValue('contact')
);
if ($settings->getSettingsValue('encryption')) {
$contents .= sprintf(
"Encryption: %s\n",
$settings->getSettingsValue('encryption')
);
}
if ($settings->getSettingsValue('acknowledgements')) {
$contents .= sprintf(
"Acknowledgements: %s\n",
$settings->getSettingsValue('acknowledgements')
);
}
if ($settings->getSettingsValue('permission')) {
$contents .= sprintf(
"Permission: %s\n",
$settings->getSettingsValue('permission')
);
}
if ($settings->getSettingsValue('policy')) {
$contents .= sprintf(
"Policy: %s\n",
$settings->getSettingsValue('policy')
);
}
if ($settings->getSettingsValue('signature')) {
$contents .= sprintf(
"Signature: %s\n",
$settings->getSettingsValue('signature')
);
}
if ($settings->getSettingsValue('hiring')) {
$contents .= sprintf(
"Hiring: %s\n",
$settings->getSettingsValue('hiring')
);
}
return new Http\Response($contents, 200, [
'Content-Type' => 'text/plain'
]);
});
$router->redirect('/security.txt', '/.well-known/security.txt');