|
17 | 17 | namespace SimpleSAML\Module\oidc\Forms; |
18 | 18 |
|
19 | 19 | use Nette\Forms\Form; |
20 | | -use SimpleSAML\Auth\Source; |
21 | 20 | use SimpleSAML\Locale\Translate; |
| 21 | +use SimpleSAML\Module\oidc\Bridges\SspBridge; |
22 | 22 | use SimpleSAML\Module\oidc\Forms\Controls\CsrfProtection; |
23 | 23 | use SimpleSAML\Module\oidc\ModuleConfig; |
24 | 24 | use SimpleSAML\OpenID\Codebooks\ClientRegistrationTypesEnum; |
@@ -58,8 +58,11 @@ class ClientForm extends Form |
58 | 58 | /** |
59 | 59 | * @throws \Exception |
60 | 60 | */ |
61 | | - public function __construct(private readonly ModuleConfig $moduleConfig, protected CsrfProtection $csrfProtection) |
62 | | - { |
| 61 | + public function __construct( |
| 62 | + protected readonly ModuleConfig $moduleConfig, |
| 63 | + protected CsrfProtection $csrfProtection, |
| 64 | + protected SspBridge $sspBridge, |
| 65 | + ) { |
63 | 66 | parent::__construct(); |
64 | 67 |
|
65 | 68 | $this->buildForm(); |
@@ -315,6 +318,14 @@ public function setDefaults(object|array $data, bool $erase = false): static |
315 | 318 |
|
316 | 319 | $data['jwks'] = is_array($data['jwks']) ? json_encode($data['jwks']) : null; |
317 | 320 |
|
| 321 | + if ( |
| 322 | + $data['auth_source'] !== null && |
| 323 | + (!in_array($data['auth_source'], $this->sspBridge->auth()->source()->getSources())) |
| 324 | + ) { |
| 325 | + // Possible auth source name change without prior update in clients, resetting. |
| 326 | + $data['auth_source'] = null; |
| 327 | + } |
| 328 | + |
318 | 329 | parent::setDefaults($data, $erase); |
319 | 330 |
|
320 | 331 | return $this; |
@@ -355,10 +366,9 @@ protected function buildForm(): void |
355 | 366 |
|
356 | 367 | $this->addCheckbox('is_confidential', '{oidc:client:is_confidential}'); |
357 | 368 |
|
358 | | - // TODO mivanci Source::getSource() move to SSP Bridge. |
359 | 369 | $this->addSelect('auth_source', '{oidc:client:auth_source}:') |
360 | 370 | ->setHtmlAttribute('class', 'full-width') |
361 | | - ->setItems(Source::getSources(), false) |
| 371 | + ->setItems($this->sspBridge->auth()->source()->getSources(), false) |
362 | 372 | ->setPrompt(Translate::noop('-')); |
363 | 373 |
|
364 | 374 | $scopes = $this->getScopes(); |
|
0 commit comments