|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LoginCidadao\OpenIDBundle\Form; |
|
12
|
|
|
|
|
13
|
|
|
use LoginCidadao\OpenIDBundle\Manager\ClientManager; |
|
14
|
|
|
use Symfony\Component\Form\AbstractType; |
|
15
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
16
|
|
|
use Symfony\Component\Form\FormEvent; |
|
17
|
|
|
use Symfony\Component\Form\FormEvents; |
|
18
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
19
|
|
|
|
|
20
|
|
|
class ClientMetadataForm extends AbstractType |
|
21
|
|
|
{ |
|
22
|
|
|
/** @var ClientManager */ |
|
23
|
|
|
private $clientManager; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @inheritDoc |
|
27
|
|
|
*/ |
|
28
|
4 |
|
public function __construct(ClientManager $clientManager) |
|
29
|
|
|
{ |
|
30
|
4 |
|
$this->clientManager = $clientManager; |
|
31
|
4 |
|
} |
|
32
|
|
|
|
|
33
|
1 |
|
public function buildForm(FormBuilderInterface $builder, array $options) |
|
34
|
|
|
{ |
|
35
|
|
|
$builder |
|
36
|
1 |
|
->add('client_id') |
|
37
|
1 |
|
->add('client_secret') |
|
38
|
1 |
|
->add('redirect_uris') |
|
39
|
1 |
|
->add('post_logout_redirect_uris') |
|
40
|
1 |
|
->add('response_types') |
|
41
|
1 |
|
->add('grant_types') |
|
42
|
1 |
|
->add('application_type') |
|
43
|
1 |
|
->add('contacts') |
|
44
|
1 |
|
->add('client_name') |
|
45
|
1 |
|
->add('logo_uri', 'text') |
|
46
|
1 |
|
->add('client_uri', 'text') |
|
47
|
1 |
|
->add('policy_uri', 'text') |
|
48
|
1 |
|
->add('tos_uri', 'text') |
|
49
|
1 |
|
->add('jwks_uri') |
|
50
|
1 |
|
->add('jwks') |
|
51
|
1 |
|
->add('sector_identifier_uri', 'text') |
|
52
|
1 |
|
->add('subject_type') |
|
53
|
1 |
|
->add('id_token_signed_response_alg') |
|
54
|
1 |
|
->add('id_token_encrypted_response_alg') |
|
55
|
1 |
|
->add('id_token_encrypted_response_enc') |
|
56
|
1 |
|
->add('userinfo_signed_response_alg') |
|
57
|
1 |
|
->add('userinfo_encrypted_response_alg') |
|
58
|
1 |
|
->add('userinfo_encrypted_response_enc') |
|
59
|
1 |
|
->add('request_object_signing_alg') |
|
60
|
1 |
|
->add('request_object_encryption_alg') |
|
61
|
1 |
|
->add('request_object_encryption_enc') |
|
62
|
1 |
|
->add('token_endpoint_auth_method') |
|
63
|
1 |
|
->add('token_endpoint_auth_signing_alg') |
|
64
|
1 |
|
->add('default_max_age') |
|
65
|
1 |
|
->add('require_auth_time') |
|
66
|
1 |
|
->add('default_acr_values') |
|
67
|
1 |
|
->add('initiate_login_uri', 'text') |
|
68
|
1 |
|
->add('request_uris') |
|
69
|
1 |
|
->addEventListener(FormEvents::SUBMIT, [$this, 'onSubmit']); |
|
70
|
1 |
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
public function configureOptions(OptionsResolver $resolver) |
|
73
|
|
|
{ |
|
74
|
1 |
|
parent::configureOptions($resolver); |
|
75
|
1 |
|
$resolver->setDefaults([ |
|
76
|
1 |
|
'data_class' => 'LoginCidadao\OpenIDBundle\Entity\ClientMetadata', |
|
77
|
|
|
'csrf_protection' => false, |
|
78
|
|
|
]); |
|
79
|
1 |
|
} |
|
80
|
|
|
|
|
81
|
1 |
|
public function onSubmit(FormEvent $event) |
|
82
|
|
|
{ |
|
83
|
1 |
|
$data = $this->clientManager->populateNewMetadata($event->getData()); |
|
84
|
|
|
|
|
85
|
1 |
|
$event->setData($data); |
|
86
|
1 |
|
} |
|
87
|
|
|
|
|
88
|
1 |
|
public function getName() |
|
89
|
|
|
{ |
|
90
|
1 |
|
return ''; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|