From b8543b863a597a0b0437d09d922d6d061b35690f Mon Sep 17 00:00:00 2001 From: = Date: Sat, 24 Feb 2024 17:19:57 -0500 Subject: [PATCH] update readme --- README.md | 177 +----------------------------------------- composer.json | 3 +- stubs/config/auth.php | 2 +- stubs/routes/api.php | 8 ++ 4 files changed, 12 insertions(+), 178 deletions(-) create mode 100644 stubs/routes/api.php diff --git a/README.md b/README.md index 602e96a..50e4b88 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ composer require laravel/jetstream ``` ```bash -php artisan jetstream:install livewire --api +php artisan jetstream:install livewire --api --dark --pest ``` See [Docs](https://jetstream.laravel.com/installation.html) for more info. @@ -33,185 +33,10 @@ See [Docs](https://jetstream.laravel.com/installation.html) for more info. composer require headerx/laravel-jetstream-passport ``` -```bash -php artisan migrate -``` - ```bash php artisan jetstream-passport:install ``` -3. in your user model replace the `Laravel\Sanctum\HasApiTokens` trait with `Laravel\Passport\HasApiTokens`: - -```diff - [ - 'web' => [ - 'driver' => 'session', - 'provider' => 'users', - ], - - 'api' => [ - 'driver' => 'passport', - 'provider' => 'users', - 'hash' => false, - ], - ], -... -``` - -5. replace the contents of resources/views/vendor/passport/authorize.blade.php with the following: - -```blade - -@include('jetstream-passport::authorize') - -``` - -6. replace the contents of resources/views/api/index.blade.php with the following: - -```blade - -@include('jetstream-passport::index') - -``` - -You can publish the views with: - -```bash -php artisan vendor:publish --provider="HeaderX\JetstreamPassport\JetstreamPassportServiceProvider" --tag="jetstream-passport-views" -``` - -7. finally, in one of you application's service providers, add passport routes and define scopes for your passport tokens, and set up jetstream to use them, example: - -```php -configurePermissions(); - - // ... - } - - /** - * Configure the roles and permissions that are available within the application. - */ - protected function configurePermissions(): void - { - - // define scopes for passport tokens - Passport::tokensCan([ - 'create' => 'Create resources', - 'read' => 'Read Resources', - 'update' => 'Update Resources', - 'delete' => 'Delete Resources', - ]); - - // default scope for passport tokens - Passport::setDefaultScope([ - // 'create', - 'read', - // 'update', - // 'delete', - ]); - - // same as passport default above - Jetstream::defaultApiTokenPermissions(['read']); - - // use passport scopes for jetstream token permissions - Jetstream::permissions(Passport::scopeIds()); - } -} -``` - -8. Now you can also edit `routes/api.php` - -```diff -user(); --})->middleware(Authenticate::using('sanctum')); -+})->middleware('auth:api'); -``` - -9. Lastly, for postcss processing of styles, you can edit tailwind.config.js to include '.vendor/headerx/laravel-jetstream-passport/resources/views/**/*.blade.php' - -```js -import defaultTheme from 'tailwindcss/defaultTheme'; -import forms from '@tailwindcss/forms'; -import typography from '@tailwindcss/typography'; - -/** @type {import('tailwindcss').Config} */ -export default { - content: [ - './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', - './vendor/headerx/laravel-jetstream-passport/resources/views/**/*.blade.php', - './vendor/laravel/jetstream/**/*.blade.php', - './storage/framework/views/*.php', - './resources/views/**/*.blade.php', - ], - - theme: { - extend: { - fontFamily: { - sans: ['Figtree', ...defaultTheme.fontFamily.sans], - }, - }, - }, - - plugins: [forms, typography], -}; -``` - ## Testing ```bash diff --git a/composer.json b/composer.json index cfa2d9a..68a3322 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ } ], "require": { - "php": "^8.1", + "php": "^8.2", + "laravel/framework": "^11.0", "laravel/passport": "*", "livewire/livewire": "^3.4", "spatie/laravel-package-tools": "^1.16.2" diff --git a/stubs/config/auth.php b/stubs/config/auth.php index b2d5fec..6681874 100644 --- a/stubs/config/auth.php +++ b/stubs/config/auth.php @@ -40,7 +40,7 @@ 'driver' => 'session', 'provider' => 'users', ], - + 'api' => [ 'driver' => 'passport', 'provider' => 'users', diff --git a/stubs/routes/api.php b/stubs/routes/api.php new file mode 100644 index 0000000..f35f6f8 --- /dev/null +++ b/stubs/routes/api.php @@ -0,0 +1,8 @@ +user(); +})->middleware('auth:api');