Skip to content

sicecep/base-lumen-oauth2

 
 

Repository files navigation

Implementation of OAuth 2 Server in Lumen PHP Framework using league/oauth2-server

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. Documentation for the framework can be found on the Lumen website.

Lumen PHP Framework version 5.1.*

About

This is simple example of how to use league/oauth2-serve inside Lumen PHP Framework.

Grants Implemented:

  1. Client Credentials
  2. Authorization Code
  3. Refresh Token

Authorization Code grant is automatically executed after logging in a user in this implementation, so you will not have any authorization approval user interface.

You can modify the Authorization Code grant implementation or remove it by modifying the UserController file. You can find OAuth2 trait usage there. But remember, you need to figure out by your self on how to identify authenticated User by removing the implementation.

Installation

Run composer install from the command line

composer install

Tables Schema

Import SQL table schema into your database.

Testing

Import Postman JSON file into your Postman application.

Steps

  1. Change all URL endpoints based on your installation.
  2. Run the "Authorization".
  3. Copy access_token value into the "User Login" Authorization header, then run it.
  4. Copy refresh_token value into the "Refresh Token" body, then run it.
  5. Copy access_token value into the "Get a User" Authorization header, then run it.

Middlewares

1. OAuthMiddleware

This middleware will identify Client based on access_token passed to the request, then it will save the identified OAuth info (client, user, and scopes) into request object.

2. AuthMiddleware

This middleware will identify authenticated User based on identified OAuth info, so you need to put OAuthMiddleware in the first place of you route middleware definition before this middleware.

Issue

Submit your issue in here.

License

Whole additional source codes included is open-sourced software licensed under the MIT license

About

Implementation of OAuth 2 Server in Lumen PHP Framework using league/oauth2-server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 99.3%
  • ApacheConf 0.7%