mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
return attachments from API
This commit is contained in:
@ -22,6 +22,7 @@ namespace Bit.Api.Controllers
|
||||
private readonly IUserService _userService;
|
||||
private readonly IAttachmentStorageService _attachmentStorageService;
|
||||
private readonly CurrentContext _currentContext;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
public CiphersController(
|
||||
ICipherRepository cipherRepository,
|
||||
@ -29,7 +30,8 @@ namespace Bit.Api.Controllers
|
||||
ICipherService cipherService,
|
||||
IUserService userService,
|
||||
IAttachmentStorageService attachmentStorageService,
|
||||
CurrentContext currentContext)
|
||||
CurrentContext currentContext,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
_cipherRepository = cipherRepository;
|
||||
_collectionCipherRepository = collectionCipherRepository;
|
||||
@ -37,6 +39,7 @@ namespace Bit.Api.Controllers
|
||||
_userService = userService;
|
||||
_attachmentStorageService = attachmentStorageService;
|
||||
_currentContext = currentContext;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
@ -49,7 +52,7 @@ namespace Bit.Api.Controllers
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
return new CipherResponseModel(cipher);
|
||||
return new CipherResponseModel(cipher, _globalSettings);
|
||||
}
|
||||
|
||||
[HttpGet("{id}/full-details")]
|
||||
@ -65,7 +68,7 @@ namespace Bit.Api.Controllers
|
||||
}
|
||||
|
||||
var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdCipherIdAsync(userId, cipherId);
|
||||
return new CipherDetailsResponseModel(cipher, collectionCiphers);
|
||||
return new CipherDetailsResponseModel(cipher, _globalSettings, collectionCiphers);
|
||||
}
|
||||
|
||||
[HttpGet("")]
|
||||
@ -73,7 +76,7 @@ namespace Bit.Api.Controllers
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var ciphers = await _cipherRepository.GetManyByUserIdAsync(userId);
|
||||
var responses = ciphers.Select(c => new CipherResponseModel(c)).ToList();
|
||||
var responses = ciphers.Select(c => new CipherResponseModel(c, _globalSettings)).ToList();
|
||||
return new ListResponseModel<CipherResponseModel>(responses);
|
||||
}
|
||||
|
||||
@ -86,7 +89,7 @@ namespace Bit.Api.Controllers
|
||||
var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(userId);
|
||||
var collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
|
||||
|
||||
var responses = ciphers.Select(c => new CipherDetailsResponseModel(c, collectionCiphersGroupDict));
|
||||
var responses = ciphers.Select(c => new CipherDetailsResponseModel(c, _globalSettings, collectionCiphersGroupDict));
|
||||
return new ListResponseModel<CipherDetailsResponseModel>(responses);
|
||||
}
|
||||
|
||||
@ -105,7 +108,8 @@ namespace Bit.Api.Controllers
|
||||
var collectionCiphers = await _collectionCipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);
|
||||
var collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
|
||||
|
||||
var responses = ciphers.Select(c => new CipherMiniDetailsResponseModel(c, collectionCiphersGroupDict));
|
||||
var responses = ciphers.Select(c => new CipherMiniDetailsResponseModel(c, _globalSettings,
|
||||
collectionCiphersGroupDict));
|
||||
return new ListResponseModel<CipherMiniDetailsResponseModel>(responses);
|
||||
}
|
||||
|
||||
@ -228,6 +232,11 @@ namespace Bit.Api.Controllers
|
||||
throw new BadRequestException("Invalid content.");
|
||||
}
|
||||
|
||||
if(Request.ContentLength > 105906176) // 101 MB, give em' 1 extra MB for cushion
|
||||
{
|
||||
throw new BadRequestException("Max file size is 100 MB.");
|
||||
}
|
||||
|
||||
var idGuid = new Guid(id);
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var cipher = await _cipherRepository.GetByIdAsync(idGuid, userId);
|
||||
|
@ -21,17 +21,20 @@ namespace Bit.Api.Controllers
|
||||
private readonly ICipherService _cipherService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly CurrentContext _currentContext;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
public LoginsController(
|
||||
ICipherRepository cipherRepository,
|
||||
ICipherService cipherService,
|
||||
IUserService userService,
|
||||
CurrentContext currentContext)
|
||||
CurrentContext currentContext,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
_cipherRepository = cipherRepository;
|
||||
_cipherService = cipherService;
|
||||
_userService = userService;
|
||||
_currentContext = currentContext;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
@ -44,7 +47,7 @@ namespace Bit.Api.Controllers
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
var response = new LoginResponseModel(login);
|
||||
var response = new LoginResponseModel(login, _globalSettings);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -58,7 +61,7 @@ namespace Bit.Api.Controllers
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
var response = new LoginResponseModel(login);
|
||||
var response = new LoginResponseModel(login, _globalSettings);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -67,7 +70,7 @@ namespace Bit.Api.Controllers
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var logins = await _cipherRepository.GetManyByTypeAndUserIdAsync(Core.Enums.CipherType.Login, userId);
|
||||
var responses = logins.Select(l => new LoginResponseModel(l)).ToList();
|
||||
var responses = logins.Select(l => new LoginResponseModel(l, _globalSettings)).ToList();
|
||||
return new ListResponseModel<LoginResponseModel>(responses);
|
||||
}
|
||||
|
||||
@ -78,7 +81,7 @@ namespace Bit.Api.Controllers
|
||||
var login = model.ToCipherDetails(userId);
|
||||
await _cipherService.SaveDetailsAsync(login, userId);
|
||||
|
||||
var response = new LoginResponseModel(login);
|
||||
var response = new LoginResponseModel(login, _globalSettings);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -94,7 +97,7 @@ namespace Bit.Api.Controllers
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
await _cipherService.SaveAsync(login, userId, true);
|
||||
|
||||
var response = new LoginResponseModel(login);
|
||||
var response = new LoginResponseModel(login, _globalSettings);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -118,7 +121,7 @@ namespace Bit.Api.Controllers
|
||||
|
||||
await _cipherService.SaveDetailsAsync(model.ToCipherDetails(login), userId);
|
||||
|
||||
var response = new LoginResponseModel(login);
|
||||
var response = new LoginResponseModel(login, _globalSettings);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -136,7 +139,7 @@ namespace Bit.Api.Controllers
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
await _cipherService.SaveAsync(model.ToCipher(login), userId, true);
|
||||
|
||||
var response = new LoginResponseModel(login);
|
||||
var response = new LoginResponseModel(login, _globalSettings);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
},
|
||||
"attachment": {
|
||||
"connectionString": "SECRET",
|
||||
"baseUrl": "http://localhost:4000/"
|
||||
"baseUrl": "http://localhost:4000/attachments/"
|
||||
},
|
||||
"documentDb": {
|
||||
"uri": "SECRET",
|
||||
|
@ -7,7 +7,7 @@
|
||||
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
|
||||
<security>
|
||||
<requestFiltering>
|
||||
<requestLimits maxQueryString="5120"/>
|
||||
<requestLimits maxQueryString="5120" maxAllowedContentLength="105906176"/>
|
||||
</requestFiltering>
|
||||
</security>
|
||||
</system.webServer>
|
||||
|
Reference in New Issue
Block a user