Open JanMikes opened 6 years ago
Hi. There is currently no easy way to do this. However, I am sure something could be figured out. What is your reason for extending the entity?
We want to have "trusted" clients, which would automatically approve authorization code grant.
Right now my solution looks like this (ApprovePresenter
):
public function actionDefault(): void
{
/** @var ApproveControl $approveControl */
$approveControl = $this['approve'];
$approveControl->setTemplateFile(__DIR__ . '/templates/approveControl.latte');
/** @var string $data */
$data = $this->getSession(OAuth2Presenter::SESSION_NAMESPACE)->authorizationRequest;
$authorizationRequest = $this->authorizationRequestSerializer->unserialize($data);
$client = $authorizationRequest->getClient();
if ($this->isTrustedClient($client)) {
$approveControl->handleApprove();
}
}
private function isTrustedClient(ClientEntityInterface $client): bool
{
return Strings::contains($client->getIdentifier(), 'xyz');
}
It works as intended.
Though i would love if there was a toggle (bool property) and method on client ClientEntity::isTrusted(): bool
.
Other solution that came in my mind is create different entity/table with list of trusted clients, but tbh i dont like this solution that much.
Hmm, interesting use case. I can definitely see how something like that could be useful. I will give it some thought and maybe I can figure out something that would satisfy you.
Hi, i am thinking about extending
ClientEntity
and i would like to know what would be the best way to do it (and basically to any other oauth related entity).Creating own entity would not be enough, i need to wire it into repository and query service.
Is there any suggestions how to do it? I can imagine there could be config option to pass entity class name.