Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/Spomky-Labs/jose
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Morselli committed Jul 28, 2016
2 parents 90004b9 + 384ebcb commit 73c777d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions doc/operation/Check.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ In the following lazy example, we check is the claim `animal` is set. If it is s
namespace Acme\Checker;

use Assert\Assertion;
use Jose\Checker\ClaimCheckerInterface
use Jose\Checker\ClaimCheckerInterface;
use Jose\Object\JWTInterface;

class AnimalChecker implements ClaimCheckerInterface
Expand All @@ -57,7 +57,7 @@ class AnimalChecker implements ClaimCheckerInterface
$animal = $jwt->getClaim('animal');
Assertion::inArray($animal, ['bog', 'cat', 'owl'], 'Bad animal.');

// We return an array with the checked claims (here only 'animal'.
// We return an array with the checked claims (here only 'animal').
return ['animal'];
}
}
Expand All @@ -69,12 +69,12 @@ The Checker Manager will handle all checkers and verify a JWS.
After the manager is created, you have to add the checkers. Then, you will be able to check the JWS.

```php
use Jose\Factory\CheckerManager;
use Jose\Factory\AudienceChecker;
use Jose\Factory\CriticalHeaderChecker;
use Jose\Factory\ExpirationTimeChecker;
use Jose\Factory\IssuedAtChecker;
use Jose\Factory\NotBeforeChecker;
use Jose\Checker\CheckerManager;
use Jose\Checker\AudienceChecker;
use Jose\Checker\CriticalHeaderChecker;
use Jose\Checker\ExpirationTimeChecker;
use Jose\Checker\IssuedAtChecker;
use Jose\Checker\NotBeforeChecker;

// We create an instance of CheckerManager.
$checker_manager = new CheckerManager();
Expand All @@ -83,7 +83,7 @@ $checker_manager = new CheckerManager();
$checker_manager->addClaimChecker(new ExpirationTimeChecker());
$checker_manager->addClaimChecker(new IssuedAtChecker());
$checker_manager->addClaimChecker(new NotBeforeChecker());
$checker_manager->addClaimChecker(new AudienceChecker('My Server));
$checker_manager->addClaimChecker(new AudienceChecker('My Server'));

// We add the header checker (crit).
$checker_manager->addHeaderChecker(new CriticalHeaderChecker());
Expand Down Expand Up @@ -122,13 +122,14 @@ This factory is also able to receive Checkers in the list of arguments:

```php
use Acme\Checker\AnimalChecker;
use Jose\Checker\AudienceChecker;
use Jose\Factory\CheckerManagerFactory;

$claim_checker_list = [
'exp',
'iat',
'nbf',
new Audience('My Server'),
new AudienceChecker('My Server'),
new AnimalChecker(),
];

Expand Down
2 changes: 1 addition & 1 deletion examples/Load1.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

// You can get headers or claims contained in this object
$jws->getSignature(0)->hasProtectedHeader('alg'); // true
$jws->getSignature(0)->hasProtectedHeader('alg'); // RS256
$jws->getSignature(0)->getProtectedHeader('alg'); // RS256
$jws->getSignature(0)->getProtectedHeaders(); // ['alg'=>'RS256']
$jws->hasClaim('foo'); // false
$jws->hasClaim('iss'); // true
Expand Down

0 comments on commit 73c777d

Please sign in to comment.