Skip to content

Commit

Permalink
Fix incorrect class name in services definition, update chanted getKe…
Browse files Browse the repository at this point in the history
…y method to getSecret, update documentation examples.
  • Loading branch information
Sam Stevens committed Apr 26, 2016
1 parent 0de301c commit 8df5342
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parameter key="vipx_bot_detect.metadata.loader.yml.class">Vipx\BotDetect\Metadata\Loader\YamlFileLoader</parameter>
<parameter key="vipx_bot_detect.metadata.dumper.class">Vipx\BotDetect\Metadata\Dumper\PhpMetadataDumper</parameter>
<parameter key="vipx_bot_detect.detector.class">Vipx\BotDetectBundle\BotDetector</parameter>
<parameter key="vipx_bot_detect.security.authentication_listener.class">Vipx\BotDetect\Security\BotAuthenticationListener</parameter>
<parameter key="vipx_bot_detect.security.authentication_listener.class">Vipx\BotDetectBundle\Security\BotAuthenticationListener</parameter>
<parameter key="vipx_bot_detect.metadata_file_locator.class">Vipx\BotDetectBundle\Config\MetadataFileLocator</parameter>
</parameters>

Expand Down
6 changes: 3 additions & 3 deletions Resources/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ vipx_bot_detect:
use_listener: true
```

Now the `security.context` service holds a special bot token with information about the visiting bot. This token also has the `ROLE_BOT` role now, which you can simply use in your controller.
Now the `security.authorization_checker` service holds a special bot token with information about the visiting bot. This token also has the `ROLE_BOT` role now, which you can simply use in your controller.

``` php
<?php
Expand All @@ -129,14 +129,14 @@ class BotController extends Controller

public function indexAction()
{
if ($this->get('security.context')->isGranted('ROLE_BOT')) {
if ($this->get('security.authorization_checker')->isGranted('ROLE_BOT')) {
// The bot is not allowed to access this controller
throw new AccessDeniedException();
}

// or

$token = $this->get('security.context')->getToken();
$token = $this->get('security.token_storage')->getToken();

if ($token instanceof BotToken) {
$botMetadata = $token->getMetadata();
Expand Down
2 changes: 1 addition & 1 deletion Security/BotToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getMetadata()
*/
public static function fromAnonymousToken(MetadataInterface $metadata, AnonymousToken $token)
{
return new self($token->getKey(), $metadata, $token->getRoles());
return new self($token->getSecret(), $metadata, $token->getRoles());
}

}

0 comments on commit 8df5342

Please sign in to comment.