generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validates JWK before LittleJWT is created in Container
- Loading branch information
1 parent
28104b8
commit 9cbd7f7
Showing
2 changed files
with
28 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace LittleApps\LittleJWT\Factories; | ||
|
||
use Illuminate\Contracts\Foundation\Application; | ||
use LittleApps\LittleJWT\JWK\JsonWebKey; | ||
use LittleApps\LittleJWT\LittleJWT; | ||
use LittleApps\LittleJWT\JWK\JWKValidator; | ||
|
||
class LittleJWTBuilder | ||
{ | ||
/** | ||
* Creates LittleJWT instance. | ||
* | ||
* @param Application $app Application container | ||
* @param JsonWebKey $jwk JWK to sign and verify JWTs with. | ||
* @param boolean $validateJwk If true, validates JWK (default: true) | ||
* @return static | ||
*/ | ||
public static function create(Application $app, JsonWebKey $jwk, bool $validateJwk = true): LittleJWT { | ||
if ($validateJwk) | ||
JWKValidator::validate($jwk); | ||
|
||
return new LittleJWT($app, $jwk); | ||
} | ||
} |
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