src/Authentication/HttpAdapter.php
/**
     * Attempt to authenticate the current request.
     *
     * @param Request $request
     * @param Response $response
     * @param MvcAuthEvent $mvcAuthEvent
     * @return false|Identity\IdentityInterface False on failure, IdentityInterface
     *     otherwise
     */
Attempt to authenticate the current request.
@param Request $request
@param Response $response
@param MvcAuthEvent $mvcAuthEvent
@return false|Identity\IdentityInterface False on failure, IdentityInterface
otherwise
Attempt to authenticate the current request . @param Request $request @param Response $response @param MvcAuthEvent $mvcAuthEvent @return false|Identity \ IdentityInterface False on failure IdentityInterface otherwise
public function authenticate(Request $request, Response $response, MvcAuthEvent $mvcAuthEvent)
    {
        if (! $request->getHeader('Authorization', false)) {
            return new Identity\GuestIdentity();
        }
        $this->httpAuth->setRequest($request);
        $this->httpAuth->setResponse($response);
        $result = $this->authenticationService->authenticate($this->httpAuth);
        $mvcAuthEvent->setAuthenticationResult($result);
        if (! $result->isValid()) {
            return false;
        }
        $resultIdentity = $result->getIdentity();
        $identity = new Identity\AuthenticatedIdentity($resultIdentity);
        $name = $resultIdentity;
        if (is_array($resultIdentity)) {
            $name = isset($resultIdentity['username'])
                ? $resultIdentity['username']
                : (string) array_shift($resultIdentity);
        }
        $identity->setName($name);
        return $identity;
    }
public function authenticate ( Request $ request , Response $ response , MvcAuthEvent $ mvcAuthEvent ) { if ( ! $ request -> getHeader ( 'Authorization' , false ) ) { return new Identity \ GuestIdentity ( ) ; } $ this -> httpAuth -> setRequest ( $ request ) ; $ this -> httpAuth -> setResponse ( $ response ) ; $ result = $ this -> authenticationService -> authenticate ( $ this -> httpAuth ) ; $ mvcAuthEvent -> setAuthenticationResult ( $ result ) ; if ( ! $ result -> isValid ( ) ) { return false ; } $ resultIdentity = $ result -> getIdentity ( ) ; $ identity = new Identity \ AuthenticatedIdentity ( $ resultIdentity ) ; $ name = $ resultIdentity ; if ( is_array ( $ resultIdentity ) ) { $ name = isset ( $ resultIdentity [ 'username' ] ) ? $ resultIdentity [ 'username' ] : ( string ) array_shift ( $ resultIdentity ) ; } $ identity -> setName ( $ name ) ; return $ identity ; }
Attempt to authenticate the current request.
Attempt to authenticate the current request .
// No credentials were present at all, so we just return a guest identity. // Pass fully discovered identity to AuthenticatedIdentity instance // But determine the name separately