mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
feat: added basic auth (#60)
* some small css fixes and changes * added basic auth https://stackoverflow.com/a/9534652/3642588 * most tests are passing * fixed all the tests * maybe now CI will pass * implemented sigoden's suggestions * test basic auth * fixed some little things
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use crate::auth::generate_www_auth;
|
||||
use crate::streamer::Streamer;
|
||||
use crate::utils::{decode_uri, encode_uri};
|
||||
use crate::{Args, BoxResult};
|
||||
@@ -96,7 +95,12 @@ impl Server {
|
||||
}
|
||||
|
||||
let authorization = headers.get(AUTHORIZATION);
|
||||
let guard_type = self.args.auth.guard(req_path, &method, authorization);
|
||||
let guard_type = self.args.auth.guard(
|
||||
req_path,
|
||||
&method,
|
||||
authorization,
|
||||
self.args.auth_method.clone(),
|
||||
);
|
||||
if guard_type.is_reject() {
|
||||
self.auth_reject(&mut res);
|
||||
return Ok(res);
|
||||
@@ -720,7 +724,7 @@ const DATA =
|
||||
}
|
||||
|
||||
fn auth_reject(&self, res: &mut Response) {
|
||||
let value = generate_www_auth(false);
|
||||
let value = self.args.auth_method.www_auth(false);
|
||||
set_webdav_headers(res);
|
||||
res.headers_mut().typed_insert(Connection::close());
|
||||
res.headers_mut()
|
||||
|
||||
Reference in New Issue
Block a user