Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@ The following sample code authenticates as an installation using [lcobucci/jwt](
to generate a JSON Web Token (JWT).

```php
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Key;
use Lcobucci\JWT\Signer\Rsa\Sha256;

$builder = new Github\HttpClient\Builder(new GuzzleClient());
$github = new Github\Client($builder, 'machine-man-preview');

$jwt = (new Builder)
->setIssuer($integrationId)
->setIssuedAt(time())
->setExpiration(time() + 60)
->sign(new Sha256(), (new Keychain)->getPrivateKey($pemPrivateKeyPath))
->sign(new Sha256(), new Key('file:///path/to/integration.private-key.pem'))
->getToken();

$github->authenticate($jwt, null, Github\Client::AUTH_JWT);
Expand Down