mikemclin / passport-custom-request-grant Goto Github PK
View Code? Open in Web Editor NEWCustom Request Grant for Laravel Passport
Custom Request Grant for Laravel Passport
After install and implement show this error for whatever i done (Postman, migrate...): Illuminate\Contracts\Container\BindingResolutionException: Target [League\OAuth2\Server\Repositories\ClientRepositoryInterface] is not instantiable while building [League\OAuth2\Server\AuthorizationServer]. in /var/www/wa/clean-api/vendor/illuminate/container/Container.php:763.
And what is exactly this "bySsoToken"?
My Custon provider
`use Laravel\Passport\Bridge\RefreshTokenRepository;
use Laravel\Passport\Bridge\UserRepository;
use Laravel\Passport\Passport;
use Laravel\Passport\PassportServiceProvider;
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Grant\PasswordGrant;
/**
Bootstrap any application services.
@return void
/
public function boot()
{
//$ClientInterface = app()->make('WA\vendor\league\oauth2-server\Repositories\ClientRepositoryInterface');
}
/*
Register the service provider.
@return void
*/
public function register()
{
app(AuthorizationServer::class)->enableGrantType($this->makeSSOGrant(), Passport::tokensExpireIn());
}
/**
Create and configure a Password grant instance.
@return PasswordGrant
*/
protected function makeSSOGrant()
{
$grant = new SSOGrant(
$this->app->make(UserRepository::class),
$this->app->make(RefreshTokenRepository::class)
);
$grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn());
return $grant;
}
}`
Model
`use Illuminate\Http\Request;
use Laravel\Passport\Bridge\User;
use League\OAuth2\Server\Entities\UserEntityInterface;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\AbstractGrant;
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
use League\OAuth2\Server\RequestEvent;
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface;
use Psr\Http\Message\ServerRequestInterface;
/**
`public function byPassportSSOGrantRequest(Request $request)
{
try {
if ($request->get('sso')) {
return $this->SSOGrantVerify($request->get('sso'));
}
} catch (\Exception $e) {
throw OAuthServerException::accessDenied($e->getMessage());
}
return null;
}
public function SSOGrantVerify(Request $request)
{
$laravelUser = Cache::get('saml2user_'.$request);
if (!isset($laravelUser)) {
return false;
} else {
return $laravelUser['attributes'];
}
}
}
`
Hi,
I have problem with your package because I have laravel 5.4 and passport 3.0 and your package is not compatible:
Problem 1
- Installation request for mikemclin/passport-custom-request-grant ^1.0 -> satisfiable by mikemclin/passport-custom-request-grant[1.0.0].
- mikemclin/passport-custom-request-grant 1.0.0 requires laravel/passport ^2.0 -> satisfiable by laravel/passport[2.0.x-dev, v2.0.0, v2.0.1, v2.0.10, v2.0.11, v2.0.2, v2.0.3, v2.0.4, v2.0.5, v2.0.6, v2.0.7, v2.0.8, v2.0.9] but these conflict with your requirements or minimum-stability.
Coud you fix it?
Thanks
I downloaded the package but I'm getting a "Class hash does not exist" error when I send the request. Here's the stack trace:
ReflectionException in Container.php line 734: Class hash does not exist in Container.php line 734 at ReflectionClass->__construct('hash') in Container.php line 734 at Container->build('hash', array()) in Container.php line 629 at Container->make('hash', array()) in Application.php line 710 at Application->make('Illuminate\Contracts\Hashing\Hasher') in Container.php line 849 at Container->resolveClass(object(ReflectionParameter)) in Container.php line 804 at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 775 at Container->build('Laravel\Passport\Bridge\UserRepository', array()) in Container.php line 629 at Container->make('Laravel\Passport\Bridge\UserRepository', array()) in Application.php line 710 at Application->make('Laravel\Passport\Bridge\UserRepository') in PassportServiceProvider.php line 138 at PassportServiceProvider->makePasswordGrant() in PassportServiceProvider.php line 80 at PassportServiceProvider->Laravel\Passport\{closure}(object(AuthorizationServer)) in helpers.php line 814 at tap(object(AuthorizationServer), object(Closure)) in PassportServiceProvider.php line 86 at PassportServiceProvider->Laravel\Passport\{closure}(object(Application), array()) in Container.php line 731 at Container->build(object(Closure), array()) in Container.php line 629 at Container->make('League\OAuth2\Server\AuthorizationServer', array()) in Application.php line 710 at Application->make('League\OAuth2\Server\AuthorizationServer', array()) in helpers.php line 106 at app('League\OAuth2\Server\AuthorizationServer') in CustomRequestGrantProvider.php line 35 at CustomRequestGrantProvider->register() in Application.php line 566 at Application->register(object(CustomRequestGrantProvider)) in ProviderRepository.php line 74 at ProviderRepository->load(array('Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Notifications\NotificationServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Laravel\Passport\PassportServiceProvider', 'MikeMcLin\Passport\CustomRequestGrantProvider', 'LogSalud\Providers\AppServiceProvider', 'LogSalud\Providers\AuthServiceProvider', 'LogSalud\Providers\EventServiceProvider', 'LogSalud\Providers\RouteServiceProvider')) in Application.php line 541 at Application->registerConfiguredProviders() in RegisterProviders.php line 17 at RegisterProviders->bootstrap(object(Application)) in Application.php line 203 at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 253 at Kernel->bootstrap() in Kernel.php line 144 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116 at Kernel->handle(object(Request)) in index.php line 54
Let me know if you need any more info. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.