PHP code example of datahivedevelopment / laravel-introspection
1. Go to this page and download the library: Download datahivedevelopment/laravel-introspection library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
datahivedevelopment / laravel-introspection example snippets
use DataHiveDevelopment\Introspection\Introspection;
// ...
public function boot()
{
$this->registerPolicies();
Passport::routes();
Passport::tokensCan([
'user.read' => '...',
//...
]);
Introspection::routes();
}
Introspection::routes([
'prefix' => '/apiauth'
]);
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'introspect',
'provider' => 'users',
],
],
Introspection::routes([
'middleware' => [
'client',
'scope:Introspect'
]
]);
Route::get('/orders', function () {
//
})->middleware('auth:api');
'scopes' => \DataHiveDevelopment\Introspection\Http\Middleware\CheckScopes::class,
'scope' => \DataHiveDevelopment\Introspection\Http\Middleware\CheckForAnyScope::class,
Route::get('/orders', function () {
// Access token has both "check-status" and "place-orders" scopes...
})->middleware('scopes:check-status,place-orders');
Route::get('/orders', function () {
// Access token has either "check-status" or "place-orders" scope...
})->middleware('scope:check-status,place-orders');
$table->efficientUuid('uuid')->index();
$table->bigIncrements('id');
$table->uuid('uuid')->index();
$table->rememberToken();
$table->timestamps();
$table->bigIncrements('id');
$table->efficientUuid('uuid')->index();
$table->string('name');
$table->string('password');
// additional columns etc
$table->rememberToken();
$table->timestamps();
public function findForIntrospect($userId)
{
return $this->where('username', $userId)->first();
}
public function getIntrospectionUserId()
{
return $this->username;
}
'web' => [
// Other middleware...
\DataHiveDevelopment\Introspection\Http\Middleware\CreateFreshApiToken::class,
],
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
Introspection::routes();
Introspection::cookie('myapp_token');
}