From 87b811f7169282aec0631fec5fe7f84c4f1f3497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Wed, 12 Apr 2023 02:10:33 +0200 Subject: [PATCH] client id can be anything --- .../structure/20230412_0208_oauth_client_id_longer.sql | 2 ++ src/Cli/AddOAuthClientCommand.php | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 database/migrations/structure/20230412_0208_oauth_client_id_longer.sql diff --git a/database/migrations/structure/20230412_0208_oauth_client_id_longer.sql b/database/migrations/structure/20230412_0208_oauth_client_id_longer.sql new file mode 100644 index 0000000..e229b98 --- /dev/null +++ b/database/migrations/structure/20230412_0208_oauth_client_id_longer.sql @@ -0,0 +1,2 @@ +ALTER TABLE `oauth_clients` +MODIFY `client_id` varchar(255) CHARACTER SET ascii COLLATE ascii_bin NOT NULL; diff --git a/src/Cli/AddOAuthClientCommand.php b/src/Cli/AddOAuthClientCommand.php index 9e1d329..21461e4 100644 --- a/src/Cli/AddOAuthClientCommand.php +++ b/src/Cli/AddOAuthClientCommand.php @@ -14,12 +14,13 @@ class AddOAuthClientCommand extends Command { $this->setName('oauth:add-client') ->setDescription('Adding of OAuth client.') + ->addArgument('client-id', InputArgument::OPTIONAL, 'Client ID') ->addArgument('preapproved', InputArgument::OPTIONAL, 'Preapproved'); } public function execute(InputInterface $input, OutputInterface $output): int { - $clientId = bin2hex(random_bytes(8)); + $clientId = $input->getArgument('client-id') ? $input->getArgument('client-id') : bin2hex(random_bytes(8)); $clientSecret = bin2hex(random_bytes(20)); $oAuthClient = new OAuthClient(); @@ -27,7 +28,7 @@ class AddOAuthClientCommand extends Command $oAuthClient->setClientSecret($clientSecret); $oAuthClient->setCreatedDate(new DateTime()); - if ($input->hasArgument('preapproved') && $input->getArgument('preapproved')) { + if ($input->getArgument('preapproved')) { $oAuthClient->setPreapproved($input->getArgument('preapproved')); }