diff --git a/Controller/GuardStatsController.php b/Controller/GuardStatsController.php index de6fd38..0d66501 100644 --- a/Controller/GuardStatsController.php +++ b/Controller/GuardStatsController.php @@ -6,9 +6,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; use Symfony\Component\Form\Extension\Core\Type\DateTimeType; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Metaclass\AuthenticationGuardBundle\Service\UsernamePasswordFormAuthenticationGuard; use Metaclass\AuthenticationGuardBundle\Form\Type\StatsPeriodType; @@ -30,7 +27,7 @@ class GuardStatsController extends Controller { protected $translateRelativeDateArray; /** - * @Route("/statistics", name="Guard_statistics") + * Route("/statistics", name="Guard_statistics") */ public function statisticsAction() { @@ -68,7 +65,7 @@ public function statisticsAction() } /** - * @Route("/history/{ipAddress}", name="Guard_history", requirements={"ipAddress" = "[^/]+"}) + * Route("/history/{ipAddress}", name="Guard_history", requirements={"ipAddress" = "[^/]+"}) */ public function historyAction($ipAddress) { @@ -105,8 +102,9 @@ public function historyAction($ipAddress) $this->container->getParameter('metaclass_auth_guard.statistics.template'), $params); } - /** - * @Route("/statistics/{username}", name="Guard_statisticsByUserName", requirements={"username" = "[^/]*"}) + + /** + * Route("/statistics/{username}", name="Guard_statisticsByUserName", requirements={"username" = "[^/]*"}) */ public function statisticsByUserNameAction($username) { @@ -180,7 +178,7 @@ protected function addStatsPeriodForm(&$params, $governor, $label, $limitFrom=nu $labels = array('From' => 'StatsPeriod.From', 'Until' => 'StatsPeriod.Until'); $historyLimit = new \DateTime("$governor->dtString - $governor->keepCountsFor"); - $formTypeClass = $this->container->getParameter('metaclass_auth_guard.statistics.StatsPeriod.formType'); + $formTypeClass = $this->container->getParameter('metaclass_auth_guard.ui.StatsPeriod.formType'); if (!class_exists($formTypeClass)) { throw new RuntimeException("value of metaclass_auth_guard.statistics.StatsPeriod.formType is not a class: '$formTypeClass'"); } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 21ca0d3..ba5d7d0 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -33,6 +33,12 @@ public function getConfigTreeBuilder() ->addDefaultsIfNotSet() ->children() ->scalarNode('dateTimeFormat')->defaultValue('SHORT')->end() + ->arrayNode('statistics') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('template')->defaultValue('MetaclassAuthenticationGuardBundle:Guard:statistics.html.twig')->end() + ->end() + ->end() ->end() ->end() ->arrayNode('tresholds_governor_params') diff --git a/DependencyInjection/MetaclassAuthenticationGuardExtension.php b/DependencyInjection/MetaclassAuthenticationGuardExtension.php index 961c995..8d4bd78 100644 --- a/DependencyInjection/MetaclassAuthenticationGuardExtension.php +++ b/DependencyInjection/MetaclassAuthenticationGuardExtension.php @@ -23,6 +23,7 @@ public function load(array $configs, ContainerBuilder $container) $config = $this->processConfiguration($configuration, $configs); $container->setParameter('metaclass_auth_guard.db_connection.name', $config['db_connection']['name']); $container->setParameter('metaclass_auth_guard.ui.dateTimeFormat', $config['ui']['dateTimeFormat']); + $container->setParameter('metaclass_auth_guard.statistics.template', $config['ui']['statistics']['template']); $container->setParameter('metaclass_auth_guard.tresholds_governor_params', $config['tresholds_governor_params']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index c49f6a1..7e0ca9b 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -5,7 +5,18 @@ # otherwise anybody will be able to see the user names, ip addresses, date, time and more # of all login attemtps!!! # -Guard: - resource: "@MetaclassAuthenticationGuardBundle/Controller/GuardStatsController.php" - type: annotation - prefix: /guard +Guard_statistics: + path: /statistics + defaults: { _controller: "%metaclass_auth_guard.ui.statistics.controller%:statistics" } + +Guard_history: + path: /history/{ipAddress} + defaults: { _controller: "%metaclass_auth_guard.ui.statistics.controller%:history" } + requirements: + ipAddress: "[^/]+" + +Guard_statisticsByUserName: + path: /statistics/{username} + defaults: { _controller: "%metaclass_auth_guard.ui.statistics.controller%:statisticsByUserName" } + requirements: + username: "[^/]*" diff --git a/Resources/config/services.yml b/Resources/config/services.yml index a61b2a2..f1f7991 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -3,8 +3,9 @@ parameters: metaclass_auth_guard.gateway.class: "Metaclass\TresholdsGovernor\Gateway\DbalGateway" metaclass_auth_guard.tresholds_governor.class: "Metaclass\TresholdsGovernor\Service\TresholdsGovernor" metaclass_auth_guard.authentication.listener.form.class: "Metaclass\AuthenticationGuardBundle\Service\UsernamePasswordFormAuthenticationGuard" - metaclass_auth_guard.statistics.StatsPeriod.formType: "Metaclass\AuthenticationGuardBundle\Form\Type\StatsPeriodType" - metaclass_auth_guard.statistics.template: "MetaclassAuthenticationGuardBundle:Guard:statistics.html.twig" + + metaclass_auth_guard.ui.statistics.controller: "MetaclassAuthenticationGuardBundle:GuardStats" + metaclass_auth_guard.ui.StatsPeriod.formType: "Metaclass\AuthenticationGuardBundle\Form\Type\StatsPeriodType" services: diff --git a/Resources/doc/Installation.md b/Resources/doc/Installation.md index 7468bd1..add2671 100644 --- a/Resources/doc/Installation.md +++ b/Resources/doc/Installation.md @@ -95,6 +95,8 @@ Installation randomSleepingNanosecondsMax: 99999 ui: dateTimeFormat: "SHORT" + statistics: + template: "MetaclassAuthenticationGuardBundle:Guard:statistics.html.twig" ``` 8. From cron or so you may garbage-collect/pack stored RequestCounts: @@ -121,7 +123,7 @@ Installation ```yml metaclass_auth_guard: resource: "@MetaclassAuthenticationGuardBundle/Resources/config/routing.yml" - prefix: / + prefix: /guard ``` And add the path of the user interface to your firewall in app/conf/security.yml: ```yml @@ -138,18 +140,9 @@ Installation - guard/statistics/username (replace 'username' by an actual username) The default template assumes you have base.html.twig still in app/Resources/views. - In an actual application you typically use a template of your own that extends your own layout - and includes MetaclassAuthenticationGuardBundle:Guard:statistics_content.html.twig . - To change the template used override the parameter metaclass_auth_guard.statistics.template - in your applications configuration. - If your layout requires more parameters you probably want to use your own subclass - of GuardStatsController. For this you may override the route(s) from Resources/config/routing.yml - in your applications routing.yml after the metaclass_auth_guard resource configuration - or replace the resource configuration entirely. - - If you want to use other datetime widgets you may override the parameter - metaclass_auth_guard.statistics.StatsPeriod.formType to refer to a class of your own. + Resources/config/services.yml defines parameters for the controller class and + the StatsPeriod formtype. You may override them to use your own (sub)classes. Currently the web based user interface only supports English and Dutch. Please clone the Bundle on Github and add your own language translation! @@ -289,7 +282,8 @@ Configurations details a random between 0 and this value is added by ::sleepUntilSinceInit (which is called by ::sleepUntilFixedExecutionTime). -12. +12. Datetime format used by the web based user interface + ui: dateTimeFormat @@ -307,6 +301,19 @@ Configurations transformer you may like (but that will not be used by the DateTimeType widgets in the Period form so you may want to set your own form type too). +13. Template used by the web based user interface for user administrators + + ui: + statistics: + template + + Bundlename:views subfolder:template filename + + In an actual application you typically use a template of your own that extends your own layout + and includes MetaclassAuthenticationGuardBundle:Guard:statistics_content.html.twig. + + The default template assumes you have base.html.twig still in app/Resources/views. + Notes - releasing is possible for a username in general, an IP address in general, or for the combination of a username with an ip address diff --git a/Resources/doc/changelog.txt b/Resources/doc/changelog.txt index a171d8b..2386862 100644 --- a/Resources/doc/changelog.txt +++ b/Resources/doc/changelog.txt @@ -299,6 +299,27 @@ Make web based user interface more extendable: - Resources/config/services.yml added parameters metaclass_auth_guard.statistics.StatsPeriod.formType - Controller\GuardStatsController::addStatsPeriodForm now uses parameter metaclass_auth_guard.statistics.StatsPeriod.formType ::initDateFormatAndPattern may be overridden for setting locale dependent (custom) patterns - +comitted, pushed, published, tagged v0.3.1 ---------------------------------------------------- +#14: Make user interface independent of DoctrineBundle +- Controller\GuardStatsController no longer uses annotations +- Resources/config/routing.yml now defines each route individually +- Resources/config/services.yml added param metaclass_auth_guard.ui.statistics.controller +- Resources/doc/Installation.md + 9. The user interface for user administrators + added info about the controller template +Make web based user interface more extendable: +- DependencyInjection\Configuration::getConfigTreeBuilder added ui.statistics.template +- DependencyInjection\MetaclassAuthenticationGuardExtension::load now sets param: + metaclass_auth_guard.ui.statistics.template +- Resources/config/services.yml + . corrected the param name for the StatsPeriod formType + . removed the template param +- Resources/doc/Installation.md + 9. The user interface for user administrators + removed info about the template parameter + 12. Datetime format used by the web based user interface + title added + 13. Template used by the web based user interface for user administrators + added