Added token signers

This commit is contained in:
Alex Bilbie 2016-08-21 12:54:24 +01:00
parent b62a5cd24a
commit 7f93e9bcae
3 changed files with 109 additions and 0 deletions

View File

@ -0,0 +1,46 @@
<?php
namespace League\OAuth2\Server\TokenSigner;
use Lcobucci\JWT\Signer;
class HmacTokenSigner implements TokenSignerInterface
{
/**
* @var \Lcobucci\JWT\Signer
*/
private $signer;
/**
* @var string
*/
private $key;
/**
* TokenSignerInterface constructor.
*
* @param \Lcobucci\JWT\Signer $signer
* @param string $key
*/
public function __construct(Signer $signer, $key)
{
$this->signer = $signer;
$this->key = $key;
}
/**
* @return \Lcobucci\JWT\Signer
*/
public function getSigner()
{
return $this->signer;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace League\OAuth2\Server\TokenSigner;
use Lcobucci\JWT\Signer;
use League\OAuth2\Server\CryptKey;
class RsaKeyTokenSigner implements TokenSignerInterface
{
/**
* @var \Lcobucci\JWT\Signer
*/
private $signer;
/**
* @var \League\OAuth2\Server\CryptKey
*/
private $key;
/**
* TokenSignerInterface constructor.
*
* @param \Lcobucci\JWT\Signer $signer
* @param CryptKey $privateKey
*/
public function __construct(Signer $signer, CryptKey $privateKey)
{
$this->signer = $signer;
$this->key = new Signer\Key($privateKey->getKeyPath(), $privateKey->getPassPhrase());
}
/**
* @return \Lcobucci\JWT\Signer
*/
public function getSigner()
{
return $this->signer;
}
/**
* @return CryptKey
*/
public function getKey()
{
return $this->key;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace League\OAuth2\Server\TokenSigner;
interface TokenSignerInterface
{
/**
* @return \Lcobucci\JWT\Signer
*/
public function getSigner();
/**
* @return mixed
*/
public function getKey();
}