Skip to content

Commit

Permalink
Merge pull request #147 from ovidiumght/private_and_public_path_shoul…
Browse files Browse the repository at this point in the history
…d_not_be_required

Made the public and private key paths not required…
  • Loading branch information
slashfan committed Mar 24, 2016
2 parents bd9040f + 9a7c452 commit 940528b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 0 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ public function getConfigTreeBuilder()
->addDefaultsIfNotSet()
->children()
->scalarNode('private_key_path')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('public_key_path')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('pass_phrase')
Expand Down
16 changes: 14 additions & 2 deletions Encoder/JWTEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,26 @@ public function decode($token)
*/
protected function getPrivateKey()
{
return openssl_pkey_get_private('file://' . $this->privateKey, $this->passPhrase);
$key = openssl_pkey_get_private('file://' . $this->privateKey, $this->passPhrase);

if(!$key) {
throw new \RuntimeException('The public key cannot be loaded, have you set the %lexik_jwt_authentication.public_key_path% parameter ?');

This comment has been minimized.

Copy link
@chalasr

chalasr Apr 1, 2016

Collaborator

Typo, need to replace "public" by "private" twice in the string. Done in #154

}

return $key;
}

/**
* @return resource
*/
protected function getPublicKey()
{
return openssl_pkey_get_public('file://' . $this->publicKey);
$key = openssl_pkey_get_public('file://' . $this->publicKey);

if(!$key) {
throw new \RuntimeException('The public key cannot be loaded, have you set the %lexik_jwt_authentication.public_key_path% parameter ?');
}

return $key;
}
}

0 comments on commit 940528b

Please sign in to comment.