Download the PHP package omarelgabry/lumen-api-oauth without Composer

On this page you can find all versions of the php package omarelgabry/lumen-api-oauth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lumen-api-oauth

Lumen API OAuth

Lumen API OAuth

Build Status Scrutinizer Code Quality Code Climate Dependency Status

Latest Stable Version License

A RESTful API based on Lumen micro-framework with OAuth2. Lumen API OAuth is a simple application, indented for small projects, helps to understand creating RESTful APIs with Lumen and OAuth2, know how to authenticate and authorize, and more.

The RESTful API for Posts and Comments, where Users can view, create, update, and delete. It provides authorization mechanism to authorize against access tokens using OAuth2, ownership, and non-admin Vs admin users.

:mega: A full tutorial on building a RESTful API with Lumen and OAuth2 can be found on Medium.

Index

Installation

Steps:

  1. Run Composer

  2. Laravel Homestead

    If you are using Laravel Homestead, then follow the Installation Guide.

  3. WAMP, LAMP, MAMP, XAMP Server

    If you are using any of WAMP, LAMP, MAMP, XAMP Servers, then don't forget to create a database, probably a MySQL database.

  4. Configure the file

    Rename file to , set your application key to a random string with 32 characters long, edit database name, database username, and database password if needed.

  5. Finally, Run Migrations and Seed the database with fake data.

Terminology

There are some terminologies that will be used on the meaning of the terms used by OAuth 2.0. If you need a refresher, then check this out.

Authorization

Authorization comes in two layers. The first layer authorize against the access token, and the second one is for checking against ownership, and non-admin Vs admin users.

By default, user can delete or update a post or a comment only if he is the owner. Admins are authorized to view, create, update or delete anything.

Access Tokens

The application implements Resource owner credentials grant, which essentially requires the client to submit 5 fields: , , , , and .

The authorization server will then issue access tokens to the client after successfully authenticating the client credentials and presenting authorization grant(user credentials).

In , A route has been defined for requesting an access token.

Ownership, & non-Admin Vs Admin Users

Now, after validating the access token, we can extend the authorization layers and check if the current user is owner of the requested resource(i.e. post or comment), or is admin. So, How does it work?

Assign Middleware to controller

Order

Please note that the middlewares has to be applied in a certain order. The has to be added before the Middleware.

Override isAuthorized() method

In , Abilities are defined using facade.

Routing

These are some of the routes defined in . You can test the API using Postman

HTTP Method Path Action Fields
GET /users index
POST /oauth/access_token username, password, client_id, client_secret, and grant_type.
The field is the in table.
The field is secret.
The & fields are id0 & secret0, or id1 & secret1, ...etc respectively.
The field is password.
POST /posts store access_token, title, content
PUT /posts/{post_id} update access_token, title, content
DELETE /posts/{post_id} destroy access_token

Support

I've written this script in my free time during my studies. This is for free, unpaid. If you find it useful, please support the project by spreading the word.

Contribute

Contribute by creating new issues, sending pull requests on Github or you can send an email at: [email protected]

Dependencies

License

Built under MIT license.


All versions of lumen-api-oauth with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
laravel/lumen-framework Version 5.2.*
vlucas/phpdotenv Version ~2.2
laravel/homestead Version ^3.0
lucadegasperi/oauth2-server-laravel Version ^5.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package omarelgabry/lumen-api-oauth contains the following files

Loading the files please wait ....