Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed May 2, 2024
1 parent a1fe4f1 commit a1219f8
Show file tree
Hide file tree
Showing 38 changed files with 175 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
Dockerfile export-ignore
docker-compose.yml export-ignore
phpstan.dist.neon export-ignore
phpcs.xml.dist export-ignore
phpunit.xml export-ignore
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.1', '8.2']
php: ['8.1', '8.2', '8.3']
name: Testing on PHP ${{ matrix.php }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -26,5 +26,8 @@ jobs:
- name: Run phpunit
run: vendor/bin/phpunit

- name: Run phpstan
run: composer require --dev illuminate/support && vendor/bin/phpstan analyze --no-progress --autoload-file=tests/phpstan/bootstrap.php --level=5 src/
- name: Run analyzer
run: composer require --dev illuminate/support && vendor/bin/phpstan analyze --no-progress --autoload-file=tests/phpstan/bootstrap.php src/

- name: Validate coding standards
run: vendor/bin/phpcs
Empty file modified .gitignore
100755 → 100644
Empty file.
Empty file modified LICENSE
100755 → 100644
Empty file.
Empty file modified README.md
100755 → 100644
Empty file.
14 changes: 10 additions & 4 deletions composer.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"phpstan/phpstan": "^1"
"phpstan/phpstan": "^1",
"squizlabs/php_codesniffer": "^3.8",
"slevomat/coding-standard": "~8.0"
},
"autoload": {
"psr-4": {
"Intervention\\HttpAuth\\": "src/"
"Intervention\\HttpAuth\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Intervention\\HttpAuth\\Test\\": "tests/"
"Intervention\\HttpAuth\\Tests\\": "tests"
}
},
"minimum-stability": "stable"
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
68 changes: 68 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0"?>
<ruleset name="Intervention">
<file>src/</file>
<file>tests/</file>
<arg name="colors"/>
<arg value="p"/>

<rule ref="PSR12"/>
<rule ref="Generic.Arrays.ArrayIndent"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Formatting.SpaceAfterNot">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
<rule ref="Generic.Metrics.NestingLevel"/>
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.RequireSelfReference"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="Intervention\HttpAuth"/>
<element key="tests" value="Intervention\HttpAuth\Tests"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<rule ref="SlevomatCodingStandard.Strings.DisallowVariableParsing"/>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="spacesCountAroundEqualsSign" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
<properties>
<property name="withSpaces" value="no" />
<property name="nullPosition" value="first" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
</ruleset>
Empty file modified phpunit.xml.dist
100755 → 100644
Empty file.
8 changes: 5 additions & 3 deletions src/AbstractVault.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth;

abstract class AbstractVault
Expand All @@ -14,7 +16,7 @@ abstract public function getDirective(): Directive;
/**
* Determine if vault is accessible by given key
*
* @param Key $key
* @param Key $key
* @return bool
*/
abstract public function unlocksWithKey(Key $key): bool;
Expand Down Expand Up @@ -129,8 +131,8 @@ public function getPassword(): string
/**
* Set username and password at once
*
* @param string $username
* @param string $password
* @param string $username
* @param string $password
* @return AbstractVault
*/
public function withCredentials(string $username, string $password): self
Expand Down
14 changes: 8 additions & 6 deletions src/Authenticator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth;

use Intervention\HttpAuth\Exception\NotSupportedException;
Expand Down Expand Up @@ -77,7 +79,7 @@ public function secure(?string $message = null): void
/**
* Set type of vault to configure
*
* @param string $type
* @param string $type
* @return self
*/
public function withType(string $type): self
Expand All @@ -90,7 +92,7 @@ public function withType(string $type): self
/**
* Set realm name of configured vault
*
* @param string $realm
* @param string $realm
* @return Authenticator
*/
public function withRealm(string $realm): self
Expand All @@ -103,7 +105,7 @@ public function withRealm(string $realm): self
/**
* Set username of configured vault
*
* @param string $username
* @param string $username
* @return Authenticator
*/
public function withUsername(string $username): self
Expand All @@ -116,7 +118,7 @@ public function withUsername(string $username): self
/**
* Set password of configured vault
*
* @param string $password
* @param string $password
* @return Authenticator
*/
public function withPassword(string $password): self
Expand All @@ -129,8 +131,8 @@ public function withPassword(string $password): self
/**
* Set credentials for configured vault
*
* @param string $username
* @param string $password
* @param string $username
* @param string $password
* @return Authenticator
*/
public function withCredentials(string $username, string $password): self
Expand Down
2 changes: 2 additions & 0 deletions src/Directive.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth;

