Download the PHP package fuzz/laravel-oauth without Composer
On this page you can find all versions of the php package fuzz/laravel-oauth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-oauth
Laravel OAuth 
An OAuth wrapper to bridge lucadegasperi/oauth2-server-laravel and Laravel's authentication system while providing optional support for fuzz/magic-box repositories
Setup
- Require the composer package
- Set up your project
AuthServiceProviderto extendFuzz\Auth\Providers\AuthServiceProvider - Follow instructions in
lucadegasperi/oauth2-server-laravelto set it up. -
Configure the
grant_typesarray inconfig/oauth2.phpto use the Fuzz grants (or extend/create your own) -
Set up
config/auth.phpSet the default guard to
apiSet the
apiguard to use\Fuzz\Auth\Guards\OAuthGuard::classas its driverSet Laravel to use the
oauthuser provider and set your project's User class - Create
app/Http/Middleware/OAuthMiddleware.phpand extendFuzz\Auth\Middleware\OAuthenticateMiddleware. Add it to the$routeMiddlewarearray in `app/Http/Kernel.php - Your User class should implement the
Fuzz\Auth\Models\AgentInterfaceandIlluminate\Contracts\Auth\Authenticatableand their required methods
Usage
Protecting routes
Routes that require authentication can now be protected with the auth middleware:
Within any authenticated route, you can use all the default Laravel Auth methods such as Auth::user() to resolve the currently authenticated user. lucadegasperi/oauth2-server-laravel provides a way to protect routes based on scope, but you can also use Fuzz\Auth\Policies\RepositoryModelPolicy@requireScopes to throw League\OAuth2\Server\Exception\AccessDeniedException exceptions when a user does not have the required scopes.
Protecting resources
Laravel OAuth comes with a base Fuzz\Auth\Policies\RepositoryModelPolicy but you may create your own (implementing the Fuzz\Auth\Policies\RepositoryModelPolicyInterface might be helpful). Extending Fuzz\Auth\Policies\RepositoryModelPolicy will provide some base methods to ease writing policies for repositories.
Once a policy is set up and mapped to its model class, you may use it to check user permissions according to your policy:
Resolving the current user
All of Laravel's Auth methods will work, so resolving the current user is as simple as $user = Auth::user(). https://laravel.com/docs/5.2/authentication.
Auth will use your default guard unless specified. A typical guard set up for an OAuth specced API would be having one for users accessing via a client and another for client-only requests. Currently there is only Fuzz\Auth\Guards\OAuthGuard which is responsible for resolving the user for a request.
TODOs
- Separate
fuzz/laravel-oauthfromfuzz/magic-box - Support client requests in their own guard and be compatible with the current user
OAuthGuard
All versions of laravel-oauth with dependencies
lucadegasperi/oauth2-server-laravel Version 5.1.*
symfony/security-core Version 3.0.*
fuzz/magic-box Version 1.1.*