Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix realpath 2 #23

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/build
/vendor
.DS_Store
.php-cs-fixer.cache
.phpunit.result.cache
composer.lock
4 changes: 3 additions & 1 deletion src/Base64/Base64Parser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Base64;

Expand Down
4 changes: 3 additions & 1 deletion src/Base64/SafeBase64Parser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Base64;

Expand Down
5 changes: 4 additions & 1 deletion src/Cryptography/Algorithms/Ecdsa/AbstractEcdsaSigner.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;

use MiladRahimi\Jwt\Cryptography\Keys\EcdsaPrivateKey;
use MiladRahimi\Jwt\Cryptography\Signer;
use MiladRahimi\Jwt\Exceptions\SigningException;

use function ltrim;
use function ord;
use function str_pad;
Expand Down
5 changes: 4 additions & 1 deletion src/Cryptography/Algorithms/Ecdsa/AbstractEcdsaVerifier.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;

use MiladRahimi\Jwt\Cryptography\Keys\EcdsaPublicKey;
use MiladRahimi\Jwt\Cryptography\Verifier;
use MiladRahimi\Jwt\Exceptions\InvalidSignatureException;

use function chr;
use function ltrim;
use function ord;
Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Ecdsa/Algorithm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Ecdsa/ES256KVerifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Ecdsa/ES256Signer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Ecdsa/ES256Verifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Ecdsa/ES384Signer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Ecdsa/ES384Verifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;

Expand Down
5 changes: 4 additions & 1 deletion src/Cryptography/Algorithms/Eddsa/EdDsaSigner.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Eddsa;

Expand All @@ -7,6 +9,7 @@
use MiladRahimi\Jwt\Exceptions\SigningException;
use RuntimeException;
use SodiumException;

use function function_exists;

class EdDsaSigner implements Signer
Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Eddsa/EdDsaVerifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Eddsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Hmac/AbstractHmac.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Hmac;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Hmac/HS256.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Hmac;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Hmac/HS384.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Hmac;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Hmac/HS512.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Hmac;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/AbstractRsaSigner.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/AbstractRsaVerifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/Algorithm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/RS256Signer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/RS256Verifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/RS384Signer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/RS384Verifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/RS512Signer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Algorithms/Rsa/RS512Verifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;

Expand Down
9 changes: 5 additions & 4 deletions src/Cryptography/Keys/EcdsaPrivateKey.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Keys;

use MiladRahimi\Jwt\Exceptions\InvalidKeyException;
use Throwable;

class EcdsaPrivateKey
{
/**
* @var mixed Key file resource handler
* @var mixed Key resource handler
*/
protected $resource;

Expand All @@ -23,7 +24,7 @@ class EcdsaPrivateKey
*/
public function __construct(string $key, string $passphrase = '', ?string $id = null)
{
$content = file_exists($key) ? file_get_contents($key) : $key;
$content = realpath($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_private($content, $passphrase);
if ($this->resource === false) {
Expand Down
9 changes: 5 additions & 4 deletions src/Cryptography/Keys/EcdsaPublicKey.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Keys;

use MiladRahimi\Jwt\Exceptions\InvalidKeyException;
use Throwable;

class EcdsaPublicKey
{
/**
* @var mixed Key file resource handler
* @var mixed Key resource handler
*/
protected $resource;

Expand All @@ -22,7 +23,7 @@ class EcdsaPublicKey
*/
public function __construct(string $key, ?string $id = null)
{
$content = file_exists($key) ? file_get_contents($key) : $key;
$content = realpath($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_public($content);
if ($this->resource === false) {
Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Keys/EdDsaPrivateKey.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Keys;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Keys/EdDsaPublicKey.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Keys;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Keys/HmacKey.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Keys;

Expand Down
9 changes: 5 additions & 4 deletions src/Cryptography/Keys/RsaPrivateKey.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Keys;

use MiladRahimi\Jwt\Exceptions\InvalidKeyException;
use Throwable;

class RsaPrivateKey
{
/**
* @var mixed Key file resource handler
* @var mixed Key resource handler
*/
protected $resource;

Expand All @@ -23,7 +24,7 @@ class RsaPrivateKey
*/
public function __construct(string $key, string $passphrase = '', ?string $id = null)
{
$content = file_exists($key) ? file_get_contents($key) : $key;
$content = realpath($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_private($content, $passphrase);
if ($this->resource === false) {
Expand Down
9 changes: 5 additions & 4 deletions src/Cryptography/Keys/RsaPublicKey.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography\Keys;

use MiladRahimi\Jwt\Exceptions\InvalidKeyException;
use Throwable;

class RsaPublicKey
{
/**
* @var mixed Key file resource handler
* @var mixed Key resource handler
*/
protected $resource;

Expand All @@ -22,7 +23,7 @@ class RsaPublicKey
*/
public function __construct(string $key, ?string $id = null)
{
$content = file_exists($key) ? file_get_contents($key) : $key;
$content = realpath($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_public($content);
if ($this->resource === false) {
Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Signer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography;

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptography/Verifier.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace MiladRahimi\Jwt\Cryptography;

Expand Down
Loading