bshaffer / oauth2-demo-php

A demo application for running an OAuth2 server
748 stars 279 forks source link

How to integrate with backend and pass custom OAuth claims back to the client #65

Open liverpoolfc-fan opened 7 years ago

liverpoolfc-fan commented 7 years ago

While I am comfortable with PHP in general, I am not familiar with the PHP framework your code uses.

I would like to customize the OpenID connect sample implementation on the server side to authenticate against our own backend system and to provide custom Oauth claims back to the client in the output Token.

Where do I go about doing this?

I can see references to $params['scope'] as possibly referring to custom data to be added but I cannot see where this ever gets set. Perhaps it is totally unrelated.

It would be useful to add high level instructions for the integration points in the readme referring to the modules to modify, and to add some commented out pseudo code where the integration should be done, and in what format the data should be returned by the backend so as to be usable by the library.

Are there flags/settings that determine whether the Token is Signed and/or Encrypted?

Thanks in advance. And apologies if these are basic questions.

josematheus10 commented 4 years ago

Hi, Try something like this:

$this->server->addGrantType(new OAuth2\GrantType\AuthorizationCode($this->storage));
$this->server->handleAuthorizeRequest($this->request, $this->response, $is_authorized, $user_id );
if ($is_authorized) {
         $code = substr($this->response->getHttpHeader('Location'), strpos($this->response->getHttpHeader('Location'), 'code=')+5, 40);
      header("Location: ".$this->response->getHttpHeader('Location'));
}
$this->response->send();