Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 8ca636b

Browse files
committed
Merge pull request #2 from webimpress/fixes
General fixes
2 parents 9daeef9 + b9a61e5 commit 8ca636b

15 files changed

+65
-69
lines changed

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/.gitignore export-ignore
44
/.travis.yml export-ignore
55
/composer.lock export-ignore
6-
/docs export-ignore
6+
/docs/ export-ignore
77
/mkdocs.yml export-ignore
88
/phpcs.xml export-ignore
99
/phpunit.xml.dist export-ignore
10-
/test export-ignore
10+
/test/ export-ignore

.gitignore

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
docs/html/
2-
vendor/
3-
zf-mkdoc-theme/
4-
clover.xml
5-
coveralls-upload.json
6-
phpunit.xml
7-
zf-mkdoc-theme.tgz
1+
/clover.xml
2+
/coveralls-upload.json
3+
/docs/html/
4+
/phpunit.xml
5+
/vendor/
6+
/zf-mkdoc-theme.tgz
7+
/zf-mkdoc-theme/

composer.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
{
22
"name": "zendframework/zend-expressive-authentication",
33
"description": "Authentication middleware for Expressive and PSR-7 applications",
4-
"homepage": "https://docs.zendframework.com/zend-expressive-authentication/",
5-
"type": "library",
64
"license": "BSD-3-Clause",
75
"keywords": [
6+
"zf",
7+
"zendframework",
88
"authentication",
99
"http",
1010
"middleware",
1111
"zend-expressive",
1212
"psr-7"
1313
],
14-
"config": {
15-
"sort-packages": true
16-
},
1714
"support": {
1815
"docs": "https://docs.zendframework.com/zend-expressive-authentication/",
1916
"issues": "https://github.com/zendframework/zend-expressive-authentication/issues",
2017
"source": "https://github.com/zendframework/zend-expressive-authentication",
18+
"rss": "https://github.com/zendframework/zend-expressive-authentication/releases.atom",
2119
"slack": "https://zendframework-slack.herokuapp.com",
2220
"forum": "https://discourse.zendframework.com/c/questions/expressive"
2321
},
@@ -51,16 +49,23 @@
5149
"ZendTest\\Expressive\\Authentication\\": "test/"
5250
}
5351
},
52+
"config": {
53+
"sort-packages": true
54+
},
55+
"extra": {
56+
"branch-alias": {
57+
"dev-master": "1.0-dev"
58+
}
59+
},
5460
"scripts": {
5561
"check": [
5662
"@cs-check",
5763
"@test"
5864
],
59-
"upload-coverage": "coveralls -v",
6065
"cs-check": "phpcs",
6166
"cs-fix": "phpcbf",
6267
"test": "phpunit --colors=always",
63-
"test-coverage": "phpunit --coverage-clover clover.xml",
64-
"license-check": "vendor/bin/docheader check src/ test/"
68+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
69+
"upload-coverage": "coveralls -v"
6570
}
6671
}

src/AuthenticationInterface.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ interface AuthenticationInterface
1515
/**
1616
* Authenticate the PSR-7 request and return a valid user
1717
* or null if not authenticated
18-
*
19-
* @param ServerRequestInterface $request
20-
* @return UserInterface|null
2118
*/
22-
public function authenticate(ServerRequestInterface $request): ?UserInterface;
19+
public function authenticate(ServerRequestInterface $request) : ?UserInterface;
2320

2421
/**
2522
* Generate the unauthorized response
26-
*
27-
* @param ServerRequestInterface $request
28-
* @return ResponseInterface
2923
*/
30-
public function unauthorizedResponse(ServerRequestInterface $request): ResponseInterface;
24+
public function unauthorizedResponse(ServerRequestInterface $request) : ResponseInterface;
3125
}

src/AuthenticationMiddleware.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@
1414
class AuthenticationMiddleware implements ServerMiddlewareInterface
1515
{
1616
/**
17-
* @var AuthentiationInterface
17+
* @var AuthenticationInterface
1818
*/
1919
protected $auth;
2020

21-
/**
22-
* Constructor
23-
*
24-
* @param AuthenticationInterface $authentication
25-
* @return void
26-
*/
2721
public function __construct(AuthenticationInterface $auth)
2822
{
2923
$this->auth = $auth;

src/Exception/ExceptionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
44
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
5-
* @license https://github.com/zendframework/zend-expressive-cache/blob/master/LICENSE.md New BSD License
5+
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
66
*/
77

88
namespace Zend\Expressive\Authentication\Exception;

src/Exception/InvalidConfigException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
44
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
5-
* @license https://github.com/zendframework/zend-expressive-cache/blob/master/LICENSE.md New BSD License
5+
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
66
*/
77

88
namespace Zend\Expressive\Authentication\Exception;

src/ResponsePrototypeTrait.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ trait ResponsePrototypeTrait
1515
/**
1616
* Return a ResponseInterface service if present or Zend\Diactoros\Response
1717
*
18-
* @param ContainerInterface $container
1918
* @throws Exception\InvalidConfigException
20-
* @return ResponseInterface
2119
*/
22-
protected function getResponsePrototype(ContainerInterface $container): ResponseInterface
20+
protected function getResponsePrototype(ContainerInterface $container) : ResponseInterface
2321
{
2422
if (! $container->has(ResponseInterface::class)
2523
&& ! class_exists(Response::class)

src/UserInterface.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@ interface UserInterface
1010
{
1111
/**
1212
* Get the username
13-
*
14-
* @return string
1513
*/
16-
public function getUsername(): string;
14+
public function getUsername() : string;
1715

1816
/**
1917
* Get the user role
20-
*
21-
* @return string
2218
*/
23-
public function getUserRole(): string;
19+
public function getUserRole() : string;
2420
}

src/UserRepository/Htpasswd.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ class Htpasswd implements UserRepositoryInterface
2020
use UserTrait;
2121

2222
/**
23-
* Constructor
24-
*
25-
* @param string $filename
23+
* @var string
24+
*/
25+
private $filename;
26+
27+
/**
28+
* @throws Exception\InvalidConfigException
2629
*/
2730
public function __construct(string $filename)
2831
{
2932
if (! file_exists($filename)) {
3033
throw new Exception\InvalidConfigException(sprintf(
31-
"I cannot access the htpasswd file %s",
34+
'I cannot access the htpasswd file %s',
3235
$filename
3336
));
3437
}
@@ -38,9 +41,9 @@ public function __construct(string $filename)
3841
/**
3942
* {@inheritDoc}
4043
*/
41-
public function authenticate(string $credential, string $password = null): ?UserInterface
44+
public function authenticate(string $credential, string $password = null) : ?UserInterface
4245
{
43-
if (! $handle = fopen($this->filename, "r")) {
46+
if (! $handle = fopen($this->filename, 'r')) {
4447
return null;
4548
}
4649
$found = false;
@@ -63,12 +66,11 @@ public function authenticate(string $credential, string $password = null): ?User
6366
/**
6467
* Check bcrypt usage for security reason
6568
*
66-
* @param string $hash
67-
* @return void
69+
* @throws Exception\RuntimeException
6870
*/
69-
protected function checkBcryptHash(string $hash): void
71+
protected function checkBcryptHash(string $hash) : void
7072
{
71-
if ('$2y$' !== substr($hash, 0, 4)) {
73+
if (0 !== strpos($hash, '$2y$')) {
7274
throw new Exception\RuntimeException(
7375
'The htpasswd file uses not secure hash algorithm. Please use bcrypt.'
7476
);

0 commit comments

Comments
 (0)