Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security] Support multiple signature algorithms and JWK/JWKSet for O…
…IDC tokens
- Loading branch information
Showing
9 changed files
with
289 additions
and
85 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
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
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
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 |
---|---|---|
@@ -1,43 +0,0 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; | ||
|
||
use Jose\Component\Core\Algorithm as AlgorithmInterface; | ||
use Jose\Component\Signature\Algorithm; | ||
use Symfony\Component\Security\Core\Exception\InvalidArgumentException; | ||
use Symfony\Component\Security\Http\AccessToken\Oidc\OidcTokenHandler; | ||
|
||
/** | ||
* Creates a signature algorithm for {@see OidcTokenHandler}. | ||
* | ||
* @internal | ||
*/ | ||
final class SignatureAlgorithmFactory | ||
{ | ||
public static function create(string $algorithm): AlgorithmInterface | ||
{ | ||
switch ($algorithm) { | ||
case 'ES256': | ||
case 'ES384': | ||
case 'ES512': | ||
if (!class_exists(Algorithm::class.'\\'.$algorithm)) { | ||
throw new \LogicException(sprintf('You cannot use the "%s" signature algorithm since "web-token/jwt-signature-algorithm-ecdsa" is not installed. Try running "composer require web-token/jwt-signature-algorithm-ecdsa".', $algorithm)); | ||
} | ||
|
||
$algorithm = Algorithm::class.'\\'.$algorithm; | ||
|
||
return new $algorithm(); | ||
} | ||
|
||
throw new InvalidArgumentException(sprintf('Unsupported signature algorithm "%s". Only ES* algorithms are supported. If you want to use another algorithm, create your TokenHandler as a service.', $algorithm)); | ||
} | ||
} | ||
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
Oops, something went wrong.