Demo: https://voting.main-app.io
- Clone the repo and
cdinto it composer install- Rename or copy
.env.examplefile to.env php artisan key:generate- Setup a database and add your database credentials in your
.envfile php artisan migrateorphp artisan migrate --seedif you want seed datanpm installnpm run devornpm run watchphp artisan serveor use Laravel Valet- Visit
localhost:8000in your browser - Access Nova via
/admin
- Install Laravel Passport in Oauth Server application: https://laravel.com/docs/8.x/passport
- Create Passport Client via:
php artisan passport:client(Read more about Requesting Tokens process: https://laravel.com/docs/8.x/passport#requesting-tokens) - Add these env variables into your voting app .env
MAIN_APP_NAME="Main App"
MAIN_APP_CLIENT_ID= // Client ID in oauth_clients table of your Oauth Server application.
MAIN_APP_CLIENT_SECRET= // Secret in oauth_clients table of your Oauth Server application.
MAIN_APP_CLIENT_REDIRECT= http://voting.test/main-app/auth/callback // Callback URL of the voting application.
MAIN_APP_PASSPORT_SERVER=https://passport.test // Oauth Server application URL
MAIN_APP_OAUTH_USER_ENDPOINT=api/user // User api endpoint in Oauth Server application.
MAIN_APP_OAUTH_TOKEN_ENDPOINT=oauth/token // Token api endpoint in Oauth Server application.
MAIN_APP_OAUTH_AUTHORIZE_ENDPOINT=oauth/authorize // Oauth authorize endpoint in Oauth Server application.
- Make sure your
api.phpis using Passport (auth:api):
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Voting app will make a request to that route to get the user information of you Saas app.
- Customize (Optional)
App\Oauth\MainAppPassportProvider.php
App\Http\Controllers\Auth\LoginWithMainAppController.php