Skip to content

Commit 7ff1e97

Browse files
committed
feat: Integrate WorkOS for SSO and OAuth flows, update configuration and routes
1 parent 00f1871 commit 7ff1e97

File tree

7 files changed

+227
-65
lines changed

7 files changed

+227
-65
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@ VITE_APP_NAME="${APP_NAME}"
7676
# Debugbar configuration
7777
DEBUGBAR_ENABLED=true
7878
DEBUGBAR_EDITOR=vscode-remote
79+
80+
# WorkOS configuration
81+
WORKOS_ENABLED=false
82+
WORKOS_API_KEY=
83+
WORKOS_CLIENT_ID=
84+
WORKOS_REDIRECT_URI=${APP_URL}/authenticate

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This is a fork of the [Laravel + React Starter Kit](https://github.com/laravel/r
1010
- **MinIO & Media Library**: For file uploads and media management.
1111
- **Sail Included**: Docker support with Laravel Sail for easy local development.
1212
- **Blueprint**: Uses [laravel-shift/blueprint](https://blueprint.laravelshift.com/) for rapid application development.
13+
- **Workos**: Integrated for SSO and OAuth flows with [workos.com](https://workos.com).
1314

1415
And much more!
1516

@@ -183,3 +184,18 @@ You have Laravels's additional types such as `Paginator`, `EnumTtait` with usefu
183184
In addition to the default validation rules, We have added the following custom validation rule:
184185
185186
- **Phone**: Validates that the input is a valid phone number using the package [propaganistas/laravel-phone](https://github.com/propaganistas/laravel-phone).
187+
188+
## Workos
189+
190+
The application integrates with [WorkOS](https://workos.com) for SSO and OAuth flows. You ca anable it in the `.env` file:
191+
192+
```env
193+
WORKOS_ENABLED=true
194+
WORKOS_CLIENT_ID=your-client-id
195+
WORKOS_CLIENT_SECRET=your-client-secret
196+
```
197+
198+
*Note:* Make Sure to set redirect URIs in your WorkOS dashboard to match your application URLs.
199+
200+
- *Redirect URIs*: `http://localhost/authenticate`
201+
- *App homepage URL*: `http://localhost`

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"inertiajs/inertia-laravel": "^2.0",
1414
"laravel/framework": "^12.0",
1515
"laravel/tinker": "^2.10.1",
16+
"laravel/workos": "^0.2.1",
1617
"propaganistas/laravel-phone": "^6.0",
1718
"spatie/laravel-data": "^4.17",
1819
"spatie/laravel-medialibrary": "^11.13",

composer.lock

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

config/services.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,11 @@
3535
],
3636
],
3737

38+
'workos' => [
39+
'enabled' => env('WORKOS_ENABLED', false),
40+
'api_key' => env('WORKOS_API_KEY'),
41+
'client_id' => env('WORKOS_CLIENT_ID'),
42+
'redirect_uri' => env('WORKOS_REDIRECT_URI', config('app.url') . '/authenticate'),
43+
],
44+
3845
];

routes/web.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@
1919
});
2020

2121
require __DIR__.'/settings.php';
22-
require __DIR__.'/auth.php';
22+
23+
if (config('services.workos.enabled')) {
24+
require __DIR__.'/workos.php';
25+
} else {
26+
require __DIR__.'/auth.php';
27+
}

routes/workos.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Route;
4+
use Laravel\WorkOS\Http\Requests\AuthKitAuthenticationRequest;
5+
use Laravel\WorkOS\Http\Requests\AuthKitLoginRequest;
6+
use Laravel\WorkOS\Http\Requests\AuthKitLogoutRequest;
7+
8+
Route::get('login', function (AuthKitLoginRequest $request) {
9+
return $request->redirect();
10+
})->middleware(['guest'])->name('login');
11+
12+
Route::get('authenticate', function (AuthKitAuthenticationRequest $request) {
13+
return tap(to_route('dashboard'), fn () => $request->authenticate());
14+
})->middleware(['guest']);
15+
16+
Route::post('logout', function (AuthKitLogoutRequest $request) {
17+
return $request->logout();
18+
})->middleware(['auth'])->name('logout');

0 commit comments

Comments
 (0)