|
1 | | -# security |
2 | | -:wrench: Robots generator component |
| 1 | +# Security |
| 2 | +:wrench: Security generator component |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +[]() |
| 7 | + |
| 8 | +[](https://codeclimate.com/github/nepttune/security) |
| 9 | +[](https://scrutinizer-ci.com/g/nepttune/security/?branch=master) |
| 10 | + |
| 11 | +## Introduction |
| 12 | + |
| 13 | +This component automaticaly generates security.txt from parameters in configuration. |
| 14 | + |
| 15 | +## Dependencies |
| 16 | + |
| 17 | +- [nepttune/base-requirements](https://github.com/nepttune/base-requirements) |
| 18 | +- [nepttune/base-component](https://github.com/nepttune/base-component) |
| 19 | + |
| 20 | +## How to use |
| 21 | + |
| 22 | +- Register `\Nepttune\Component\ISecurityFactory` as service in cofiguration file, inject it into presenter, write `createComponent` method and use macro `{control}` in template file. |
| 23 | + - Just as any other component. |
| 24 | + - You need to pass security configuration to factory service. |
| 25 | + - Content type is automaticaly set to `text/plain`. |
| 26 | +- Modify parameters to accomplish your needs. |
| 27 | + |
| 28 | +### Example configuration |
| 29 | + |
| 30 | +``` |
| 31 | +services: |
| 32 | + securityFactory: |
| 33 | + implement: Nepttune\Component\ISecurityFactory |
| 34 | + arguments: |
| 35 | + - '%security%' |
| 36 | +parameters: |
| 37 | + security: |
| 38 | + |
| 39 | + hiring: 'https://hiring.test.com' |
| 40 | + acknowledgements: 'https://hall-of-fame.test.com' |
| 41 | + permission: 'none' |
| 42 | +``` |
| 43 | + |
| 44 | +### Example presenter |
| 45 | + |
| 46 | +``` |
| 47 | +class ExamplePresenter implements IPresenter |
| 48 | +{ |
| 49 | + /** @var \Nepttune\Component\IRobotsFactory */ |
| 50 | + protected $iRobotsFactory; |
| 51 | + |
| 52 | + public function __construct(\Nepttune\Component\IRobotsFactory $IRobotsFactory) |
| 53 | + { |
| 54 | + $this->iRobotsFactory = $IRobotsFactory; |
| 55 | + } |
| 56 | + |
| 57 | + public function actionRobots() |
| 58 | + { |
| 59 | + $this->getHttpResponse()->setContentType('text/plain'); |
| 60 | + } |
| 61 | +
|
| 62 | + protected function createComponentRobots() |
| 63 | + { |
| 64 | + return $this->iRobotsFactory->create(); |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
0 commit comments