mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-26 08:42:01 +05:30
Added token signers
This commit is contained in:
parent
b62a5cd24a
commit
7f93e9bcae
46
src/TokenSigner/HmacTokenSigner.php
Normal file
46
src/TokenSigner/HmacTokenSigner.php
Normal 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;
|
||||
}
|
||||
}
|
47
src/TokenSigner/RsaKeyTokenSigner.php
Normal file
47
src/TokenSigner/RsaKeyTokenSigner.php
Normal 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;
|
||||
}
|
||||
}
|
16
src/TokenSigner/TokenSignerInterface.php
Normal file
16
src/TokenSigner/TokenSignerInterface.php
Normal 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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user