summaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-09-01 07:01:20 +0200
committerByron Jones <glob@mozilla.com>2015-09-01 07:01:20 +0200
commit421ff7f194875db9634ea783d9dd5b6111f19df3 (patch)
tree5806e9f3001fa4f33ba85aa94856b70a7f878cf8 /Bugzilla/WebService
parentbcc93f83a64a76cd73501eaefaf5fd073fbc3f0d (diff)
downloadbugzilla-421ff7f194875db9634ea783d9dd5b6111f19df3.tar.gz
bugzilla-421ff7f194875db9634ea783d9dd5b6111f19df3.tar.xz
Bug 1197073 - add support for 2fa using totp (eg. google authenticator)
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__