コード例 #1
0
 public function testAddKey()
 {
     $request = new Request();
     $event = new GenerateKeyEvent($request, "foo");
     $this->assertEquals("foo", $event->getKey());
     $event->addToKey("bar");
     $this->assertEquals("foo:bar", $event->getKey());
     $event->addToKey("baz");
     $this->assertEquals("foo:bar:baz", $event->getKey());
     $event->addToKey("");
     $this->assertEquals("foo:bar:baz:", $event->getKey());
 }
コード例 #2
0
 /**
  * @param GenerateKeyEvent $event
  */
 public function onGenerateKey(GenerateKeyEvent $event)
 {
     $token = $this->securityContext->getToken();
     if (!$token instanceof \FOS\OAuthServerBundle\Security\Authentication\Token\OAuthToken) {
         return;
     }
     $event->addToKey($token->getToken());
 }
コード例 #3
0
 /**
  * Apply rate limits separately to different IPs.
  *
  * @param GenerateKeyEvent $event
  */
 public function setRateLimitKey(GenerateKeyEvent $event)
 {
     $event->addToKey($event->getRequest()->getClientIp());
 }