This repository has been archived by the owner on Feb 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement Laravel sanctum (#670)
- Loading branch information
Showing
7 changed files
with
167 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Stateful Domains | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Requests from the following domains / hosts will receive stateful API | ||
| authentication cookies. Typically, these should include your local | ||
| and production domains which access your API via a frontend SPA. | ||
| | ||
*/ | ||
|
||
'stateful' => explode(',', env( | ||
'SANCTUM_STATEFUL_DOMAINS', | ||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1' | ||
)), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Expiration Minutes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This value controls the number of minutes until an issued token will be | ||
| considered expired. If this value is null, personal access tokens do | ||
| not expire. This won't tweak the lifetime of first-party sessions. | ||
| | ||
*/ | ||
|
||
'expiration' => null, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Sanctum Middleware | ||
|-------------------------------------------------------------------------- | ||
| | ||
| When authenticating your first-party SPA with Sanctum you may need to | ||
| customize some of the middleware Sanctum uses while processing the | ||
| request. You may change the middleware listed below as required. | ||
| | ||
*/ | ||
|
||
'middleware' => [ | ||
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, | ||
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, | ||
], | ||
|
||
]; |
32 changes: 32 additions & 0 deletions
32
database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreatePersonalAccessTokensTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('personal_access_tokens', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->morphs('tokenable'); | ||
$table->string('name'); | ||
$table->string('token', 64)->unique(); | ||
$table->text('abilities')->nullable(); | ||
$table->timestamp('last_used_at')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('personal_access_tokens'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters