Skip to content

Commit

Permalink
bug #999 Unify audience claim (aerrasti)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.x branch.

Discussion
----------

Unify audience claim

The 'aud' part of the payload is being converted to array, thats why we need to use UnifyAudience claim formatter to create lcobucci token.

Before the change:
```json
{
  "iss": "iss",
  "aud": [
     "audience"
  ],
  "sub": "sub",
}
```
After the change
```json
{
  "iss": "iss",
  "aud": "audience",
  "sub": "sub",
}
```
Check out the `default` method:

https://github.com/lcobucci/jwt/blob/4.2.x/src/Encoding/ChainedFormatter.php

:)

Commits
-------

666b1ce Unify audience claim
  • Loading branch information
chalasr committed Apr 5, 2022
2 parents c06387e + 666b1ce commit ebaaa13
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Services/JWSProvider/LcobucciJWSProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Lcobucci\Clock\SystemClock;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Encoding\ChainedFormatter;
use Lcobucci\JWT\Encoding\JoseEncoder;
use Lcobucci\JWT\Encoding\MicrosecondBasedDateConversion;
use Lcobucci\JWT\Parser;
use Lcobucci\JWT\Signer;
use Lcobucci\JWT\Signer\Hmac;
Expand Down Expand Up @@ -87,7 +87,7 @@ public function __construct(KeyLoaderInterface $keyLoader, string $cryptoEngine,
public function create(array $payload, array $header = [])
{
if (class_exists(JWTBuilder::class)) {
$jws = new JWTBuilder(new JoseEncoder(), new MicrosecondBasedDateConversion());
$jws = new JWTBuilder(new JoseEncoder(), ChainedFormatter::default());
} else {
$jws = new Builder();
}
Expand Down

0 comments on commit ebaaa13

Please sign in to comment.