Skip to content
Merged
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
7 changes: 7 additions & 0 deletions src/Bridges/SspBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace SimpleSAML\Module\oidc\Bridges;

use SimpleSAML\Module\oidc\Bridges\SspBridge\Auth;
use SimpleSAML\Module\oidc\Bridges\SspBridge\Module;
use SimpleSAML\Module\oidc\Bridges\SspBridge\Utils;

Expand All @@ -13,6 +14,7 @@
*/
class SspBridge
{
protected static ?Auth $auth = null;
protected static ?Utils $utils = null;
protected static ?Module $module = null;

Expand All @@ -25,4 +27,9 @@ public function module(): Module
{
return self::$module ??= new Module();
}

public function auth(): Auth
{
return self::$auth ??= new Auth();
}
}
17 changes: 17 additions & 0 deletions src/Bridges/SspBridge/Auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Module\oidc\Bridges\SspBridge;

use SimpleSAML\Module\oidc\Bridges\SspBridge\Auth\Source;

class Auth
{
protected static ?Source $source = null;

public function source(): Source
{
return self::$source ??= new Source();
}
}
13 changes: 13 additions & 0 deletions src/Bridges/SspBridge/Auth/Source.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Module\oidc\Bridges\SspBridge\Auth;

class Source
{
public function getSources(): array
{
return \SimpleSAML\Auth\Source::getSources();
}
}
20 changes: 15 additions & 5 deletions src/Forms/ClientForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
namespace SimpleSAML\Module\oidc\Forms;

use Nette\Forms\Form;
use SimpleSAML\Auth\Source;
use SimpleSAML\Locale\Translate;
use SimpleSAML\Module\oidc\Bridges\SspBridge;
use SimpleSAML\Module\oidc\Forms\Controls\CsrfProtection;
use SimpleSAML\Module\oidc\ModuleConfig;
use SimpleSAML\OpenID\Codebooks\ClientRegistrationTypesEnum;
Expand Down Expand Up @@ -58,8 +58,11 @@ class ClientForm extends Form
/**
* @throws \Exception
*/
public function __construct(private readonly ModuleConfig $moduleConfig, protected CsrfProtection $csrfProtection)
{
public function __construct(
protected readonly ModuleConfig $moduleConfig,
protected CsrfProtection $csrfProtection,
protected SspBridge $sspBridge,
) {
parent::__construct();

$this->buildForm();
Expand Down Expand Up @@ -315,6 +318,14 @@ public function setDefaults(object|array $data, bool $erase = false): static

$data['jwks'] = is_array($data['jwks']) ? json_encode($data['jwks']) : null;

if (
$data['auth_source'] !== null &&
(!in_array($data['auth_source'], $this->sspBridge->auth()->source()->getSources()))
) {
// Possible auth source name change without prior update in clients, resetting.
$data['auth_source'] = null;
}

parent::setDefaults($data, $erase);

return $this;
Expand Down Expand Up @@ -355,10 +366,9 @@ protected function buildForm(): void

$this->addCheckbox('is_confidential', '{oidc:client:is_confidential}');

// TODO mivanci Source::getSource() move to SSP Bridge.
$this->addSelect('auth_source', '{oidc:client:auth_source}:')
->setHtmlAttribute('class', 'full-width')
->setItems(Source::getSources(), false)
->setItems($this->sspBridge->auth()->source()->getSources(), false)
->setPrompt(Translate::noop('-'));

$scopes = $this->getScopes();
Expand Down
Loading