Skip to content

Commit b6a182c

Browse files
committed
Add api routes
1 parent 46b5c38 commit b6a182c

73 files changed

Lines changed: 6059 additions & 414 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
1616
- laravel/prompts (PROMPTS) - v0
17+
- laravel/sanctum (SANCTUM) - v4
1718
- laravel/wayfinder (WAYFINDER) - v0
1819
- laravel/boost (BOOST) - v2
1920
- laravel/mcp (MCP) - v0

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
1616
- laravel/prompts (PROMPTS) - v0
17+
- laravel/sanctum (SANCTUM) - v4
1718
- laravel/wayfinder (WAYFINDER) - v0
1819
- laravel/boost (BOOST) - v2
1920
- laravel/mcp (MCP) - v0

GEMINI.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
1414
- laravel/fortify (FORTIFY) - v1
1515
- laravel/framework (LARAVEL) - v13
1616
- laravel/prompts (PROMPTS) - v0
17+
- laravel/sanctum (SANCTUM) - v4
1718
- laravel/wayfinder (WAYFINDER) - v0
1819
- laravel/boost (BOOST) - v2
1920
- laravel/mcp (MCP) - v0

app/Models/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
use Illuminate\Foundation\Auth\User as Authenticatable;
1111
use Illuminate\Notifications\Notifiable;
1212
use Laravel\Fortify\TwoFactorAuthenticatable;
13+
use Laravel\Sanctum\HasApiTokens;
1314

1415
#[Fillable(['name', 'email', 'password'])]
1516
#[Hidden(['password', 'two_factor_secret', 'two_factor_recovery_codes', 'remember_token'])]
1617
class User extends Authenticatable
1718
{
1819
/** @use HasFactory<UserFactory> */
19-
use HasFactory, Notifiable, TwoFactorAuthenticatable;
20+
use HasFactory, Notifiable, TwoFactorAuthenticatable, HasApiTokens;
2021

2122
/**
2223
* Get the attributes that should be cast.

bootstrap/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
return Application::configure(basePath: dirname(__DIR__))
1111
->withRouting(
1212
web: __DIR__.'/../routes/web.php',
13+
api: __DIR__.'/../routes/api.php',
1314
commands: __DIR__.'/../routes/console.php',
1415
health: '/up',
1516
)

bun.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"inertiajs/inertia-laravel": "^3.0",
1414
"laravel/fortify": "^1.34",
1515
"laravel/framework": "^13.7",
16+
"laravel/sanctum": "^4.0",
1617
"laravel/tinker": "^3.0",
1718
"laravel/wayfinder": "^0.1.14"
1819
},

composer.lock

Lines changed: 64 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/sanctum.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
use Laravel\Sanctum\Sanctum;
4+
5+
return [
6+
7+
/*
8+
|--------------------------------------------------------------------------
9+
| Stateful Domains
10+
|--------------------------------------------------------------------------
11+
|
12+
| Requests from the following domains / hosts will receive stateful API
13+
| authentication cookies. Typically, these should include your local
14+
| and production domains which access your API via a frontend SPA.
15+
|
16+
*/
17+
18+
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
19+
'%s%s',
20+
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
21+
Sanctum::currentApplicationUrlWithPort(),
22+
// Sanctum::currentRequestHost(),
23+
))),
24+
25+
/*
26+
|--------------------------------------------------------------------------
27+
| Sanctum Guards
28+
|--------------------------------------------------------------------------
29+
|
30+
| This array contains the authentication guards that will be checked when
31+
| Sanctum is trying to authenticate a request. If none of these guards
32+
| are able to authenticate the request, Sanctum will use the bearer
33+
| token that's present on an incoming request for authentication.
34+
|
35+
*/
36+
37+
'guard' => ['web'],
38+
39+
/*
40+
|--------------------------------------------------------------------------
41+
| Expiration Minutes
42+
|--------------------------------------------------------------------------
43+
|
44+
| This value controls the number of minutes until an issued token will be
45+
| considered expired. This will override any values set in the token's
46+
| "expires_at" attribute, but first-party sessions are not affected.
47+
|
48+
*/
49+
50+
'expiration' => null,
51+
52+
/*
53+
|--------------------------------------------------------------------------
54+
| Token Prefix
55+
|--------------------------------------------------------------------------
56+
|
57+
| Sanctum can prefix new tokens in order to take advantage of numerous
58+
| security scanning initiatives maintained by open source platforms
59+
| that notify developers if they commit tokens into repositories.
60+
|
61+
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
62+
|
63+
*/
64+
65+
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
66+
67+
/*
68+
|--------------------------------------------------------------------------
69+
| Sanctum Middleware
70+
|--------------------------------------------------------------------------
71+
|
72+
| When authenticating your first-party SPA with Sanctum you may need to
73+
| customize some of the middleware Sanctum uses while processing the
74+
| request. You may change the middleware listed below as required.
75+
|
76+
*/
77+
78+
'middleware' => [
79+
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
80+
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
81+
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
82+
],
83+
84+
];
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('personal_access_tokens', function (Blueprint $table) {
15+
$table->id();
16+
$table->morphs('tokenable');
17+
$table->text('name');
18+
$table->string('token', 64)->unique();
19+
$table->text('abilities')->nullable();
20+
$table->timestamp('last_used_at')->nullable();
21+
$table->timestamp('expires_at')->nullable()->index();
22+
$table->timestamps();
23+
});
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*/
29+
public function down(): void
30+
{
31+
Schema::dropIfExists('personal_access_tokens');
32+
}
33+
};

0 commit comments

Comments
 (0)