@@ -66,11 +66,17 @@ public function buildForm(array $form, FormStateInterface $form_state): array {
6666 '#description ' => $ this ->t ('Check this to generate a new random secret ' ),
6767 ];
6868
69- $ form ['token_param_name ' ] = [
69+ $ form ['payload_name ' ] = [
7070 '#type ' => 'textfield ' ,
71- '#title ' => $ this ->t ('Token param name ' ),
72- '#default_value ' => $ config ->get ('token_param_name ' ),
73- '#description ' => $ this ->t ('Query string param name used for JWT token on GET request ' ),
71+ '#title ' => $ this ->t ('Payload name ' ),
72+ '#default_value ' => $ config ->get ('payload_name ' ) ?? 'payload ' ,
73+ '#description ' => $ this ->t ('Name of parameter used for payload ' ),
74+ ];
75+
76+ $ form ['jwt_leeway ' ] = [
77+ '#type ' => 'textfield ' ,
78+ '#title ' => $ this ->t ('JWT leeway ' ),
79+ '#default_value ' => $ config ->get ('jwt_leeway ' ) ?? 0 ,
7480 ];
7581
7682 $ form ['log_level ' ] = [
@@ -80,42 +86,31 @@ public function buildForm(array $form, FormStateInterface $form_state): array {
8086 '#default_value ' => $ config ->get ('log_level ' ) ?? RfcLogLevel::ERROR ,
8187 ];
8288
83- $ authenticationStartUrl = Url::fromRoute ('os2loop_cura_login.start ' )->setAbsolute ()->toString (true )->getGeneratedUrl ();
89+ $ authenticationStartUrl = Url::fromRoute ('os2loop_cura_login.start ' )->setAbsolute ()->toString (TRUE )->getGeneratedUrl ();
8490 $ form ['info ' ] = [
8591 '#theme ' => 'item_list ' ,
8692 '#items ' => [
87- '#markup ' => $ this ->t ('Use <a href=":url">:url</a> as <code>linkURL</code>. ' , [':url ' => $ authenticationStartUrl ]),
93+ '#markup ' => $ this ->t ('Use <a href=":url">:url</a> as <code>linkURL</code> for <code>postToGetLinkURL ≡ true</code> . ' , [':url ' => $ authenticationStartUrl ]),
8894 ],
8995 ];
9096
91- if ($ name = $ config ->get ('token_param_name ' )) {
92- $ authenticationStartUrl = Url::fromRoute ('os2loop_cura_login.start ' , [$ name => '… ' ])->setAbsolute ()->toString (true )->getGeneratedUrl ();
93- $ authenticationStartUrl = str_replace (urlencode ('… ' ), '… ' , $ authenticationStartUrl );
97+ $ authenticationStartUrl = Url::fromRoute ('os2loop_cura_login.start ' , [])->setAbsolute ()->toString (TRUE )->getGeneratedUrl ();
98+ $ authenticationStartUrl = rtrim ($ authenticationStartUrl , '/ ' ) . '/ ' ;
99+ $ form ['info ' ]['#items ' ][] = [
100+ '#markup ' => $ this ->t ('Use <a href=":url">:url</a> as <code>linkURL</code> for <core><code>postToGetLinkURL ≡ false</code>. ' , [':url ' => $ authenticationStartUrl ]),
101+ ];
102+
103+ if ($ name = $ config ->get ('payload_name ' )) {
104+ $ authenticationStartUrl = Url::fromRoute ('os2loop_cura_login.start ' , [$ name => '… ' ])->setAbsolute ()->toString (TRUE )->getGeneratedUrl ();
105+ $ authenticationStartUrl = str_replace (urlencode ('… ' ), '' , $ authenticationStartUrl );
94106 $ form ['info ' ]['#items ' ][] = [
95- '#markup ' => $ this ->t ('Use <a href=":url">:url</a> as <code>linkURL</code> for <core>GET</core >. ' , [':url ' => $ authenticationStartUrl ]),
107+ '#markup ' => $ this ->t ('Use <a href=":url">:url</a> as <code>linkURL</code> for <core><code>postToGetLinkURL ≡ false</code >. ' , [':url ' => $ authenticationStartUrl ]),
96108 ];
97109 }
98110
99111 return parent ::buildForm ($ form , $ form_state );
100112 }
101113
102- /**
103- * {@inheritdoc}
104- */
105- public function validateForm (array &$ form , FormStateInterface $ form_state ): void {
106- // @todo Validate the form here.
107- // Example:
108- // @code
109- // if ($form_state->getValue('example') === 'wrong') {
110- // $form_state->setErrorByName(
111- // 'message',
112- // $this->t('The value is not correct.'),
113- // );
114- // }
115- // @endcode
116- parent ::validateForm ($ form , $ form_state );
117- }
118-
119114 /**
120115 * {@inheritdoc}
121116 */
@@ -127,7 +122,8 @@ public function submitForm(array &$form, FormStateInterface $form_state): void {
127122 $ this ->config ('os2loop_cura_login.settings ' )
128123 ->set ('signing_algorithm ' , $ form_state ->getValue ('signing_algorithm ' ))
129124 ->set ('signing_secret ' , $ secret )
130- ->set ('token_param_name ' , $ form_state ->getValue ('token_param_name ' ))
125+ ->set ('payload_name ' , $ form_state ->getValue ('payload_name ' ))
126+ ->set ('jwt_leeway ' , $ form_state ->getValue ('jwt_leeway ' ))
131127 ->set ('log_level ' , $ form_state ->getValue ('log_level ' ))
132128 ->save ();
133129 parent ::submitForm ($ form , $ form_state );
0 commit comments