Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sfelix-martins/passport-multiauth
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel committed Jun 9, 2018
2 parents 740f5e3 + 7007427 commit 7fc57c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

Add multi-authentication support to [Laravel Passport](https://laravel.com/docs/5.5/passport)

**OBS:** Based on [renanwilian](https://github.com/renanwilliam) responses to [Passport Multi-Auth issue](https://github.com/laravel/passport/issues/161)

## Important

The instructions below are from the developing version (Branch `master`). Please prefer stable versions! Stable docs [HERE](https://github.com/sfelix-martins/passport-multiauth/tree/v1.0.1)
Expand Down Expand Up @@ -327,3 +325,7 @@ class AuthTest extends TestCase
}
}
```

### Contributors

Based on [renanwilian](https://github.com/renanwilliam) responses to [Passport Multi-Auth issue](https://github.com/laravel/passport/issues/161).
4 changes: 2 additions & 2 deletions src/Http/Middleware/MultiAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use SMartins\PassportMultiauth\Provider as Token;
use SMartins\PassportMultiauth\ProviderRepository;
use SMartins\PassportMultiauth\Guards\GuardChecker;
use SMartins\PassportMultiauth\Facades\ServerRequest;
use League\OAuth2\Server\Exception\OAuthServerException;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;

class MultiAuthenticate extends Authenticate
{
Expand Down Expand Up @@ -60,7 +60,7 @@ public function handle($request, Closure $next, ...$guards)
return $next($request);
}

$psrRequest = (new DiactorosFactory())->createRequest($request);
$psrRequest = ServerRequest::createRequest($request);

try {
$psrRequest = $this->server->validateAuthenticatedRequest($psrRequest);
Expand Down
6 changes: 6 additions & 0 deletions src/Providers/MultiauthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\ServiceProvider;
use Laravel\Passport\Events\AccessTokenCreated;
use SMartins\PassportMultiauth\ProviderRepository;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;

class MultiauthServiceProvider extends ServiceProvider
{
Expand All @@ -22,6 +23,11 @@ public function boot(ProviderRepository $providers)

$this->createAccessTokenProvider($providers);

// Register the facade ServerRequest returning an instance of DiactorosFactory.
$this->app->singleton('ServerRequest', function () {
return new DiactorosFactory;
});

// Register the middleware as signleton to use the same middleware
// instance when the handle and terminate methods are called.
$this->app->singleton(\SMartins\PassportMultiauth\Http\Middleware\AddCustomProvider::class);
Expand Down

0 comments on commit 7fc57c0

Please sign in to comment.