]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1643821 - Add code to generate_conduit_data.pl to create an oauth2 client for...
authordklawren <dklawren@users.noreply.github.com>
Tue, 9 Jun 2020 14:22:37 +0000 (10:22 -0400)
committerGitHub <noreply@github.com>
Tue, 9 Jun 2020 14:22:37 +0000 (10:22 -0400)
scripts/generate_conduit_data.pl

index 9764eb3c9c22d156396711b216b5caf65daedb27..c1c63e2d30f7f37d91aa98ac45b23a08e236469f 100755 (executable)
@@ -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 {