Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2a1abf

Browse files
committed
[SecurityBundle] Fix incompatibility with 6.0
1 parent 4628689 commit d2a1abf

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function collect(Request $request, Response $response, \Throwable $except
127127

128128
$this->data = [
129129
'enabled' => true,
130-
'authenticated' => $token->isAuthenticated(false),
130+
'authenticated' => method_exists($token, 'isAuthenticated') ? $token->isAuthenticated(false) : true,
131131
'impersonated' => null !== $impersonatorUser,
132132
'impersonator_user' => $impersonatorUser,
133133
'impersonation_exit_path' => null,

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterEntryPointsPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
2626
use Symfony\Component\Security\Http\Authentication\AuthenticatorManager;
2727
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
28-
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
28+
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
2929
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
3030
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
3131

@@ -76,7 +76,7 @@ public function supports(Request $request): ?bool
7676
return false;
7777
}
7878

79-
public function authenticate(Request $request): PassportInterface
79+
public function authenticate(Request $request): Passport
8080
{
8181
throw new BadCredentialsException();
8282
}

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use Symfony\Component\Security\Guard\AuthenticatorInterface as GuardAuthenticatorInterface;
3939
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
4040
use Symfony\Component\Security\Http\Authenticator\HttpBasicAuthenticator;
41+
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
4142
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
4243

4344
class SecurityExtensionTest extends TestCase
@@ -841,7 +842,7 @@ public function supports(Request $request): ?bool
841842
{
842843
}
843844

844-
public function authenticate(Request $request): PassportInterface
845+
public function authenticate(Request $request): Passport
845846
{
846847
}
847848

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AuthenticatorBundle/ApiAuthenticator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\Security\Core\User\InMemoryUser;
2121
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
2222
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
23-
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
23+
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
2424
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
2525

2626
class ApiAuthenticator extends AbstractAuthenticator
@@ -37,7 +37,7 @@ public function supports(Request $request): ?bool
3737
return $request->headers->has('X-USER-EMAIL');
3838
}
3939

40-
public function authenticate(Request $request): PassportInterface
40+
public function authenticate(Request $request): Passport
4141
{
4242
$email = $request->headers->get('X-USER-EMAIL');
4343
if (false === strpos($email, '@')) {

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AuthenticatorBundle/LoginFormAuthenticator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
2222
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
2323
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
24-
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
2524
use Symfony\Component\Security\Http\Util\TargetPathTrait;
2625

2726
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
@@ -36,7 +35,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator)
3635
$this->urlGenerator = $urlGenerator;
3736
}
3837

