]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1368066 - When using bmo auth delegation from Phabricator, the confirmation shoul...
authorDavid Lawrence <dkl@mozilla.com>
Wed, 31 May 2017 23:09:52 +0000 (19:09 -0400)
committerDavid Lawrence <dkl@mozilla.com>
Wed, 31 May 2017 23:09:52 +0000 (19:09 -0400)
extensions/PhabBugz/Extension.pm
extensions/PhabBugz/lib/Config.pm
extensions/PhabBugz/template/en/default/admin/params/phabbugz.html.tmpl

index 501fbc65dda26b37ebcb99343d3c0b750b8c9c4f..1ba1609f587f6c05b1d33a9d260374461747a0fc 100644 (file)
@@ -20,4 +20,17 @@ sub config_add_panels {
     $modules->{PhabBugz} = "Bugzilla::Extension::PhabBugz::Config";
 }
 
+sub auth_delegation_confirm {
+    my ($self, $args) = @_;
+    my $phab_callback_url = Bugzilla->params->{phabricator_auth_callback_url};
+    my $phab_app_id       = Bugzilla->params->{phabricator_app_id};
+
+    return unless $phab_callback_url;
+    return unless $phab_app_id;
+
+    if (index($args->{callback}, $phab_callback_url) == 0 && $args->{app_id} eq $phab_app_id) {
+        ${$args->{skip_confirmation}} = 1;
+    }
+}
+
 __PACKAGE__->NAME;
index 686198a2574b18c8eab49e181c372701ad871d93..a0b7ef2e5ac4eb41e4d6ba5000bb534380f63b8f 100644 (file)
@@ -35,6 +35,26 @@ sub get_param_list {
             type => 't',
             default => '',
         },
+        {
+            name    => 'phabricator_auth_callback_url',
+            type    => 't',
+            default => '',
+            checker => sub {
+                my ($url) = (@_);
+                return 'must be an HTTP/HTTPS absolute URL' unless $url =~ m{^https?://};
+                return '';
+            }
+        },
+        {
+            name => 'phabricator_app_id',
+            type => 't',
+            default => '',
+            checker => sub {
+                my ($app_id) = (@_);
+                return 'must be a hex number' unless $app_id =~ /^[[:xdigit:]]+$/;
+                return '';
+            }
+        }
     );
 
     return @params;
index 922fcf7093005fb38d920c47963edd7c34abbac0..6eb16d993780a0938029a6286a18873f6a060f91 100644 (file)
@@ -16,5 +16,7 @@
      phabricator_base_uri    => 'Phabricator Base URI',
      phabricator_api_key     => 'Phabricator User API Key',
      phabricator_sync_groups => 'Comma delimited list of Bugzilla groups to sync to Phabricator projects',
+     phabricator_auth_callback_url => 'Phabricator Auth Delegation URL',
+     phabricator_app_id      => 'app_id for API Keys delegated to Phabricator',
    }
 %]