Skip to content

Commit

Permalink
bring the realpath back (#22)
Browse files Browse the repository at this point in the history
* bring the realpath back

* fix return type

* add cs fixer cache

* run cs fixer
  • Loading branch information
miladrahimi authored Jun 1, 2024
1 parent e8b96a7 commit 675a7fa
Show file tree
Hide file tree
Showing 67 changed files with 220 additions and 91 deletions.
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
11 changes: 6 additions & 5 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 resource 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 = file_exists($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_private($content, $passphrase);
if ($this->resource === false) {
Expand All @@ -34,7 +35,7 @@ public function __construct(string $key, string $passphrase = '', ?string $id =
}

/**
* @return mixed
* @return resource
*/
public function getResource()
{
Expand Down
11 changes: 6 additions & 5 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 resource 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 = file_exists($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_public($content);
if ($this->resource === false) {
Expand All @@ -33,7 +34,7 @@ public function __construct(string $key, ?string $id = null)
}

/**
* @return mixed
* @return resource
*/
public function getResource()
{
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
11 changes: 6 additions & 5 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 resource 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 = file_exists($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_private($content, $passphrase);
if ($this->resource === false) {
Expand All @@ -34,7 +35,7 @@ public function __construct(string $key, string $passphrase = '', ?string $id =
}

/**
* @return mixed
* @return resource
*/
public function getResource()
{
Expand Down
Loading

0 comments on commit 675a7fa

Please sign in to comment.