From: dklawren Date: Tue, 9 Jun 2020 14:22:37 +0000 (-0400) Subject: Bug 1643821 - Add code to generate_conduit_data.pl to create an oauth2 client for... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f9aefce75ee065fee34641f5de99552386e2af7;p=thirdparty%2Fbugzilla.git Bug 1643821 - Add code to generate_conduit_data.pl to create an oauth2 client for Phabricator when used for development --- diff --git a/scripts/generate_conduit_data.pl b/scripts/generate_conduit_data.pl index 9764eb3c9..c1c63e2d3 100755 --- a/scripts/generate_conduit_data.pl +++ b/scripts/generate_conduit_data.pl @@ -177,6 +177,32 @@ set_params( ); set_push_connector_options(); +########################################################################## +# Create Phabricator OAuth2 Client +########################################################################## + +my $oauth_id = $ENV{PHABRICATOR_OAUTH_ID} || ''; +my $oauth_secret = $ENV{PHABRICATOR_OAUTH_SECRET} || ''; + +if ($oauth_id && $oauth_secret) { + print "creating phabricator oauth2 client...\n"; + + $dbh->do( + 'REPLACE INTO oauth2_client (client_id, description, secret) VALUES (?, \'Phabricator\', ?)', + undef, $oauth_id, $oauth_secret + ); + + my $client_data + = $dbh->selectrow_hashref('SELECT * FROM oauth2_client WHERE client_id = ?', + undef, $oauth_id); + + my $scope_id = $dbh->selectrow_array( + 'SELECT id FROM oauth2_scope WHERE description = \'user:read\'', undef); + + $dbh->do('REPLACE INTO oauth2_client_scope (client_id, scope_id) VALUES (?, ?)', + undef, $client_data->{id}, $scope_id); +} + print "installation and configuration complete!\n"; sub set_push_connector_options {