public async Task <TwoFactorDuoResponseModel> PutOrganizationDuo(string id, [FromBody] UpdateTwoFactorDuoRequestModel model) { var user = await CheckAsync(model.MasterPasswordHash, false); var orgIdGuid = new Guid(id); if (!_currentContext.OrganizationAdmin(orgIdGuid)) { throw new NotFoundException(); } var organization = await _organizationRepository.GetByIdAsync(orgIdGuid); if (organization == null) { throw new NotFoundException(); } model.ToOrganization(organization); await _organizationService.UpdateTwoFactorProviderAsync(organization, TwoFactorProviderType.OrganizationDuo); var response = new TwoFactorDuoResponseModel(organization); return(response); }
public async Task <TwoFactorDuoResponseModel> GetDuo([FromBody] TwoFactorRequestModel model) { var user = await CheckAsync(model.MasterPasswordHash, true); var response = new TwoFactorDuoResponseModel(user); return(response); }
public async Task <TwoFactorDuoResponseModel> GetDuo([FromBody] SecretVerificationRequestModel model) { var user = await CheckAsync(model, true); var response = new TwoFactorDuoResponseModel(user); return(response); }
public async Task <TwoFactorDuoResponseModel> PutDuo([FromBody] UpdateTwoFactorDuoRequestModel model) { var user = await CheckAsync(model.MasterPasswordHash, true); model.ToUser(user); await _userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.Duo); var response = new TwoFactorDuoResponseModel(user); return(response); }
public async Task <TwoFactorDuoResponseModel> PutDuo([FromBody] UpdateTwoFactorDuoRequestModel model) { var user = await CheckAsync(model.MasterPasswordHash, true); try { var duoApi = new DuoApi(model.IntegrationKey, model.SecretKey, model.Host); duoApi.JSONApiCall <object>("GET", "/auth/v2/check"); } catch (DuoException) { throw new BadRequestException("Duo configuration settings are not valid. Please re-check the Duo Admin panel."); } model.ToUser(user); await _userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.Duo); var response = new TwoFactorDuoResponseModel(user); return(response); }
public async Task <TwoFactorDuoResponseModel> GetOrganizationDuo(string id, [FromBody] TwoFactorRequestModel model) { var user = await CheckAsync(model.MasterPasswordHash, false); var orgIdGuid = new Guid(id); if (!_currentContext.ManagePolicies(orgIdGuid)) { throw new NotFoundException(); } var organization = await _organizationRepository.GetByIdAsync(orgIdGuid); if (organization == null) { throw new NotFoundException(); } var response = new TwoFactorDuoResponseModel(organization); return(response); }
public async Task <TwoFactorDuoResponseModel> PutOrganizationDuo(string id, [FromBody] UpdateTwoFactorDuoRequestModel model) { var user = await CheckAsync(model.MasterPasswordHash, false); var orgIdGuid = new Guid(id); if (!_currentContext.ManagePolicies(orgIdGuid)) { throw new NotFoundException(); } var organization = await _organizationRepository.GetByIdAsync(orgIdGuid); if (organization == null) { throw new NotFoundException(); } try { var duoApi = new DuoApi(model.IntegrationKey, model.SecretKey, model.Host); duoApi.JSONApiCall <object>("GET", "/auth/v2/check"); } catch (DuoException) { throw new BadRequestException("Duo configuration settings are not valid. Please re-check the Duo Admin panel."); } model.ToOrganization(organization); await _organizationService.UpdateTwoFactorProviderAsync(organization, TwoFactorProviderType.OrganizationDuo); var response = new TwoFactorDuoResponseModel(organization); return(response); }