mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-04 22:59:41 +00:00
Fix the anikeen API guard and register its user provider
- Register the guard driver and the anikeen user provider with static closures: Laravel binds extend() closures to the AuthManager, so $this->makeGuard() failed. - Look the token's sub up in the user's Anikeen ID column (anikeen_id by default; provider 'column', services.anikeen.user_id_column or useUserIdField()), not in the primary key; works with the anikeen, eloquent and database providers. - JwtParser: key from services.anikeen.public_key(_path) or the bundled key, read once per process; misconfiguration is an error, not a 401. Passport tokens have no client claim, so it is optional now. - Optional revocation check against Anikeen ID (verify_revocation), cached per token. - anikeenTokenCan() without a token, anikeenTokenCanAny(), scope middleware accept JSON responses. - Update the bundled staging public key to the current staging key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbpgPaLqhBzo1AXHNs9Cx5
This commit is contained in:
1 parent
b074ec3c0c
commit
dc29eb2844
12 files changed
+554
-163
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Anikeen\Id\Auth;
|
||||
|
||||
use Anikeen\Id\AnikeenId;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Auth\UserProvider as Base;
|
||||
|
||||
@@ -10,11 +11,33 @@ class UserProvider implements Base
|
||||
/**
|
||||
* Create a new AnikeenId user provider.
|
||||
*/
|
||||
public function __construct(protected Base $provider, protected string $providerName)
|
||||
public function __construct(protected Base $provider, protected string $providerName, protected ?string $column = null)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* The column that holds a user's Anikeen ID: the provider's `column`, else
|
||||
* `services.anikeen.user_id_column`, else AnikeenId::getUserIdField() (`anikeen_id`).
|
||||
*/
|
||||
public function column(): string
|
||||
{
|
||||
return $this->column ?: (config('services.anikeen.user_id_column') ?: AnikeenId::getUserIdField());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the user of an Anikeen ID (the `sub` of an access token).
|
||||
*/
|
||||
public function retrieveByAnikeenId(string $anikeenId): ?Authenticatable
|
||||
{
|
||||
if (method_exists($this->provider, 'retrieveByAnikeenId')) {
|
||||
return $this->provider->retrieveByAnikeenId($anikeenId);
|
||||
}
|
||||
|
||||
// eloquent / database providers: a plain where on the column
|
||||
return $this->provider->retrieveByCredentials([$this->column() => $anikeenId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -65,6 +88,6 @@ class UserProvider implements Base
|
||||
|
||||
public function rehashPasswordIfRequired(Authenticatable $user, #[\SensitiveParameter] array $credentials, bool $force = false)
|
||||
{
|
||||
// TODO: Implement rehashPasswordIfRequired() method.
|
||||
$this->provider->rehashPasswordIfRequired($user, $credentials, $force);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user