vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit cb6f3927745b8f5feb69662fe7aa2b355c818612
parent 5c6081c4e2d287687a1be185306f6131fca33b4c
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Sat, 28 Dec 2019 15:08:17 +0100

When receiving a comma separated list as IP, pick the first

Diffstat:
Msrc/auth.rs | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/auth.rs b/src/auth.rs @@ -429,9 +429,13 @@ impl<'a, 'r> FromRequest<'a, 'r> for ClientIp { fn from_request(req: &'a Request<'r>) -> request::Outcome<Self, Self::Error> { let ip = if CONFIG._ip_header_enabled() { req.headers().get_one(&CONFIG.ip_header()).and_then(|ip| { - ip.parse() - .map_err(|_| warn_!("'{}' header is malformed: {}", CONFIG.ip_header(), ip)) - .ok() + match ip.find(',') { + Some(idx) => &ip[..idx], + None => ip, + } + .parse() + .map_err(|_| warn!("'{}' header is malformed: {}", CONFIG.ip_header(), ip)) + .ok() }) } else { None