zf-fr / zfr-oauth2-server

PHP library for creating an OAuth 2 server (currently proof of concept)
BSD 3-Clause "New" or "Revised" License
36 stars 13 forks source link

Q: Should we document or provide Zf AuthenticationService integration #71

Open basz opened 8 years ago

basz commented 8 years ago

This is what I currently use.

public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out = null)
    {
        if ($accessToken = $request->getAttribute('oauth_token')) {
            /** @var \ZfrOAuth2\Server\Model\AccessToken $accessToken */
            $adapter = new Callback(function ($identity, $credential) {
                return $identity;
            });

            $adapter->setIdentity($accessToken->getOwner());

            $this->authenticationService->authenticate($adapter);
        }

        $response = $out($request, $response);

        return $response;
    }