Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/authentication_local.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [
'Authentication' => [
'Api' => [
'algorithm' => 'ES256',
'algorithm' => 'RS256',
'expiration' => time() + 60,
'privateKey' => null,
'publicKey' => null,
Expand Down
10 changes: 2 additions & 8 deletions src/Authentication/ApiAuthenticationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe
AbstractIdentifier::CREDENTIAL_USERNAME => 'email',
AbstractIdentifier::CREDENTIAL_PASSWORD => 'password',
];
$config = Configure::read('Authentication.Api');
foreach (['publicKey', 'algorithm'] as $key) {
if (!array_key_exists($key, $config)) {
throw new MissingConfigurationException($key);
}
}
return new AuthenticationService([
'authenticators' => [
'Authentication.Jwt' => [
'identifier' => 'Authentication.JwtSubject',
'secretKey' => $config['publicKey'],
'algorithm' => $config['algorithm'],
'secretKey' => Configure::readOrFail('Authentication.Api.publicKey'),
'algorithm' => Configure::readOrFail('Authentication.Api.algorithm'),
],
'Authentication.Form' => [
'identifier' => [
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Api/V1/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public function authenticate()
$result = $this->Authentication->getResult();
dd($result);
if ($result->isValid()) {
$algorithm = Configure::read('');
$privateKey = Configure::read('');
$expiration = Configure::read('');
$algorithm = Configure::readOrFail('Authentication.Api.algorithm');
$privateKey = Configure::readOrFail('Authentication.Api.privateKey');
$expiration = Configure::readOrFail('Authentication.Api.expiration');
$user = $result->getData();
$payload = [
'iss' => $this->request->domain(),
Expand Down
Loading