Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/Admin/OAuthProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
use Horde\Core\PageOutput\PageMeta;
use Horde\Core\PageOutput\ViewMode;
use Horde\Core\PageOutput\ViewModeConfigurator;
use Horde\Core\Service\OAuthProviderConfigRepository;
use Horde\Core\Service\Exception\OAuthProviderConfigNotFoundException;
use Horde\Core\Service\NullOAuthProviderConfigRepository;
use Horde\Core\Service\OAuthProviderConfigRepository;
use Horde\Core\Sidebar\AdminSidebarPanel;
use Horde\Core\Sidebar\SidebarRenderer;
use Horde\Core\Topbar\TopbarBuilder;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function __construct(
private readonly AdminSidebarPanel $adminPanel,
private readonly SidebarRenderer $sidebarRenderer,
private readonly Horde_Registry $registry,
private readonly RouteUrlWriter $urlWriter,
private readonly ?RouteUrlWriter $urlWriter = null,
private readonly ?ProviderDiscovery $discovery = null,
) {}

Expand Down Expand Up @@ -90,6 +91,8 @@ private function listProviders(ServerRequestInterface $request): ResponseInterfa
$view->presets = $availablePresets;
$view->baseUrl = $this->getBaseUrl();
$view->statusUrl = $webroot . '/admin/authentication/status/';
$view->storageUnavailable = $this->repository instanceof NullOAuthProviderConfigRepository;
$view->configUrl = $webroot . '/admin/config/config.php?app=horde';

$html = $this->renderChrome(
_("OAuth Providers"),
Expand Down Expand Up @@ -188,7 +191,7 @@ private function editProvider(ServerRequestInterface $request, ?string $provider
$view->provider = $provider;
$view->baseUrl = $baseUrl;
$view->setupNotes = $preset['notes'] ?? '';
$view->callbackUrl = $this->urlWriter->absoluteUrlFor('SettingsOAuthCallback');
$view->callbackUrl = $this->resolveCallbackUrl();

$template = $provider['type'] === 'service_app' ? 'edit-service-app' : 'edit-oauth2';

Expand Down Expand Up @@ -417,4 +420,16 @@ private function getBaseUrl(): string
{
return rtrim($this->registry->get('webroot', 'horde'), '/') . '/admin/authentication/provider';
}

private function resolveCallbackUrl(): string
{
if ($this->urlWriter !== null) {
$url = $this->urlWriter->absoluteUrlFor('SettingsOAuthCallback');
if ($url !== null) {
return $url;
}
}

return rtrim($this->registry->get('webroot', 'horde'), '/') . '/settings/oauth/callback';
}
}
10 changes: 10 additions & 0 deletions templates/admin/oauthprovider/list.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
<a href="<?php echo $this->h($this->statusUrl) ?>" class="btn btn-secondary"><?php echo _("System Status") ?></a>
</div>

<?php if (!empty($this->storageUnavailable)): ?>
<div class="settings-empty">
<?php echo sprintf(
_("Providers cannot be saved. Configure the SQL database in %sHorde Settings%s."),
'<a href="' . $this->h($this->configUrl) . '">',
'</a>'
) ?>
</div>
<?php endif; ?>

<?php if (count($this->providers)): ?>
<ul class="settings-provider-list">
<?php foreach ($this->providers as $provider): ?>
Expand Down