Skip to content

Commit 772c1ad

Browse files
authored
Merge pull request #6 from sashaaro/fix
rename wrong naming class
2 parents bc2554c + 9a74a82 commit 772c1ad

10 files changed

Lines changed: 36 additions & 36 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Allows switching the `UserProvider` at Runtime using environment variables.
66
Dynamic UserProvider that supports multiple backends based on environment variables.
77

88
To override which should provider configuration as array for runtime
9-
```FlexAuth\AuthFlexTypeProviderInterface```
9+
```FlexAuth\FlexAuthTypeProviderInterface```
1010

11-
Using ```FlexAuth\AuthFlexTypeProviderFactory::fromEnv('FLEX_AUTH'')``` and define env variables in format
11+
Using ```FlexAuth\FlexAuthTypeProviderFactory::fromEnv('FLEX_AUTH'')``` and define env variables in format
1212
`type?param1=value1&param2=value2&param3=value3`
1313

1414
Example define environment variable
@@ -33,7 +33,7 @@ FLEX_AUTH_ENTITY_PROPERTY=username
3333

3434
Dynamically flex type provider example.
3535
```php
36-
class MyAuthFlexTypeProvider implements AuthFlexTypeProviderInterface {
36+
class MyFlexAuthTypeProvider implements FlexAuthTypeProviderInterface {
3737
protected $className = \App\Entities\User::class; // can be change in runtime
3838
protected $propery = 'id';
3939

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"autoload-dev": {
1212
"psr-4": {
13-
"GeneratedHydratorTest\\": "tests/FlexAuthTest"
13+
"FlexAuthTest\\": "tests"
1414
}
1515
},
1616
"require": {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace FlexAuth;
44

55
/**
6-
* Class AuthFlexTypeCallbackProvider
6+
* Class FlexAuthTypeCallbackProvider
77
* @author Aleksandr Arofikin <sashaaro@gmail.com>
88
*/
9-
class AuthFlexTypeCallbackProvider implements AuthFlexTypeProviderInterface
9+
class FlexAuthTypeCallbackProvider implements FlexAuthTypeProviderInterface
1010
{
1111
/** @var callable */
1212
private $callback;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
namespace FlexAuth;
44

55
/**
6-
* Class AuthFlexTypeProviderFactory
6+
* Class FlexAuthTypeProviderFactory
77
* @author Aleksandr Arofikin <sashaaro@gmail.com>
88
*/
9-
class AuthFlexTypeProviderFactory
9+
class FlexAuthTypeProviderFactory
1010
{
1111
public static function fromEnv(string $envVarName)
1212
{
13-
return new AuthFlexTypeCallbackProvider(function () use($envVarName) {
13+
return new FlexAuthTypeCallbackProvider(function () use($envVarName) {
1414
return self::resolveParamsFromEnv($envVarName);
1515
});
1616
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace FlexAuth;
44

55
/**
6-
* Interface AuthFlexTypeProviderInterface
6+
* Interface FlexAuthTypeProviderInterface
77
* @author Aleksandr Arofikin <sashaaro@gmail.com>
88
*/
9-
interface AuthFlexTypeProviderInterface
9+
interface FlexAuthTypeProviderInterface
1010
{
1111
/**
1212
* Provider configuration for runtime which to pass to UserProviderFactoryInterface::create as params

src/Security/FlexAuthPasswordEncoder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace FlexAuth\Security;
44

5-
use FlexAuth\AuthFlexTypeProviderInterface;
5+
use FlexAuth\FlexAuthTypeProviderInterface;
66
use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder;
77
use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
88
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
@@ -15,7 +15,7 @@
1515
*/
1616
class FlexAuthPasswordEncoder implements PasswordEncoderInterface
1717
{
18-
/** @var AuthFlexTypeProviderInterface */
18+
/** @var FlexAuthTypeProviderInterface */
1919
protected $flexAuthTypeProvider;
2020

2121
private $encoders = [
@@ -26,7 +26,7 @@ class FlexAuthPasswordEncoder implements PasswordEncoderInterface
2626
'plain' => PlaintextPasswordEncoder::class
2727
];
2828

29-
public function __construct(AuthFlexTypeProviderInterface $flexAuthTypeProvider)
29+
public function __construct(FlexAuthTypeProviderInterface $flexAuthTypeProvider)
3030
{
3131
$this->flexAuthTypeProvider = $flexAuthTypeProvider;
3232
}

src/Type/JWT/FlexTypeJWTEncoder.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
namespace FlexAuth\Type\JWT;
44

55
use Firebase\JWT\JWT;
6-
use FlexAuth\AuthFlexTypeProviderInterface;
6+
use FlexAuth\FlexAuthTypeProviderInterface;
77

88
/**
99
* Class FlexTypeJWTEncoder
1010
* @author Aleksandr Arofikin <sashaaro@gmail.com>
1111
*/
1212
class FlexTypeJWTEncoder implements EnableJWTEncoderInterface
1313
{
14-
/** @var AuthFlexTypeProviderInterface */
15-
private $authFlexTypeProvider;
14+
/** @var FlexAuthTypeProviderInterface */
15+
private $flexAuthTypeProvider;
1616

17-
public function __construct(AuthFlexTypeProviderInterface $authFlexTypeProvider)
17+
public function __construct(FlexAuthTypeProviderInterface $flexAuthTypeProvider)
1818
{
19-
$this->authFlexTypeProvider = $authFlexTypeProvider;
19+
$this->flexAuthTypeProvider = $flexAuthTypeProvider;
2020
}
2121

2222
public function encode(array $data)
@@ -31,21 +31,21 @@ public function decode($token)
3131

3232
public function isEnabled(): bool
3333
{
34-
$params = $this->authFlexTypeProvider->provide();
34+
$params = $this->flexAuthTypeProvider->provide();
3535

3636
return $params['type'] === JWTUserProviderFactory::TYPE;
3737
}
3838

3939
private function getAlgorithm()
4040
{
41-
$params = $this->authFlexTypeProvider->provide();
41+
$params = $this->flexAuthTypeProvider->provide();
4242

4343
return array_key_exists('algo', $params) ? $params['algo'] : 'RS256';
4444
}
4545

4646
private function getPrivateKey()
4747
{
48-
$params = $this->authFlexTypeProvider->provide();
48+
$params = $this->flexAuthTypeProvider->provide();
4949
$privateKey = $params['private_key'];
5050

5151
$isFilePath = substr($privateKey, 0, 1) === '@';
@@ -66,7 +66,7 @@ private function getPrivateKey()
6666

6767
private function getPublicKey()
6868
{
69-
$params = $this->authFlexTypeProvider->provide();
69+
$params = $this->flexAuthTypeProvider->provide();
7070

7171
$publicKey = $params['public_key'];
7272
$isFilePath = substr($publicKey, 0, 1) === '@';

src/Type/JWT/JWTTokenAuthenticator.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace FlexAuth\Type\JWT;
44

5-
use FlexAuth\AuthFlexTypeProviderInterface;
5+
use FlexAuth\FlexAuthTypeProviderInterface;
66
use Symfony\Component\HttpFoundation\Request;
77
use Symfony\Component\HttpFoundation\Response;
88
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -25,18 +25,18 @@ class JWTTokenAuthenticator extends AbstractGuardAuthenticator
2525
private $JWTUserFactory;
2626
/** @var JWTEncoderInterface */
2727
private $JWTEncoder;
28-
/** @var AuthFlexTypeProviderInterface */
29-
private $authFlexTypeProvider;
28+
/** @var FlexAuthTypeProviderInterface */
29+
private $flexAuthTypeProvider;
3030

3131
public function __construct(
3232
JWTUserFactoryInterface $JWTUserFactory,
3333
JWTEncoderInterface $JWTEncoder,
34-
AuthFlexTypeProviderInterface $authFlexTypeProvider
34+
FlexAuthTypeProviderInterface $flexAuthTypeProvider
3535
)
3636
{
3737
$this->JWTUserFactory = $JWTUserFactory;
3838
$this->JWTEncoder = $JWTEncoder;
39-
$this->authFlexTypeProvider = $authFlexTypeProvider;
39+
$this->flexAuthTypeProvider = $flexAuthTypeProvider;
4040
}
4141

4242
public function supports(Request $request)
@@ -65,7 +65,7 @@ public function getCredentials(Request $request)
6565

6666
public function createTokenFromUser(UserInterface $user): string
6767
{
68-
$params = $this->authFlexTypeProvider->provide();
68+
$params = $this->flexAuthTypeProvider->provide();
6969
$userField = $params['user_field'] ?? 'username';
7070
$roleField = $params['role_field'] ?? 'permissions';
7171

@@ -83,11 +83,11 @@ public function getUser($credentialsToken, UserProviderInterface $userProvider)
8383
{
8484
if (!is_string($credentialsToken)) {
8585
throw new \InvalidArgumentException(
86-
sprintf('The first argument of the "%s()" method must be string.', __METHOD__, __CLASS__)
86+
sprintf('The first argument of the "%s::%s()" method must be string.', __CLASS__, __METHOD__)
8787
);
8888
}
8989

90-
$params = $this->authFlexTypeProvider->provide();
90+
$params = $this->flexAuthTypeProvider->provide();
9191
$userField = $params['user_field'] ?? 'username';
9292
$roleField = $params['role_field'] ?? 'permissions';
9393

src/UserProviderFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class UserProviderFactory
1616
/** @var UserProviderFactoryInterface[] */
1717
protected $factories = [];
1818

19-
protected $authFlexTypeProvider;
19+
protected $flexAuthTypeProvider;
2020

21-
public function __construct(AuthFlexTypeProviderInterface $authFlexTypeProvider)
21+
public function __construct(FlexAuthTypeProviderInterface $flexAuthTypeProvider)
2222
{
23-
$this->authFlexTypeProvider = $authFlexTypeProvider;
23+
$this->flexAuthTypeProvider = $flexAuthTypeProvider;
2424
}
2525

2626
public function addType($typeKey, UserProviderFactoryInterface $userFactory)
@@ -64,7 +64,7 @@ public function create(): UserProviderInterface
6464
*/
6565
private function resolveTypeAndParams()
6666
{
67-
$flexAuthData = $this->authFlexTypeProvider->provide();
67+
$flexAuthData = $this->flexAuthTypeProvider->provide();
6868

6969
$allowTypes = array_keys($this->factories);
7070

tests/AuthenticationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AuthenticationTest extends TestCase
2222
{
2323
public function testAuthenticate() {
2424
$envName = 'FLEX_AUTH';
25-
$typeProvider = \FlexAuth\AuthFlexTypeProviderFactory::fromEnv($envName);
25+
$typeProvider = \FlexAuth\FlexAuthTypeProviderFactory::fromEnv($envName);
2626

2727
$userFactory = new \FlexAuth\UserProviderFactory($typeProvider);
2828
$userFactory->addType(MemoryUserProviderFactory::TYPE, new MemoryUserProviderFactory());

0 commit comments

Comments
 (0)