in my environment I just need the authorizationUrl. But as it was build only in a hook while executing the felogin plugin, I had to extract the needed parts of your extension into my own userfunc:
<?php
declare(strict_types=1);
/*
* This file is part of the package jweiland/dudeldudeldi
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace JWeiland\DudelDudelDi\UserFunc;
use Causal\Oidc\Service\OAuthService;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* The OIDC Authorization URL will only be generated while loading the fe_login plugin.
* As that plugin will not be used anymore we had to build the authorization URL with help of an TypoScript "userfunc".
* We have adopted the authorization URL generation into this class, so, that you can call it
* via TypoScript lib.* USER.
*/
class GetOidcAuthorizationUrlUserFunc
{
private OAuthService $oAuthService;
private ExtensionConfiguration $extensionConfiguration;
private ContentObjectRenderer $cObj;
public function __construct(OAuthService $oAuthService, ExtensionConfiguration $extensionConfiguration)
{
$this->oAuthService = $oAuthService;
$this->extensionConfiguration = $extensionConfiguration;
}
/**
* This method is the new way of TYPO3 "callUserFunc" to inject the ContentObjectRenderer into UserFunc classes
*/
public function setContentObjectRenderer(ContentObjectRenderer $contentObjectRenderer): void
{
$this->cObj = $contentObjectRenderer;
}
public function build(): string
{
$settings = $this->getExtensionSettings();
// Early return. Empty string to handle the condition in Fluid template much easier.
if ($settings === []) {
return '';
}
$this->oAuthService->setSettings($this->getExtensionSettings());
return $this->oAuthService->getAuthorizationUrl();
}
private function getExtensionSettings(): array
{
try {
$settings = $this->extensionConfiguration->get('oidc') ?? [];
if (is_array($settings) && $settings !== []) {
return $settings;
}
} catch (ExtensionConfigurationExtensionNotConfiguredException | ExtensionConfigurationPathDoesNotExistException $e) {
}
return [];
}
}
Sure, I'm working with DependencyInjection, but in FE I got following error message:
(1/1) Symfony\Component\DependencyInjection\Exception\RuntimeException
Cannot autowire service "JWeiland\DudelDudelDi\UserFunc\GetOidcAuthorizationUrlUserFunc": argument "$oAuthService" of method "__construct()" references class "Causal\Oidc\Service\OAuthService" but no such service exists.
I found out, that you have forgotten to add the resource part in Services.yaml
Hello,
in my environment I just need the authorizationUrl. But as it was build only in a hook while executing the felogin plugin, I had to extract the needed parts of your extension into my own
userfunc
:Sure, I'm working with DependencyInjection, but in FE I got following error message:
I found out, that you have forgotten to add the
resource
part inServices.yaml
Nice greetings
Stefan