39-
public function authenticate(Request $request): PassportInterface
38+
public function authenticate(Request $request): Passport
4039
{
4140
$username = $request->request->get('_username', '');
4241

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,60 +177,60 @@ public function getPassword(): ?string
177177
/**
178178
* {@inheritdoc}
179179
*/
180-
public function getSalt()
180+
public function getSalt(): string
181181
{
182-
return null;
182+
return '';
183183
}
184184

185185
/**
186186
* {@inheritdoc}
187187
*/
188-
public function getUsername()
188+
public function getUsername(): string
189189
{
190190
return $this->username;
191191
}
192192

193-
public function getUserIdentifier()
193+
public function getUserIdentifier(): string
194194
{
195195
return $this->username;
196196
}
197197

198198
/**
199199
* {@inheritdoc}
200200
*/
201-
public function isAccountNonExpired()
201+
public function isAccountNonExpired(): bool
202202
{
203203
return $this->accountNonExpired;
204204
}
205205

206206
/**
207207
* {@inheritdoc}
208208
*/
209-
public function isAccountNonLocked()
209+
public function isAccountNonLocked(): bool
210210
{
211211
return $this->accountNonLocked;
212212
}
213213

214214
/**
215215
* {@inheritdoc}
216216
*/
217-
public function isCredentialsNonExpired()
217+
public function isCredentialsNonExpired(): bool
218218
{
219219
return $this->credentialsNonExpired;
220220
}
221221

222222
/**
223223
* {@inheritdoc}
224224
*/
225-
public function isEnabled()
225+
public function isEnabled(): bool
226226
{
227227
return $this->enabled;
228228
}
229229

230230
/**
231231
* {@inheritdoc}
232232
*/
233-
public function eraseCredentials()
233+
public function eraseCredentials(): void
234234
{
235235
}
236236
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/base_config.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ security:
3939
path: /second/logout
4040

4141
access_control:
42-
- { path: ^/en/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
43-
- { path: ^/unprotected_resource$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
44-
- { path: ^/secure-but-not-covered-by-access-control$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
45-
- { path: ^/secured-by-one-ip$, ip: 10.10.10.10, roles: IS_AUTHENTICATED_ANONYMOUSLY }
46-
- { path: ^/secured-by-two-ips$, ips: [1.1.1.1, 2.2.2.2], roles: IS_AUTHENTICATED_ANONYMOUSLY }
42+
- { path: ^/en/$, roles: PUBLIC_ACCESS }
43+
- { path: ^/unprotected_resource$, roles: PUBLIC_ACCESS }
44+
- { path: ^/secure-but-not-covered-by-access-control$, roles: PUBLIC_ACCESS }
45+
- { path: ^/secured-by-one-ip$, ip: 10.10.10.10, roles: PUBLIC_ACCESS }
46+
- { path: ^/secured-by-two-ips$, ips: [1.1.1.1, 2.2.2.2], roles: PUBLIC_ACCESS }
4747
# these real IP addresses are reserved for docs/examples (https://tools.ietf.org/search/rfc5737)
48-
- { path: ^/secured-by-one-real-ip$, ips: 198.51.100.0, roles: IS_AUTHENTICATED_ANONYMOUSLY }
49-
- { path: ^/secured-by-one-real-ip-with-mask$, ips: '203.0.113.0/24', roles: IS_AUTHENTICATED_ANONYMOUSLY }
50-
- { path: ^/secured-by-one-real-ipv6$, ips: 0:0:0:0:0:ffff:c633:6400, roles: IS_AUTHENTICATED_ANONYMOUSLY }
51-
- { path: ^/secured-by-one-env-placeholder$, ips: '%env(APP_IP)%', roles: IS_AUTHENTICATED_ANONYMOUSLY }
52-
- { path: ^/secured-by-one-env-placeholder-multiple-ips$, ips: '%env(APP_IPS)%', roles: IS_AUTHENTICATED_ANONYMOUSLY }
53-
- { path: ^/secured-by-one-env-placeholder-and-one-real-ip$, ips: ['%env(APP_IP)%', 198.51.100.0], roles: IS_AUTHENTICATED_ANONYMOUSLY }
54-
- { path: ^/secured-by-one-env-placeholder-multiple-ips-and-one-real-ip$, ips: ['%env(APP_IPS)%', 198.51.100.0], roles: IS_AUTHENTICATED_ANONYMOUSLY }
48+
- { path: ^/secured-by-one-real-ip$, ips: 198.51.100.0, roles: PUBLIC_ACCESS }
49+
- { path: ^/secured-by-one-real-ip-with-mask$, ips: '203.0.113.0/24', roles: PUBLIC_ACCESS }
50+
- { path: ^/secured-by-one-real-ipv6$, ips: 0:0:0:0:0:ffff:c633:6400, roles: PUBLIC_ACCESS }
51+
- { path: ^/secured-by-one-env-placeholder$, ips: '%env(APP_IP)%', roles: PUBLIC_ACCESS }
52+
- { path: ^/secured-by-one-env-placeholder-multiple-ips$, ips: '%env(APP_IPS)%', roles: PUBLIC_ACCESS }
53+
- { path: ^/secured-by-one-env-placeholder-and-one-real-ip$, ips: ['%env(APP_IP)%', 198.51.100.0], roles: PUBLIC_ACCESS }
54+
- { path: ^/secured-by-one-env-placeholder-multiple-ips-and-one-real-ip$, ips: ['%env(APP_IPS)%', 198.51.100.0], roles: PUBLIC_ACCESS }
5555
- { path: ^/highly_protected_resource$, roles: IS_ADMIN }
5656
- { path: ^/protected-via-expression$, allow_if: "(!is_authenticated() and request.headers.get('user-agent') matches '/Firefox/i') or is_granted('ROLE_USER')" }
5757
- { path: .*, roles: IS_AUTHENTICATED_FULLY }

0 commit comments

Comments
 (0)