10. Fortify - a gdzie widoki?
● https://github.com/laravel/ui
● AppProvidersFortifyServiceProvider.php
public function boot()
{
Fortify::loginView(
function () {
return view('auth.login');
}
);
}
11. Fortify - plusy i minusy
- brak widoków
+ dużo opcji konfiguracji
+ mała ilość dodatkowych plików w projekcie
15. Sanctum - co nam daje?
● Uwierzytelnianie API za pomocą tokenu
● Uwierzytelnianie dla aplikacji typu SPA
● Uwierzytelnianie dla aplikacji mobilnych
● https://laravel.com/docs/8.x/sanctum
Przykładowy token: Bearer 1|jadhafvbma67e8fsddfsm
16. Sanctum - to naprawdę proste
public function __construct(protected Hasher $hash) {}
public function login(Request $request): string
{
$user = User::query()->where(
"email", $request->get(
"email"))->first();
if ($user === null || !$this->hash->check($request->get(
"password"), $user->password))
{
throw new AuthenticationException();
}
return $user->createToken($user->email)->plainTextToken;
}
18. Sanctum - od strony serwera
use IlluminateRoutingRouter;
/** @var Router $router */
$router = app(Router::class);
$router->middleware(
"auth:sanctum")->group(
function (Router $router): void {
$router->get(
"/user", fn(Request $request) => $
request->user());
},
);
19. Sanctum - plusy i brak minusów?
+ opcja modyfikacji bazowej klasy tokenu
+ mała ilość dodatkowych plików w projekcie
+ łatwa i przejrzysta praca z tokenami
31. Jetstream - co nam daje cd.
● Zarządzanie sesjami
● Zarządzanie tokenami API
● Zarządzanie grupami i uprawnieniami w nich
● https://jetstream.laravel.com/2.x/introduction.html
36. Jetstream - rozszerzenie --teams
● możliwość tworzenia i
zarządzania grupami
● zarządzanie uprawnieniami
37. Jetstream - rozszerzenie --teams c. d.
// Access the team's owner...
$team->owner : AppModelsUser
// Get all of the team's users, including the owner...
$team->allUsers() : IlluminateDatabaseEloquentCollection
// Get all of the team's users, excluding the owner...
$team->users : IlluminateDatabaseEloquentCollection
// Determine if the given user is a team member...
$team->hasUser($user) : bool
// Determine if the team has a member with the given email address...
$team->hasUserWithEmail($emailAddress) :bool
// Determine if the given user is a team member with the given permission...
$team->userHasPermission($user, $permission) :bool
38. Jetstream - plusy i minusy
+ duża liczba gotowych widoków
+ duża liczba gotowych funkcjonalności
- duża ilość dodatkowych plików w projekcie
39. Podsumowanie
Gotowe
widoki
Tokeny API 2FA Logowanie /
Rejestracja
Wybór
technologii
frontendu
Fortify NIE NIE TAK TAK NIE
Breeze TAK NIE NIE TAK TAK
Sanctum NIE TAK NIE NIE NIE
Jetstream TAK TAK TAK TAK TAK