From d245d4ee8460a1a4cc9e72e96bb0350c2f0d1681 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Mon, 10 May 2021 17:35:01 +0200
Subject: [PATCH] refactor: Autofix code style.
---
LICENSE | 2 +-
spec/EcPhp/CasBundle/Cas.php | 190 ++++++++++--------
.../CasBundle/Configuration/SymfonySpec.php | 5 +
.../CasBundle/Controller/HomepageSpec.php | 5 +
spec/EcPhp/CasBundle/Controller/LoginSpec.php | 5 +
.../EcPhp/CasBundle/Controller/LogoutSpec.php | 5 +
.../Controller/ProxyCallbackSpec.php | 5 +
.../DependencyInjection/CasExtensionSpec.php | 5 +
.../DependencyInjection/ConfigurationSpec.php | 5 +
.../Security/CasGuardAuthenticatorSpec.php | 53 ++---
.../Core/User/CasUserProviderSpec.php | 27 ++-
.../Security/Core/User/CasUserSpec.php | 5 +
src/CasBundle.php | 5 +
src/Configuration/Symfony.php | 8 +-
src/Controller/Homepage.php | 16 +-
src/Controller/Login.php | 5 +
src/Controller/Logout.php | 5 +
src/Controller/ProxyCallback.php | 5 +
src/DependencyInjection/CasExtension.php | 5 +
src/DependencyInjection/Configuration.php | 8 +-
src/Resources/config/routes/routes.php | 5 +
src/Resources/config/services.php | 5 +
src/Security/CasGuardAuthenticator.php | 29 +--
src/Security/Core/User/CasUser.php | 32 +--
src/Security/Core/User/CasUserInterface.php | 5 +
src/Security/Core/User/CasUserProvider.php | 17 +-
.../Core/User/CasUserProviderInterface.php | 5 +
27 files changed, 271 insertions(+), 196 deletions(-)
diff --git a/LICENSE b/LICENSE
index bb9ba02..6692205 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
BSD 3-Clause License
-Copyright (c) 2020, ECPHP
+Copyright (c) 2019-2021, ECPHP.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/spec/EcPhp/CasBundle/Cas.php b/spec/EcPhp/CasBundle/Cas.php
index 658732d..11e4149 100644
--- a/spec/EcPhp/CasBundle/Cas.php
+++ b/spec/EcPhp/CasBundle/Cas.php
@@ -1,5 +1,10 @@
-
- username
-
-
-EOF;
+
+
+ username
+
+
+ EOF;
break;
+
case 'http://local/cas/serviceValidate?service=service&ticket=ticket-failure':
$body = <<< 'EOF'
-
-
-
-
-EOF;
+
+
+
+
+ EOF;
break;
+
case 'http://local/cas/proxyValidate?service=service&ticket=ticket':
case 'http://local/cas/proxyValidate?ticket=PT-ticket&service=http%3A%2F%2Ffrom':
case 'http://local/cas/proxyValidate?ticket=ST-ticket&service=http%3A%2F%2Ffrom':
@@ -50,118 +57,127 @@ public static function getHttpClientMock()
case 'http://local/cas/proxyValidate?service=http%3A%2F%2Flocal%2Fcas%2FserviceValidate%3Fservice%3Dservice&ticket=ticket':
case 'http://local/cas/proxyValidate?service=http%3A%2F%2Flocal%2Fcas%2FserviceValidate%3Fservice%3Dservice%26renew%3Dtrue&ticket=ticket&renew=true':
$body = <<< 'EOF'
-
-
- username
-
- http://app/proxyCallback.php
-
-
-
-EOF;
+
+
+ username
+
+ http://app/proxyCallback.php
+
+
+
+ EOF;
break;
+
case 'http://local/cas/serviceValidate?ticket=ST-ticket-pgt&service=http%3A%2F%2Ffrom':
$body = <<< 'EOF'
-
-
- username
- pgtIou
-
-
-EOF;
+
+
+ username
+ pgtIou
+
+
+ EOF;
break;
+
case 'http://local/cas/serviceValidate?ticket=ST-ticket-pgt-pgtiou-not-found&service=http%3A%2F%2Ffrom':
$body = <<< 'EOF'
-
-
- username
- unknownPgtIou
-
-
-EOF;
+
+
+ username
+ unknownPgtIou
+
+
+ EOF;
break;
+
case 'http://local/cas/proxyValidate?ticket=ST-ticket-pgt-pgtiou-pgtid-null&service=http%3A%2F%2Ffrom':
$body = <<< 'EOF'
-
-
- username
- pgtIouWithPgtIdNull
-
-
-EOF;
+
+
+ username
+ pgtIouWithPgtIdNull
+
+
+ EOF;
break;
+
case 'http://local/cas/proxyValidate?service=service&ticket=ST-ticket-pgt':
case 'http://local/cas/proxyValidate?ticket=ST-ticket-pgt&service=http%3A%2F%2Ffrom':
case 'http://local/cas/proxyValidate?service=http%3A%2F%2Flocal%2Fcas%2FproxyValidate%3Fservice%3Dhttp%253A%252F%252Ffrom&ticket=PT-ticket-pgt':
$body = <<< 'EOF'
-
-
- username
- pgtIou
-
- http://app/proxyCallback.php
-
-
-
-EOF;
+
+
+ username
+ pgtIou
+
+ http://app/proxyCallback.php
+
+
+
+ EOF;
break;
+
case 'http://local/cas/serviceValidate?service=http%3A%2F%2Flocal%2Fcas%2FserviceValidate%3Fservice%3Dservice%26format%3DJSON&ticket=ticket&format=JSON':
$body = <<< 'EOF'
-{
- "serviceResponse": {
- "authenticationSuccess": {
- "user": "username"
- }
- }
-}
-EOF;
+ {
+ "serviceResponse": {
+ "authenticationSuccess": {
+ "user": "username"
+ }
+ }
+ }
+ EOF;
break;
+
case 'http://local/cas/proxyValidate?service=http%3A%2F%2Ffrom&ticket=PT-ticket':
$body = <<< 'EOF'
-
-
- username
- pgtIou
-
- http://app/proxyCallback.php
-
-
-
-EOF;
+
+
+ username
+ pgtIou
+
+ http://app/proxyCallback.php
+
+
+
+ EOF;
break;
+
case 'http://local/cas/proxy?targetService=targetService&pgt=pgt':
$body = <<< 'EOF'
-
-
-
- PT-214-A3OoEPNr4Q9kNNuYzmfN8azU31aDUsuW8nk380k7wDExT5PFJpxR1TrNI3q3VGzyDdi0DpZ1LKb8IhPKZKQvavW-8hnfexYjmLCx7qWNsLib1W-DCzzoLVTosAUFzP3XDn5dNzoNtxIXV9KSztF9fYhwHvU0
-
-
-EOF;
+
+
+
+ PT-214-A3OoEPNr4Q9kNNuYzmfN8azU31aDUsuW8nk380k7wDExT5PFJpxR1TrNI3q3VGzyDdi0DpZ1LKb8IhPKZKQvavW-8hnfexYjmLCx7qWNsLib1W-DCzzoLVTosAUFzP3XDn5dNzoNtxIXV9KSztF9fYhwHvU0
+
+
+ EOF;
break;
+
case 'http://local/cas/proxy?targetService=targetService&pgt=pgt-error-in-getCredentials':
$body = <<< 'EOF'
-
-
-
- TODO: Find something to put here.
-
-
-EOF;
+
+
+
+ TODO: Find something to put here.
+
+
+ EOF;
break;
+
case 'http://local/cas/serviceValidate?service=http%3A%2F%2Ffrom&ticket=BAD-http-query':
case 'http://local/cas/proxyValidate?service=http%3A%2F%2Ffrom&ticket=BAD-http-query':
case 'http://local/cas/proxyValidate?service=http%3A%2F%2Flocal%2Fcas%2FproxyValidate%3Fservice%3Dservice%26error%3DTestClientException&ticket=ticket&error=TestClientException':
diff --git a/spec/EcPhp/CasBundle/Configuration/SymfonySpec.php b/spec/EcPhp/CasBundle/Configuration/SymfonySpec.php
index b47d8dc..04297dc 100644
--- a/spec/EcPhp/CasBundle/Configuration/SymfonySpec.php
+++ b/spec/EcPhp/CasBundle/Configuration/SymfonySpec.php
@@ -1,5 +1,10 @@
-
- username
-
-
-EOF;
+
+
+ username
+
+
+ EOF;
$response = new Response(200, ['content-type' => 'application/xml'], $body);
@@ -93,11 +98,11 @@ public function it_can_check_the_credentials(UserInterface $user)
->shouldReturn(true);
$body = <<< 'EOF'
-
-
-
-
-EOF;
+
+
+
+
+ EOF;
$response = new Response(200, ['content-type' => 'application/xml'], $body);
@@ -106,8 +111,8 @@ public function it_can_check_the_credentials(UserInterface $user)
->during('checkCredentials', [$response, $user]);
$body = <<< 'EOF'
-Completely invalid XML.
-EOF;
+ Completely invalid XML.
+ EOF;
$response = new Response(200, ['content-type' => 'application/xml'], $body);
@@ -132,12 +137,12 @@ public function it_can_detect_when_the_request_is_an_ajax_request_and_respond_ac
public function it_can_get_the_user_from_the_response()
{
$body = <<< 'EOF'
-
-
- username
-
-
-EOF;
+
+
+ username
+
+
+ EOF;
$response = new Response(200, ['content-type' => 'application/xml'], $body);
$casUserProvider = new CasUserProvider(new Introspector());
@@ -147,11 +152,11 @@ public function it_can_get_the_user_from_the_response()
->shouldBeAnInstanceOf(CasUserInterface::class);
$body = <<< 'EOF'
-
-
-
-
-EOF;
+
+
+
+
+ EOF;
$response = new Response(200, ['content-type' => 'application/xml'], $body);
$this
diff --git a/spec/EcPhp/CasBundle/Security/Core/User/CasUserProviderSpec.php b/spec/EcPhp/CasBundle/Security/Core/User/CasUserProviderSpec.php
index 9da0d90..ec8e8a6 100644
--- a/spec/EcPhp/CasBundle/Security/Core/User/CasUserProviderSpec.php
+++ b/spec/EcPhp/CasBundle/Security/Core/User/CasUserProviderSpec.php
@@ -1,5 +1,10 @@
-
- username
-
-
-EOF;
+
+
+ username
+
+
+ EOF;
$response = new Response(200, ['content-type' => 'application/xml'], $body);
@@ -51,11 +56,11 @@ public function it_can_load_a_user_with_a_response()
->shouldBeAnInstanceOf(CasUserInterface::class);
$body = <<< 'EOF'
-
-
-
-
-EOF;
+
+
+
+
+ EOF;
$response = new Response(200, ['content-type' => 'application/xml'], $body);
diff --git a/spec/EcPhp/CasBundle/Security/Core/User/CasUserSpec.php b/spec/EcPhp/CasBundle/Security/Core/User/CasUserSpec.php
index 31b34fa..b542082 100644
--- a/spec/EcPhp/CasBundle/Security/Core/User/CasUserSpec.php
+++ b/spec/EcPhp/CasBundle/Security/Core/User/CasUserSpec.php
@@ -1,5 +1,10 @@
cas = new PsrCasConfiguration($this->routeToUrl($properties));
}
- /**
- * {@inheritdoc}
- */
public function all(): array
{
return $this->cas->all();
diff --git a/src/Controller/Homepage.php b/src/Controller/Homepage.php
index 9ed4ac1..6f66112 100644
--- a/src/Controller/Homepage.php
+++ b/src/Controller/Homepage.php
@@ -1,5 +1,10 @@
You have been redirected here by default. You are most probably using the default CAS configuration.
+ You have been redirected here by default.
+ You are most probably using the default CAS configuration.
-The default CAS bundle configuration should be installed in config/packages/dev/cas_bundle.yaml
+ The default CAS bundle configuration should be installed in
+ config/packages/dev/cas_bundle.yaml
-Please update your configuration and replace cas_bundle_homepage
with an existing route of your app.
-EOF;
+ Please update your configuration and replace cas_bundle_homepage
+ with an existing route of your app.
+ EOF;
return new Response($body);
}
diff --git a/src/Controller/Login.php b/src/Controller/Login.php
index 5a83edc..19a2769 100644
--- a/src/Controller/Login.php
+++ b/src/Controller/Login.php
@@ -1,5 +1,10 @@
httpMessageFactory = $httpMessageFactory;
}
- /**
- * {@inheritdoc}
- */
public function checkCredentials($credentials, UserInterface $user): bool
{
try {
@@ -56,9 +58,6 @@ public function checkCredentials($credentials, UserInterface $user): bool
return true;
}
- /**
- * {@inheritdoc}
- */
public function getCredentials(Request $request): ?ResponseInterface
{
$response = $this
@@ -72,9 +71,6 @@ public function getCredentials(Request $request): ?ResponseInterface
return $response;
}
- /**
- * {@inheritdoc}
- */
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
{
if (false === ($userProvider instanceof CasUserProviderInterface)) {
@@ -90,9 +86,6 @@ public function getUser($credentials, UserProviderInterface $userProvider): ?Use
return $user;
}
- /**
- * {@inheritdoc}
- */
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
{
$uri = $this->toPsr($request)->getUri();
@@ -113,9 +106,6 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
return null;
}
- /**
- * {@inheritdoc}
- */
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $providerKey): Response
{
return new RedirectResponse(
@@ -127,9 +117,6 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
);
}
- /**
- * {@inheritdoc}
- */
public function start(Request $request, ?AuthenticationException $authException = null): Response
{
if (true === $request->isXmlHttpRequest()) {
@@ -153,9 +140,6 @@ public function start(Request $request, ?AuthenticationException $authException
);
}
- /**
- * {@inheritdoc}
- */
public function supports(Request $request): bool
{
return $this
@@ -164,9 +148,6 @@ public function supports(Request $request): bool
->supportAuthentication();
}
- /**
- * {@inheritdoc}
- */
public function supportsRememberMe(): bool
{
return false;
diff --git a/src/Security/Core/User/CasUser.php b/src/Security/Core/User/CasUser.php
index addbfde..ccafd77 100644
--- a/src/Security/Core/User/CasUser.php
+++ b/src/Security/Core/User/CasUser.php
@@ -1,5 +1,10 @@
storage = $data;
}
- /**
- * {@inheritdoc}
- */
public function eraseCredentials(): void
{
}
- /**
- * {@inheritdoc}
- */
public function get(string $key, $default = null)
{
return $this->getStorage()[$key] ?? $default;
}
- /**
- * {@inheritdoc}
- */
public function getAttribute(string $key, $default = null)
{
return $this->getStorage()['attributes'][$key] ?? $default;
}
- /**
- * {@inheritdoc}
- */
public function getAttributes(): array
{
return $this->get('attributes', []);
}
- /**
- * {@inheritdoc}
- */
public function getPassword(): ?string
{
return null;
}
- /**
- * {@inheritdoc}
- */
public function getPgt(): ?string
{
return $this->get('proxyGrantingTicket');
}
- /**
- * {@inheritdoc}
- */
public function getRoles(): array
{
return ['ROLE_CAS_AUTHENTICATED'];
}
- /**
- * {@inheritdoc}
- */
public function getSalt(): ?string
{
return null;
}
- /**
- * {@inheritdoc}
- */
public function getUsername(): string
{
return $this->get('user');
diff --git a/src/Security/Core/User/CasUserInterface.php b/src/Security/Core/User/CasUserInterface.php
index 36aa4bf..6d6736e 100644
--- a/src/Security/Core/User/CasUserInterface.php
+++ b/src/Security/Core/User/CasUserInterface.php
@@ -1,5 +1,10 @@
introspector = $introspector;
}
- /**
- * {@inheritdoc}
- */
public function loadUserByResponse(ResponseInterface $response): CasUserInterface
{
try {
@@ -41,17 +43,11 @@ public function loadUserByResponse(ResponseInterface $response): CasUserInterfac
throw new AuthenticationException('Unable to load user from response.');
}
- /**
- * {@inheritdoc}
- */
public function loadUserByUsername(string $username): UserInterface
{
throw new UnsupportedUserException(sprintf('Username "%s" does not exist.', $username));
}
- /**
- * {@inheritdoc}
- */
public function refreshUser(UserInterface $user): UserInterface
{
if (!$user instanceof CasUserInterface) {
@@ -61,9 +57,6 @@ public function refreshUser(UserInterface $user): UserInterface
return $user;
}
- /**
- * {@inheritdoc}
- */
public function supportsClass(string $class): bool
{
return CasUser::class === $class;
diff --git a/src/Security/Core/User/CasUserProviderInterface.php b/src/Security/Core/User/CasUserProviderInterface.php
index 52da636..cbd235e 100644
--- a/src/Security/Core/User/CasUserProviderInterface.php
+++ b/src/Security/Core/User/CasUserProviderInterface.php
@@ -1,5 +1,10 @@