Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b41de9c
NGP-5519 Resolve direct deprecations
aaronopela Sep 15, 2022
25b8f5a
NGP-5519 Move to symfony 6 and fix return type issues and deprecations
aaronopela Sep 15, 2022
a169803
NGP-5519 Remove deprecated authentication provider and listener
aaronopela Sep 15, 2022
0fa195b
NGP-5519 Fix phpstan errors
aaronopela Sep 15, 2022
ed3a202
NGP-5519 Add return types as suggested in deprecation log
aaronopela Sep 15, 2022
966b1d3
NGP-5519 Add okayed errors to phpstan-baseline
aaronopela Sep 15, 2022
e6b493d
NGP-5519 Remove extra errors from phpstan-baseline
aaronopela Sep 15, 2022
6082068
NGP-5519 Update github workflow for php8.1 and symfony6
aaronopela Sep 16, 2022
519545a
NGP-5519 php-cs-fixer fixes
aaronopela Sep 16, 2022
840d1c5
NGP-5519 Composer normalize fixes
aaronopela Sep 16, 2022
a4e1ed2
NGP-5519 Skip test that doesn't work in github workflow
aaronopela Sep 16, 2022
5597091
NGP-5519 Remove symfony/symfony dependency
aaronopela Sep 20, 2022
7feb9b0
NGP-5519 Remove UserInterface functions from client
aaronopela Sep 20, 2022
ecd7cca
NGP-5519 Replace monolog with monolog bundle
aaronopela Sep 20, 2022
390486b
NGP-5519 Test symfony 5.4
aaronopela Sep 20, 2022
b6be5bb
NGP-5519 Switch to tagged oauth2-php
aaronopela Sep 28, 2022
db9da9d
Removed 5.3 deprecations.
archerryan Nov 17, 2021
9d9a81c
Updating auth-manager fork to be on symfony 5.3.
archerryan Jan 7, 2022
6ac4149
Remove field name attribute from Mongo field configurations.
Feb 23, 2022
a1eaa7d
Fix phpstan/phpunit errors
aaronopela Sep 14, 2022
51cd83c
Update phpstan baseline
aaronopela Sep 15, 2022
703f8f5
Fix failing test from session changes
aaronopela Sep 15, 2022
cdcf697
php-cs-fixer fixes
aaronopela Sep 15, 2022
b5cca4d
composer-normalize
aaronopela Sep 15, 2022
f6231a1
Fixes annotations dependency
iisisrael Sep 20, 2022
f28dcdd
Merge branch 'symfony-6' into ngp-5519
iisisrael Oct 25, 2022
cb9a33e
Reverting PR merge changes to maintain NG specific support.
iisisrael Oct 26, 2022
db8e076
NGP-5782 Fix return type deprecation
aaronopela Nov 7, 2022
d1f6d44
NGP-5782 Require newer php-mock
aaronopela Nov 7, 2022
e5e192a
Merge pull request #6 from archerryan/ngp-5782
aaronopela Nov 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '7.4'
php-version: '8.1'
coverage: 'none'
extensions: 'json, mbstring, tokenizer'
tools: 'composer-normalize, php-cs-fixer:3.10.0'
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '7.4'
php-version: '8.1'
coverage: 'none'
extensions: 'json, mbstring, tokenizer'
env:
Expand All @@ -64,8 +64,8 @@ jobs:
include:
- dependencies: 'beta'
symfony_version:
- 5.3
- 5.4
- 6.0
env:
SYMFONY_VERSION: '${{ matrix.symfony_version }}'
steps:
Expand All @@ -75,7 +75,7 @@ jobs:
- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '7.4'
php-version: '8.1'
coverage: 'none'
tools: 'composer:2'
extensions: 'mongodb'
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('fos_oauth_server');
$rootNode = $treeBuilder->getRootNode();
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/FOSOAuthServerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function load(array $configs, ContainerBuilder $container)
/**
* {@inheritdoc}
*/
public function getAlias()
public function getAlias(): string
{
return 'fos_oauth_server';
}
Expand Down
19 changes: 13 additions & 6 deletions DependencyInjection/Security/Factory/OAuthFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace FOS\OAuthServerBundle\DependencyInjection\Security\Factory;

