Skip to content

Commit

Permalink
Merge pull request #26 from mainick/fix-encryption-key-requirement
Browse files Browse the repository at this point in the history
Fix encryption key requirement in KeycloakClientBundle
  • Loading branch information
mainick authored Oct 28, 2024
2 parents 5904b38 + e7020ad commit 2715e7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public function getConfigTreeBuilder(): TreeBuilder
->scalarNode('encryption_algorithm')->defaultNull()->end()
->scalarNode('encryption_key')->defaultNull()->end()
->scalarNode('encryption_key_path')->defaultNull()->end()
->validate()
->ifTrue(function ($v) {
return empty($v['encryption_key']) && empty($v['encryption_key_path']);
})
->thenInvalid('At least one of "encryption_key" or "encryption_key_path" must be provided.')
->end()
->scalarNode('version')->defaultNull()->end()
->end()
->end()
Expand Down
5 changes: 2 additions & 3 deletions src/Provider/KeycloakClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ public function __construct(

if ('RS256' === $this->encryption_algorithm) {
if ('' === $this->encryption_key && '' === $this->encryption_key_path) {
throw new \RuntimeException('encryption_key is empty');
throw new \RuntimeException('Either encryption_key or encryption_key_path must be provided.');
}
if ('' !== $this->encryption_key) {
$this->keycloakProvider->setEncryptionKey($this->encryption_key);
}
if ('' !== $this->encryption_key_path) {
} elseif ('' !== $this->encryption_key_path) {
$this->keycloakProvider->setEncryptionKeyPath($this->encryption_key_path);
}
}
Expand Down

0 comments on commit 2715e7d

Please sign in to comment.