Replies: 1 comment
-
|
You can absolutely create a custom User Provider and User Entity — Shield fully supports this out of the box, and you can set them up easily by following the documentation. Regarding a custom Authenticator: Shield already provides a solid set of built-in authentication methods, including: /**
* --------------------------------------------------------------------
* Authenticators
* --------------------------------------------------------------------
* The available authentication systems, listed
* with alias and class name. These can be referenced
* by alias in the auth helper:
* auth('tokens')->attempt($credentials);
*
* @var array<string, class-string<AuthenticatorInterface>>
*/
public array $authenticators = [
'tokens' => AccessTokens::class,
'session' => Session::class,
'hmac' => HmacSha256::class,
// 'jwt' => JWT::class,
];These cover most use cases in typical applications. If you can explain what specific behavior or functionality you’re trying to achieve — something that the existing authenticators cannot provide — it would help a lot. There may be a simpler or more integrated solution available for what you’re trying to do. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
For my project, I need to create my own Authenticator with a custom User Provider and User entity.
I created a class into a file named App\Shield\Authenticators\MyAuthenticator for example and tried replacing "CodeIgniter\Shield\Entities\User" with my own: "App\Entities\User". However, i'm getting an error in the "login" function : it's not compatible with the prototype declaration of the AuthenticatorInterface. This is due to the class of the $user parameter.
I thought I could extend a "BaseAuthenticator" like the "BaseModel" for models, but I couldn't find anything in the Shield source code.
My question is: Is it possible to create my own authenticator, and if so, how?
Thank you in advance for your help.
Beta Was this translation helpful? Give feedback.
All reactions