mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-20 13:20:16 +00:00
🔒 Add Nostr authentication support with custom guard and user provider
🛠️ Integrate Nostr auth across relevant components and views 📦 Update config, routes, and service provider for Nostr auth
This commit is contained in:
43
app/Auth/NostrUserProvider.php
Normal file
43
app/Auth/NostrUserProvider.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Auth;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
|
||||
class NostrUserProvider implements UserProvider
|
||||
{
|
||||
public function retrieveById($identifier): ?Authenticatable
|
||||
{
|
||||
return new NostrUser($identifier);
|
||||
}
|
||||
|
||||
public function retrieveByToken($identifier, $token): ?Authenticatable
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function updateRememberToken(Authenticatable $user, $token): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function retrieveByCredentials(array $credentials): ?Authenticatable
|
||||
{
|
||||
if (isset($credentials['pubkey'])) {
|
||||
return new NostrUser($credentials['pubkey']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function validateCredentials(Authenticatable $user, array $credentials): bool
|
||||
{
|
||||
return $user instanceof NostrUser && $user->getPubkey() === ($credentials['pubkey'] ?? null);
|
||||
}
|
||||
|
||||
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user