@@ -179,6 +179,7 @@ protected function configure() {
179179 ->addOption ('clientid ' , 'c ' , InputOption::VALUE_REQUIRED , 'OpenID client identifier ' )
180180 ->addOption ('clientsecret ' , 's ' , InputOption::VALUE_REQUIRED , 'OpenID client secret ' )
181181 ->addOption ('discoveryuri ' , 'd ' , InputOption::VALUE_REQUIRED , 'OpenID discovery endpoint uri ' )
182+ ->addOption ('bearersecret ' , 'bs ' , InputOption::VALUE_OPTIONAL , 'Telekom bearer token requires a different client secret for bearer tokens ' )
182183 ->addOption ('endsessionendpointuri ' , 'e ' , InputOption::VALUE_REQUIRED , 'OpenID end session endpoint uri ' )
183184 ->addOption ('postlogouturi ' , 'p ' , InputOption::VALUE_REQUIRED , 'Post logout URI ' )
184185 ->addOption ('scope ' , 'o ' , InputOption::VALUE_OPTIONAL , 'OpenID requested value scopes, if not set defaults to "openid email profile" ' );
@@ -206,10 +207,17 @@ protected function execute(InputInterface $input, OutputInterface $output) {
206207 return $ this ->listProviders ($ input , $ output );
207208 }
208209
210+ // bearersecret is usually base64 encoded, but SAM delivers it non-encoded by default
211+ // so always encode/decode for this field
212+ $ bearersecret = $ input ->getOption ('bearersecret ' );
213+ if ($ bearersecret !== null ) {
214+ $ bearersecret = $ this ->crypto ->encrypt ($ this ->base64UrlEncode ($ bearersecret ));
215+ }
216+
209217 // check if any option for updating is provided
210218 $ updateOptions = array_filter ($ input ->getOptions (), static function ($ value , $ option ) {
211219 return in_array ($ option , [
212- 'identifier ' , 'clientid ' , 'clientsecret ' , 'discoveryuri ' , 'endsessionendpointuri ' , 'postlogouturi ' , 'scope ' ,
220+ 'identifier ' , 'clientid ' , 'clientsecret ' , 'discoveryuri ' , 'endsessionendpointuri ' , 'postlogouturi ' , 'scope ' , ' bearersecret ' ,
213221 ...array_keys (self ::EXTRA_OPTIONS ),
214222 ]) && $ value !== null ;
215223 }, ARRAY_FILTER_USE_BOTH );
@@ -250,7 +258,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
250258 }
251259 try {
252260 $ provider = $ this ->providerMapper ->createOrUpdateProvider (
253- $ identifier , $ clientid , $ clientsecret , $ discoveryuri , $ scope , $ endsessionendpointuri , $ postLogoutUri
261+ $ identifier , $ clientid , $ clientsecret , $ discoveryuri , $ scope , $ endsessionendpointuri , $ postLogoutUri, $ bearersecret
254262 );
255263 // invalidate JWKS cache (even if it was just created)
256264 $ this ->providerService ->setSetting ($ provider ->getId (), ProviderService::SETTING_JWKS_CACHE , '' );
@@ -306,4 +314,8 @@ private function listProviders(InputInterface $input, OutputInterface $output) {
306314 $ table ->render ();
307315 return 0 ;
308316 }
317+
318+ private function base64UrlEncode (string $ data ): string {
319+ return rtrim (strtr (base64_encode ($ data ), '+/ ' , '-_ ' ), '= ' );
320+ }
309321}
0 commit comments