Giter VIP home page Giter VIP logo

slim-oauth2-routes's Introduction

Achievements

AWS-CloudPractitioner-2020 AWS-SolArchitect-Associate-2020

slim-oauth2-routes's People

Contributors

chadicus avatar earllapura avatar jeffdrumgod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

slim-oauth2-routes's Issues

__invoke magic function not working

Hi!

I have used your package in my project and it has worked. However, due to a server disk failure, I transferred my project to localhost and reconfigured it to a local database storage. When I accessed /authorize, the invoke seems to not work. I've put var_dumps at the functions, but it seems the var_dump inside the __invoke magic function did not execute, thus the authorization form did not appear.

What seems to be the problem?

Earl

Update coveralls dependency

satooshi/php-coveralls has become php-coveralls/php-coveralls. The dev dependencies should be updated accordingly.

Authorization code not linked to user_id

Expected behavior

When a user authorizes a client, the user_id should be saved with the authorization code if the user_id argument is set.

Actual behavior

The authorization code is created but without any user_id (the column user_id in table oauth_authorization_codes remains NULL)

Steps to reproduce the behavior

Invoke the Authorize route, with or without a user_id argument.

Suggested fix

The Authorize route calls handleAuthorizeRequest() on the OAuth2 server, but doesn't pass the user_id argument (which then defaults to null). Therefore the OAuth2 server won't link the authorization code to the user_id.

I suggest adding the user_id at line 84 of Authorize.php:

$user_id = isset($arguments['user_id']) ? $arguments['user_id'] : null;
$this->server->handleAuthorizeRequest($oauth2Request, $oauth2Response, $authorized === 'yes', $user_id);

Context

In my application I use Slim middleware to validate the user credentials and then set the user_id argument:

$loginMiddelware = function ($request, $response, $next) 
{
  $email = $request->getParam('email');
  $password = $request->getParam('password');

  // Validate the user credentials
  $user_id = getUserIdIfValidCredentials($email, $password);
  if ($user_id === FALSE || !is_numeric($user_id)) {
    return $response->withStatus(303)->withHeader('Location', URL_AUTHORIZE_INVALID_CREDENTIALS);
  }

  // Set the user_id argument so that Routes\Authorize can give it to handleAuthorizeRequest
  $route = $request->getAttribute('route');
  $route->setArgument('user_id', $user_id);

  // Credentials are valid, continue so the authorization code can be sent to the clients callback_uri
  $response = $next($request, $response);
  return $response;
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.