class Directive
Expand Down
5 changes: 3 additions & 2 deletions src/Environment.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth;

use Intervention\HttpAuth\Exception\AuthentificationException;
Expand Down Expand Up @@ -28,8 +30,7 @@ public function getKey(): Key
{
foreach ($this->tokenClassnames as $classname) {
try {
$key = (new $classname())->getKey();
return $key;
return (new $classname())->getKey();
} catch (AuthentificationException) {
// try next
}
Expand Down
3 changes: 2 additions & 1 deletion src/Exception/AuthentificationException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Exception;

use RuntimeException;

class AuthentificationException extends RuntimeException
{
//
}
3 changes: 2 additions & 1 deletion src/Exception/NotSupportedException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Exception;

use RuntimeException;

class NotSupportedException extends RuntimeException
{
//
}
6 changes: 4 additions & 2 deletions src/Key.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth;

class Key
Expand Down Expand Up @@ -178,10 +180,10 @@ public function getResponse(): ?string
* Set property to given value on current instance
*
* @param string $name
* @param mixed $value
* @param mixed $value
* @return Key
*/
public function setProperty($name, $value): Key
public function setProperty($name, $value): self
{
if (property_exists($this, $name)) {
$this->{$name} = $value;
Expand Down
2 changes: 2 additions & 0 deletions src/Token/AbstractToken.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Token;

use Intervention\HttpAuth\Key;
Expand Down
2 changes: 2 additions & 0 deletions src/Token/HttpAuthentification.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Token;

use Intervention\HttpAuth\Exception\AuthentificationException;
Expand Down
2 changes: 2 additions & 0 deletions src/Token/HttpAuthorization.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Token;

use Intervention\HttpAuth\Exception\AuthentificationException;
Expand Down
2 changes: 2 additions & 0 deletions src/Token/PhpAuthDigest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Token;

use Intervention\HttpAuth\Exception\AuthentificationException;
Expand Down
2 changes: 2 additions & 0 deletions src/Token/PhpAuthUser.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Token;

use Intervention\HttpAuth\Exception\AuthentificationException;
Expand Down
2 changes: 2 additions & 0 deletions src/Token/RedirectHttpAuthorization.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Token;

use Intervention\HttpAuth\Exception\AuthentificationException;
Expand Down
4 changes: 3 additions & 1 deletion src/Vault/BasicVault.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Vault;

use Intervention\HttpAuth\AbstractVault;
Expand All @@ -11,7 +13,7 @@ class BasicVault extends AbstractVault
/**
* Determine if given key is able to unlock (access) vault.
*
* @param Key $key
* @param Key $key
* @return bool
*/
public function unlocksWithKey(Key $key): bool
Expand Down
6 changes: 4 additions & 2 deletions src/Vault/DigestVault.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Intervention\HttpAuth\Vault;

use Intervention\HttpAuth\AbstractVault;
Expand All @@ -11,7 +13,7 @@ class DigestVault extends AbstractVault
/**
* Determine if given key is able to unlock (access) vault.
*
* @param Key $key
* @param Key $key
* @return bool
*/
public function unlocksWithKey(Key $key): bool
Expand All @@ -25,7 +27,7 @@ public function unlocksWithKey(Key $key): bool
/**
* Build and return hash from given key/vault
*
* @param Key $key
* @param Key $key
* @return string
*/
private function getKeyHash(Key $key): string
Expand Down
4 changes: 3 additions & 1 deletion tests/AbstractTokenTestCase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace Intervention\HttpAuth\Test;
declare(strict_types=1);

namespace Intervention\HttpAuth\Tests;

use PHPUnit\Framework\TestCase;

Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/AbstractVaultTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace Intervention\HttpAuth\Test\Unit;
declare(strict_types=1);

namespace Intervention\HttpAuth\Tests\Unit;

use Intervention\HttpAuth\AbstractVault;
use PHPUnit\Framework\TestCase;
Expand Down
Loading

0 comments on commit a1219f8

Please sign in to comment.