|
@@ -16,10 +16,10 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerI
|
|
|
use Buzz\Listener\BasicAuthListener;
|
|
|
use Buzz\Message;
|
|
|
|
|
|
-use Symfony\Component\HttpFoundation\Session\Session;
|
|
|
-
|
|
|
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
|
|
|
|
|
|
+use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
|
|
+
|
|
|
class OAuthProxyAuthenticator implements SimplePreAuthenticatorInterface, AuthenticationFailureHandlerInterface
|
|
|
{
|
|
|
public function __construct($client_id, $client_secret, $access_token_url, $user_info_url)
|
|
@@ -32,7 +32,10 @@ class OAuthProxyAuthenticator implements SimplePreAuthenticatorInterface, Authen
|
|
|
|
|
|
public function createToken(Request $request, $providerKey)
|
|
|
{
|
|
|
- return new PreAuthenticatedToken($request->headers->get("php-auth-user"), $request->headers->get("php-auth-pw"), $providerKey);
|
|
|
+ if($request->headers->has("php-auth-user") and $request->headers->has("php-auth-pw"))
|
|
|
+ return new PreAuthenticatedToken($request->headers->get("php-auth-user"), $request->headers->get("php-auth-pw"), $providerKey);
|
|
|
+ return new AnonymousToken("anon.", "anon.");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function supportsToken(TokenInterface $token, $providerKey)
|
|
@@ -102,6 +105,8 @@ class OAuthProxyAuthenticator implements SimplePreAuthenticatorInterface, Authen
|
|
|
$token["user_info"] = $auth_info;
|
|
|
|
|
|
file_put_contents("/tmp/.".base64_encode($username. ":" . $password), json_encode($token));
|
|
|
+ }else{
|
|
|
+ $auth_info = $token["user_info"];
|
|
|
}
|
|
|
|
|
|
$user = $userProvider->loadUserByUsername($auth_info["username"]);
|