summaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/WebService')
-rw-r--r--Bugzilla/WebService/Server/REST/Resources/User.pm10
-rw-r--r--Bugzilla/WebService/User.pm14
2 files changed, 23 insertions, 1 deletions
diff --git a/Bugzilla/WebService/Server/REST/Resources/User.pm b/Bugzilla/WebService/Server/REST/Resources/User.pm
index badbc94b2..b9ecc21ba 100644
--- a/Bugzilla/WebService/Server/REST/Resources/User.pm
+++ b/Bugzilla/WebService/Server/REST/Resources/User.pm
@@ -58,7 +58,15 @@ sub _rest_resources {
return { $param => [ $_[0] ] };
}
}
- }
+ },
+ qr{^/user/mfa/([^/]+)/enroll$}, {
+ GET => {
+ method => 'mfa_enroll',
+ params => sub {
+ return { provider => $_[0] };
+ }
+ },
+ },
];
return $rest_resources;
}
diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm
index 8592d809c..2d3f5f185 100644
--- a/Bugzilla/WebService/User.pm
+++ b/Bugzilla/WebService/User.pm
@@ -416,6 +416,20 @@ sub _login_to_hash {
return $item;
}
+#
+# MFA
+#
+
+sub mfa_enroll {
+ my ($self, $params) = @_;
+ my $provider_name = lc($params->{provider});
+
+ my $user = Bugzilla->login(LOGIN_REQUIRED);
+ $user->set_mfa($provider_name);
+ my $provider = $user->mfa_provider // die "Unknown MTA provider\n";
+ return $provider->enroll();
+}
+
1;
__END__