-
-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,12 @@ | |
namespace Lexik\Bundle\JWTAuthenticationBundle\Services\KeyLoader; | ||
|
||
/** | ||
* Interface for classes that are able to load crypto keys. | ||
* | ||
* @author Robin Chalas <[email protected]> | ||
*/ | ||
interface KeyDumperInterface | ||
{ | ||
/** | ||
* Dumps a key as sharable s | ||
* | ||
* @param resource|string | ||
* Dumps a key to be shared between parties. | ||
* | ||
* @return resource|string | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* | ||
* @author Robin Chalas <[email protected]> | ||
*/ | ||
class OpenSSLKeyLoader extends AbstractKeyLoader | ||
class OpenSSLKeyLoader extends AbstractKeyLoader implements KeyDumperInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
|
@@ -32,4 +32,18 @@ public function loadKey($type) | |
|
||
return $key; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function dumpKey() | ||
{ | ||
$key = openssl_pkey_get_details($this->loadKey('public')); | ||
|
||
if (!isset($key['key'])) { | ||
return; | ||
} | ||
|
||
return $key['key']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* | ||
* @author Robin Chalas <[email protected]> | ||
*/ | ||
class RawKeyLoader extends AbstractKeyLoader | ||
class RawKeyLoader extends AbstractKeyLoader implements KeyDumperInterface | ||
{ | ||
/** | ||
* @param string $type | ||
|
@@ -20,4 +20,12 @@ public function loadKey($type) | |
{ | ||
return file_get_contents($this->getKeyPath($type)); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function dumpKey() | ||
{ | ||
return $this->loadKey('public'); | ||
} | ||
} |