Giter Club home page Giter Club logo

passport-consumer's Introduction

Laravel Passport Consumer.

Latest Version on Packagist Software License Build Status Total Downloads

This package lets you consume laravel passport local or remote with either the password grant flow or the authorization code flow. The aim is to allow you to focus on your app and leave oauth to passport and the consumption of said oauth to this package.

Installation

composer require montross50/passport-consumer

Environment configuration

Publish the config file:

php artisan vendor:publish --provider="Montross50\PassportConsumer\PassportConsumerServiceProvider" --tag=config

There are a LOT of config options. Probably too many. The package should work out of the box with a default laravel install aside from defining the required env variables somewhere. The main config options to take note of are:

  • enable_pg
    • If set to true then the password grant routes are loaded.
  • enable_access
    • If set to true then the authorization code routes are loaded
  • passport_location
    • If set to local then it is assumed the given app is the app with passport installed. If not it is expected that this value is your passport server url.
  • log_user_in
    • If set to true the following happens:
      • User is retrieved from user_endpoint
      • If remote passport:
        • Find local user for remote user
        • Create local user using defaults and data from remote if not found
      • Log user in using session guard
      • The access_token and refresh_token will be in the session.

Required env variables:

  • PC_PASSPORT_SECRET_PG
    • The passport secret access key for you password grant client
  • PC_PASSPORT_SECRET_ACCESS
    • The passport secret access key for you authorization code client
  • PC_PASSPORT_ID_PG
    • The passport client id for your password grant client
  • PC_PASSPORT_ID_ACCESS
    • The passport client id for you authorization code client

User Model

If you are working with a remote passport install then add the Montross50\PassportConsumer\HasRemoteTokens Trait to your Users model.

The log_user_in functionality will create users to pair with a remote user if the local user cannot be found. Default values and fields are defined on the trait and must be overridden if you need to add more defaults for new user.

Run Migrations

This package adds an api_token and configurable remote_user_id field to your users model. This only happens if you have your package configured for remote passport.

php artisan migrate

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

  • Trent Schmidt

License

The MIT License (MIT). Please see License File for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.