Download the PHP package renepardon/lighthouse-graphql-passport-auth without Composer
On this page you can find all versions of the php package renepardon/lighthouse-graphql-passport-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download renepardon/lighthouse-graphql-passport-auth
More information about renepardon/lighthouse-graphql-passport-auth
Files in renepardon/lighthouse-graphql-passport-auth
Package lighthouse-graphql-passport-auth
Short Description Add GraphQL types and mutations for login and recover password functionality through passport with lighthouse
License MIT
Informations about the package lighthouse-graphql-passport-auth
Lighthouse GraphQL Passport Auth (Laravel ^6.2 / Lighthouse ^4.8)
GraphQL mutations for Laravel Passport using Lighthouse version ^4.8
Installation
Make sure you have Laravel Passport installed.
To install run composer require renepardon/lighthouse-graphql-passport-auth
.
ServiceProvider will be attached automatically
Run this command to publish the migration, schema and configuration file
Add the following env vars to your .env
You are done with the installation!
Configuration
In the configuration file you can now set the schema file to be used for the exported one like this:
This will allow you to change the schema and resolvers if needed.
Usage
This will add 8 mutations to your GraphQL API
- login: Will allow your clients to log in by using the password grant client.
- refreshToken: Will allow your clients to refresh a passport token by using the password grant client.
- logout: Will allow your clients to invalidate a passport token.
- forgotPassword: Will allow your clients to request the forgot password email.
- updateForgottenPassword: Will allow your clients to update the forgotten password from the email received.
- register: Will allow your clients to register a new user using the default Laravel registration fields
- socialLogin: Will allow your clients to log in using access token from social providers using socialite
- verifyEmail: Will allow your clients to verify the email after they receive a token in the email
Using the email verification
If you want to use the email verification feature that comes with laravel, please follow the instruction in the laravel documentation to configure the model in https://laravel.com/docs/6.x/verification, once that is done add the following traits
This will add some methods for the email notification to be sent with a token. Use the token in the following mutation.
If the token is valid the tokens will be issued.
Using socialite for social login
If you want to use the mutation for social login, please add the Renepardon\LighthouseGraphQLPassport\HasSocialLogin
trait to your user model like this
This will add a method that is used by the mutation to get the user from the social network and create or get it from
the DB based on the provider
and provider_id
You can override the method and add more fields if you need to.
Make sure Socialite is configured properly to use the social network, please see Laravel Socialite
Why the OAuth client is used in the backend and not from the client application?
When an application that needs to be re compiled and re deploy to stores like an iOS app needs to change the client for whatever reason, it becomes a blocker for QA or even brakes the production app if the client is removed. The app will not work until the new version with the updated keys is deployed. There are alternatives to store this configuration in the client but for this use case we are relying on the backend to be the OAuth client
Tests
To run the test in this package, navigate to the root folder of the project and run
Then
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email rene dot pardon at boonweb dot de instead of using the issue tracker.
Credits
And all developers within the commit history.
License
The MIT License (MIT). Please see License File for more information.
All versions of lighthouse-graphql-passport-auth with dependencies
nuwave/lighthouse Version ^4.8
laravel/passport Version ^8.2
laravel/socialite Version ^4.3
guzzlehttp/guzzle Version ^6.5
ext-json Version *