11
11
12
12
namespace League \OAuth2 \Server ;
13
13
14
- use Lcobucci \JWT \Signer \Key ;
15
- use Lcobucci \JWT \Signer \Key \InMemory ;
16
- use Lcobucci \JWT \Signer \Key \LocalFileReference ;
17
14
use LogicException ;
18
15
19
16
class CryptKey
@@ -25,9 +22,9 @@ class CryptKey
25
22
private const FILE_PREFIX = 'file:// ' ;
26
23
27
24
/**
28
- * @var Key
25
+ * @var string Key contents
29
26
*/
30
- protected $ key ;
27
+ protected $ keyContents ;
31
28
32
29
/**
33
30
* @var string
@@ -49,8 +46,7 @@ public function __construct($keyPath, $passPhrase = null, $keyPermissionsCheck =
49
46
$ this ->passPhrase = $ passPhrase ;
50
47
51
48
if (\strpos ($ keyPath , self ::FILE_PREFIX ) !== 0 && $ this ->isValidKey ($ keyPath , $ this ->passPhrase ?? '' )) {
52
- $ contents = $ keyPath ;
53
- $ this ->key = InMemory::plainText ($ keyPath , $ this ->passPhrase ?? '' );
49
+ $ this ->keyContents = $ keyPath ;
54
50
$ this ->keyPath = '' ;
55
51
// There's no file, so no need for permission check.
56
52
$ keyPermissionsCheck = false ;
@@ -62,10 +58,9 @@ public function __construct($keyPath, $passPhrase = null, $keyPermissionsCheck =
62
58
if (!\is_readable ($ keyPath )) {
63
59
throw new LogicException (\sprintf ('Key path "%s" does not exist or is not readable ' , $ keyPath ));
64
60
}
65
- $ contents = \file_get_contents ($ keyPath );
61
+ $ this -> keyContents = \file_get_contents ($ keyPath );
66
62
$ this ->keyPath = $ keyPath ;
67
- $ this ->key = LocalFileReference::file ($ this ->keyPath , $ this ->passPhrase ?? '' );
68
- if (!$ this ->isValidKey ($ contents , $ this ->passPhrase ?? '' )) {
63
+ if (!$ this ->isValidKey ($ this ->keyContents , $ this ->passPhrase ?? '' )) {
69
64
throw new LogicException ('Unable to read key from file ' . $ keyPath );
70
65
}
71
66
} else {
@@ -89,13 +84,13 @@ public function __construct($keyPath, $passPhrase = null, $keyPermissionsCheck =
89
84
}
90
85
91
86
/**
92
- * Get key
87
+ * Get key contents
93
88
*
94
- * @return Key
89
+ * @return string Key contents
95
90
*/
96
- public function getKey (): Key
91
+ public function getKeyContents (): string
97
92
{
98
- return $ this ->key ;
93
+ return $ this ->keyContents ;
99
94
}
100
95
101
96
/**
0 commit comments