mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
configure duo 2fa
This commit is contained in:
@ -77,8 +77,7 @@ namespace Bit.Api.Controllers
|
||||
|
||||
[HttpPut("yubikey")]
|
||||
[HttpPost("yubikey")]
|
||||
public async Task<TwoFactorYubiKeyResponseModel> PutYubiKey(
|
||||
[FromBody]UpdateTwoFactorYubicoOtpRequestModel model)
|
||||
public async Task<TwoFactorYubiKeyResponseModel> PutYubiKey([FromBody]UpdateTwoFactorYubicoOtpRequestModel model)
|
||||
{
|
||||
var user = await CheckPasswordAsync(model.MasterPasswordHash);
|
||||
model.ToUser(user);
|
||||
@ -94,6 +93,25 @@ namespace Bit.Api.Controllers
|
||||
return response;
|
||||
}
|
||||
|
||||
[HttpPost("get-duo")]
|
||||
public async Task<TwoFactorDuoResponseModel> GetDuo([FromBody]TwoFactorRequestModel model)
|
||||
{
|
||||
var user = await CheckPasswordAsync(model.MasterPasswordHash);
|
||||
var response = new TwoFactorDuoResponseModel(user);
|
||||
return response;
|
||||
}
|
||||
|
||||
[HttpPut("duo")]
|
||||
[HttpPost("duo")]
|
||||
public async Task<TwoFactorDuoResponseModel> PutDuo([FromBody]UpdateTwoFactorDuoRequestModel model)
|
||||
{
|
||||
var user = await CheckPasswordAsync(model.MasterPasswordHash);
|
||||
model.ToUser(user);
|
||||
await _userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.Duo);
|
||||
var response = new TwoFactorDuoResponseModel(user);
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task ValidateYubiKeyAsync(User user, string name, string value)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(value) || value.Length == 12)
|
||||
@ -148,12 +166,11 @@ namespace Bit.Api.Controllers
|
||||
|
||||
[HttpPut("disable")]
|
||||
[HttpPost("disable")]
|
||||
public async Task<TwoFactorEmailResponseModel> PutDisable([FromBody]TwoFactorProviderRequestModel model)
|
||||
public async Task<TwoFactorProviderResponseModel> PutDisable([FromBody]TwoFactorProviderRequestModel model)
|
||||
{
|
||||
var user = await CheckPasswordAsync(model.MasterPasswordHash);
|
||||
await _userService.DisableTwoFactorProviderAsync(user, model.Type.Value);
|
||||
|
||||
var response = new TwoFactorEmailResponseModel(user);
|
||||
var response = new TwoFactorProviderResponseModel(model.Type.Value, user);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user