Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
Merge bc897d0 into 5fd92e1
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor committed Jul 11, 2020
2 parents 5fd92e1 + bc897d0 commit 83692df
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 11 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@
"nyholm/psr7": "^1.3"
},
"require-dev": {
"nunomaduro/larastan": "^0.6.1",
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^8.5||^9.0"
},
"autoload": {
"psr-4": {
"DarkGhostHunter\\Larapass\\": "src"
"DarkGhostHunter\\Larapass\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
"Tests\\": "tests/"
}
},
"scripts": {
Expand All @@ -53,4 +54,4 @@
]
}
}
}
}
9 changes: 9 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
includes:
- vendor/nunomaduro/larastan/extension.neon
parameters:
bootstrapFiles:
- tests/phpstan/bootstrap.php
- tests/phpstan/User.php
level: 5
paths:
- src/
2 changes: 1 addition & 1 deletion src/Auth/EloquentWebAuthnProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function isSignedChallenge(array $credentials)
* @param array $credentials
* @return bool
*/
public function validateCredentials(UserContract $user, array $credentials)
public function validateCredentials($user, array $credentials)
{
if ($this->isSignedChallenge($credentials)) {
return (bool)$this->validator->validate($credentials);
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/WebAuthnAuthenticatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function flushCredentials($except = null) : void;
* Checks if a given credential exists and is enabled.
*
* @param string $id
* @return mixed
* @return bool
*/
public function hasCredentialEnabled(string $id) : bool;

Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/WebAuthnCredential.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function isDisabled()
/**
* Returns the credential ID encoded in BASE64.
*
* @return false
* @return string
*/
public function getPrettyIdAttribute()
{
Expand Down
2 changes: 1 addition & 1 deletion src/WebAuthn/WebAuthnAssertValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class WebAuthnAssertValidator
/**
* If the login should require explicit User verification.
*
* @var bool
* @var string
*/
protected $verifyLogin;

Expand Down
6 changes: 3 additions & 3 deletions src/WebAuthn/WebAuthnAttestCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class WebAuthnAttestCreator
/**
* If the devices should be further verified.
*
* @var bool
* @var string
*/
protected $conveyance;

Expand Down Expand Up @@ -122,7 +122,7 @@ public function __construct(ConfigContract $config,
* @param \Illuminate\Contracts\Auth\Authenticatable|\DarkGhostHunter\Larapass\Contracts\WebAuthnAuthenticatable $user
* @return \Webauthn\PublicKeyCredentialCreationOptions|null
*/
public function retrieveAttestation(WebAuthnAuthenticatable $user)
public function retrieveAttestation($user)
{
return $this->cache->get($this->cacheKey($user));
}
Expand All @@ -133,7 +133,7 @@ public function retrieveAttestation(WebAuthnAuthenticatable $user)
* @param \Illuminate\Contracts\Auth\Authenticatable|\DarkGhostHunter\Larapass\Contracts\WebAuthnAuthenticatable $user
* @return mixed|\Webauthn\PublicKeyCredentialCreationOptions
*/
public function generateAttestation(WebAuthnAuthenticatable $user)
public function generateAttestation($user)
{
$attestation = $this->makeAttestationRequest($user);

Expand Down
2 changes: 1 addition & 1 deletion src/WebAuthn/WebAuthnAttestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __construct(ConfigContract $config,
* @param \Illuminate\Contracts\Auth\Authenticatable|\DarkGhostHunter\Larapass\Contracts\WebAuthnAuthenticatable $user
* @return bool|\Webauthn\PublicKeyCredentialSource
*/
public function validate(array $data, WebAuthnAuthenticatable $user)
public function validate(array $data, $user)
{
if (! $attestation = $this->retrieveAttestation($user)) {
return false;
Expand Down
1 change: 1 addition & 0 deletions tests/phpstan/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WEBAUTHN_NAME=test
39 changes: 39 additions & 0 deletions tests/phpstan/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
use Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];

/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
4 changes: 4 additions & 0 deletions tests/phpstan/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

0 comments on commit 83692df

Please sign in to comment.