use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -25,12 +24,12 @@
*
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
*/
class OAuthFactory implements AuthenticatorFactoryInterface, SecurityFactoryInterface
class OAuthFactory implements AuthenticatorFactoryInterface
{
/**
* {@inheritdoc}
*/
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId)
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId): array|string
{
$providerId = 'fos_oauth_server.security.authentication.authenticator.'.$id;
$container
Expand All @@ -46,7 +45,7 @@ public function createAuthenticator(ContainerBuilder $container, string $id, arr
/**
* {@inheritdoc}
*/
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint): array
{
$providerId = 'security.authentication.provider.fos_oauth_server.'.$id;
$container
Expand All @@ -64,15 +63,23 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
/**
* {@inheritdoc}
*/
public function getPosition()
public function getPosition(): string
{
return 'pre_auth';
}

/**
* {@inheritdoc}
*/
public function getKey()
public function getPriority(): int
{
return 0;
}

/**
* {@inheritdoc}
*/
public function getKey(): string
{
return 'fos_oauth';
}
Expand Down
2 changes: 1 addition & 1 deletion FOSOAuthServerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function build(ContainerBuilder $container)

/** @var SecurityExtension $extension */
$extension = $container->getExtension('security');
$extension->addSecurityListenerFactory(new OAuthFactory());
$extension->addAuthenticatorFactory(new OAuthFactory());

$container->addCompilerPass(new GrantExtensionsCompilerPass());
$container->addCompilerPass(new RequestStackCompilerPass());
Expand Down
2 changes: 1 addition & 1 deletion Model/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function setRedirectUri($redirectUri)
/**
* {@inheritdoc}
*/
public function getRedirectUri()
public function getRedirectUri(): string
{
return $this->redirectUri;
}
Expand Down
4 changes: 2 additions & 2 deletions Model/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getRandomId()
/**
* {@inheritdoc}
*/
public function getPublicId()
public function getPublicId(): string
{
return sprintf('%s_%s', $this->getId(), $this->getRandomId());
}
Expand Down Expand Up @@ -115,7 +115,7 @@ public function setRedirectUris(array $redirectUris)
/**
* {@inheritdoc}
*/
public function getRedirectUris()
public function getRedirectUris(): array
{
return $this->redirectUris;
}
Expand Down
12 changes: 6 additions & 6 deletions Model/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getId()
/**
* {@inheritdoc}
*/
public function getClientId()
public function getClientId(): string
{
return $this->getClient()->getPublicId();
}
Expand All @@ -79,7 +79,7 @@ public function getExpiresAt()
/**
* {@inheritdoc}
*/
public function getExpiresIn()
public function getExpiresIn(): int
{
if ($this->expiresAt) {
return $this->expiresAt - time();
Expand All @@ -91,7 +91,7 @@ public function getExpiresIn()
/**
* {@inheritdoc}
*/
public function hasExpired()
public function hasExpired(): bool
{
if ($this->expiresAt) {
return time() > $this->expiresAt;
Expand All @@ -111,7 +111,7 @@ public function setToken($token)
/**
* {@inheritdoc}
*/
public function getToken()
public function getToken(): string
{
return $this->token;
}
Expand All @@ -127,7 +127,7 @@ public function setScope($scope)
/**
* {@inheritdoc}
*/
public function getScope()
public function getScope(): ?string
{
return $this->scope;
}
Expand All @@ -151,7 +151,7 @@ public function getUser()
/**
* {@inheritdoc}
*/
public function getData()
public function getData(): mixed
{
return $this->getUser();
}
Expand Down
14 changes: 0 additions & 14 deletions Resources/config/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

<parameters>
<parameter key="fos_oauth_server.security.authentication.authenticator.class">FOS\OAuthServerBundle\Security\Authentication\Authenticator\OAuthAuthenticator</parameter>
<parameter key="fos_oauth_server.security.authentication.provider.class">FOS\OAuthServerBundle\Security\Authentication\Provider\OAuthProvider</parameter>
<parameter key="fos_oauth_server.security.authentication.listener.class">FOS\OAuthServerBundle\Security\Firewall\OAuthListener</parameter>
<parameter key="fos_oauth_server.security.entry_point.class">FOS\OAuthServerBundle\Security\EntryPoint\OAuthEntryPoint</parameter>
</parameters>

Expand All @@ -18,18 +16,6 @@
<argument /> <!-- user provider -->
</service>

<service id="fos_oauth_server.security.authentication.provider" class="%fos_oauth_server.security.authentication.provider.class%" public="false">
<argument /> <!-- user provider -->
<argument type="service" id="fos_oauth_server.server" />
<argument type="service" id="security.user_checker" />
</service>

<service id="fos_oauth_server.security.authentication.listener" class="%fos_oauth_server.security.authentication.listener.class%" public="false">
<argument type="service" id="security.token_storage"/>
<argument type="service" id="security.authentication.manager" />
<argument type="service" id="fos_oauth_server.server" />
</service>

<service id="fos_oauth_server.security.entry_point" class="%fos_oauth_server.security.entry_point.class%" public="false">
<argument type="service" id="fos_oauth_server.server" />
</service>
Expand Down
18 changes: 13 additions & 5 deletions Security/Authentication/Authenticator/OAuthAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\UserPassportInterface;

/**
* OAuthAuthenticator class.
Expand Down Expand Up @@ -67,7 +65,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function authenticate(Request $request): UserPassportInterface
public function authenticate(Request $request): Passport
{
// remove the authorization header from the request on this check
$tokenString = $this->serverService->getBearerToken($request, true);
Expand Down Expand Up @@ -107,10 +105,21 @@ public function authenticate(Request $request): UserPassportInterface
return new Passport($userBadge, $credentials);
}

/**
* Deprecated, here to maintain Symfony 5 support.
*/
public function createAuthenticatedToken(Passport $passport, string $firewallName): TokenInterface
{
$token = $this->createToken($passport, $firewallName);
$token->setAuthenticated(true, false);

return $token;
}

/**
* {@inheritdoc}
*/
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
public function createToken(Passport $passport, string $firewallName): TokenInterface
{
try {
// expect the badges in the passport from authenticate method above
Expand All @@ -137,7 +146,6 @@ public function createAuthenticatedToken(PassportInterface $passport, string $fi
}

$token = new OAuthToken($credentials->getRoles($user));
$token->setAuthenticated(true);
$token->setToken($credentials->getTokenString());
$token->setUser($user);

Expand Down
Loading