rustic-rs / rustic_server

A REST server built in rust for use with rustic/restic
https://rustic.cli.rs/ecosystem/rustic-server/
GNU Affero General Public License v3.0
18 stars 2 forks source link

htpasswd auth not working? #41

Open ipl31 opened 10 months ago

ipl31 commented 10 months ago

Summary

This may be a documentation issue and I am not configuring properly or could be a bug not sure.

I am testing out the rest server. In attempting to run it with basic HTTP auth. I noticed the code expected an .htpasswd in the base of the data directory. I created an htpasswd file using the htpasswd program and installed it in the data directory. When running a backup with the rest endpoint as the repo I never get prompted for authentication.

What happens:

Server accepts create repo command and backup requests but never prompts for basic auth.

What I execpted to happen:

I expected I would need to enter user/pass from the rustic backup cli when creating a repo and backing up the repo to the rest server.

Details

Build: rustic-server nightly as of yesterday (1/21/2024). rest server cli:

rustic-server-x86_64-unknown-linux-musl/rustic-server -l 0.0.0.0:8000 -p /home/ipl31/data/rustic-server-repos/ --acl data/rustic-acl.toml

htpasswd contents:

ipl31:REDACTED

acl toml file:

cat data/rustic-acl.toml 
[default]
ipl31 = "Modify"

rest server data dir:

ls -la data/rustic-server-repos/
total 20
drwxr--r-- 4 ipl31 ipl31 4096 Jan 22 09:24 .
drwxr-x--- 6 ipl31 ipl31 4096 Jan 22 09:23 ..
-rwxr--r-- 1 ipl31 ipl31   44 Jan 22 08:21 .htpasswd
drwxr-xr-x 7 ipl31 ipl31 4096 Jan 22 09:19 test_repo
drwxr-xr-x 7 ipl31 ipl31 4096 Jan 22 09:24 test_repo2
simonsan commented 10 months ago

We are currently undergoing a big refactoring due to moving to axum in #40 / #42.

It would be nice if you would try out rustic-server again afterwards, to see if it is fixed.

aawsome commented 10 months ago

About the current version: can you run with --log=debug and post the output?

ipl31 commented 10 months ago

@aawsome

drwxr--r-- 4 ipl31 ipl31 4096 Jan 22 09:24 .
drwxr-x--- 6 ipl31 ipl31 4096 Jan 22 09:23 ..
-rwxr--r-- 1 ipl31 ipl31   44 Jan 22 08:21 .htpasswd
drwxr-xr-x 7 ipl31 ipl31 4096 Jan 22 09:19 test_repo
drwxr-xr-x 7 ipl31 ipl31 4096 Jan 22 09:24 test_repo2
rustic-server-x86_64-unknown-linux-musl/rustic-server --log debug -l 0.0.0.0:8000 -p /home/ipl31/data/rustic-server-repos/
{"level":30,"time":1706466985456,"msg":"Logger started","level":"DEBUG"}
{"level":20,"time":1706466985456,"msg":"add path: /data/"}
{"level":20,"time":1706466985456,"msg":"add path: /data/:name"}
{"level":20,"time":1706466985456,"msg":"add path: /:path/data/"}
{"level":20,"time":1706466985456,"msg":"add path: /:path/data/:name"}
{"level":20,"time":1706466985456,"msg":"add path: /keys/"}
{"level":20,"time":1706466985456,"msg":"add path: /keys/:name"}
{"level":20,"time":1706466985456,"msg":"add path: /:path/keys/"}
{"level":20,"time":1706466985456,"msg":"add path: /:path/keys/:name"}
{"level":20,"time":1706466985456,"msg":"add path: /locks/"}
{"level":20,"time":1706466985456,"msg":"add path: /locks/:name"}
{"level":20,"time":1706466985456,"msg":"add path: /:path/locks/"}
{"level":20,"time":1706466985456,"msg":"add path: /:path/locks/:name"}
{"level":20,"time":1706466985456,"msg":"add path: /snapshots/"}
{"level":20,"time":1706466985456,"msg":"add path: /snapshots/:name"}
{"level":20,"time":1706466985456,"msg":"add path: /:path/snapshots/"}
{"level":20,"time":1706466985456,"msg":"add path: /:path/snapshots/:name"}
{"level":20,"time":1706466985456,"msg":"add path: /index/"}
{"level":20,"time":1706466985456,"msg":"add path: /index/:name"}
{"level":20,"time":1706466985457,"msg":"add path: /:path/index/"}
{"level":20,"time":1706466985457,"msg":"add path: /:path/index/:name"}
{"level":30,"time":1706466985457,"msg":"Server listening on http://0.0.0.0:8000"}
{"level":30,"time":1706467080137,"msg":"<-- Request received","method":"HEAD","path":"/test_repo/config"}
{"level":20,"time":1706467080137,"msg":"get_file","path":"test_repo","tpe":"config","name":""}
{"level":20,"time":1706467080137,"msg":"auth","user":"","path":"test_repo","tpe":"config","allowed":true}
{"level":30,"time":1706467080155,"msg":"--> Response sent","method":"HEAD","path":"/test_repo/config","status":"200 - OK","duration":"17.63404ms"}
{"level":30,"time":1706467080333,"msg":"<-- Request received","method":"GET","path":"/test_repo/keys/"}
{"level":20,"time":1706467080333,"msg":"list_files","path":"test_repo","tpe":"keys"}
{"level":20,"time":1706467080333,"msg":"auth","user":"","path":"test_repo","tpe":"keys","allowed":true}
{"level":30,"time":1706467080371,"msg":"--> Response sent","method":"GET","path":"/test_repo/keys/","status":"200 - OK","duration":"37.782889ms"}
{"level":30,"time":1706467080725,"msg":"<-- Request received","method":"GET","path":"/test_repo/keys/3c8f8949bdc0e586751b570c871063d0e70ff6a539e7f8725984e813c59b0c9e"}
{"level":20,"time":1706467080725,"msg":"get_file","path":"test_repo","tpe":"keys","name":"3c8f8949bdc0e586751b570c871063d0e70ff6a539e7f8725984e813c59b0c9e"}
{"level":20,"time":1706467080725,"msg":"auth","user":"","path":"test_repo","tpe":"keys","allowed":true}
{"level":30,"time":1706467080725,"msg":"--> Response sent","method":"GET","path":"/test_repo/keys/3c8f8949bdc0e586751b570c871063d0e70ff6a539e7f8725984e813c59b0c9e","status":"200 - OK","duration":"351.095µs"}
{"level":30,"time":1706467081592,"msg":"<-- Request received","method":"GET","path":"/test_repo/config"}
{"level":20,"time":1706467081592,"msg":"get_file","path":"test_repo","tpe":"config","name":""}
{"level":20,"time":1706467081592,"msg":"auth","user":"","path":"test_repo","tpe":"config","allowed":true}
{"level":30,"time":1706467081593,"msg":"--> Response sent","method":"GET","path":"/test_repo/config","status":"200 - OK","duration":"397.182µs"}
{"level":30,"time":1706467081970,"msg":"<-- Request received","method":"GET","path":"/test_repo/index/"}
{"level":20,"time":1706467081970,"msg":"list_files","path":"test_repo","tpe":"index"}
{"level":20,"time":1706467081970,"msg":"auth","user":"","path":"test_repo","tpe":"index","allowed":true}
{"level":30,"time":1706467081972,"msg":"--> Response sent","method":"GET","path":"/test_repo/index/","status":"200 - OK","duration":"1.501103ms"}
{"level":30,"time":1706467082399,"msg":"<-- Request received","method":"GET","path":"/test_repo/index/abaa195003cf07044b7eee17b4a2077106febe92844c43432ff5e4259a853338"}
{"level":20,"time":1706467082399,"msg":"get_file","path":"test_repo","tpe":"index","name":"abaa195003cf07044b7eee17b4a2077106febe92844c43432ff5e4259a853338"}
{"level":20,"time":1706467082399,"msg":"auth","user":"","path":"test_repo","tpe":"index","allowed":true}
{"level":30,"time":1706467082400,"msg":"--> Response sent","method":"GET","path":"/test_repo/index/abaa195003cf07044b7eee17b4a2077106febe92844c43432ff5e4259a853338","status":"200 - OK","duration":"390.199µs"}
{"level":30,"time":1706467082727,"msg":"<-- Request received","method":"GET","path":"/test_repo/index/e7a4f9d759d37dbe5e1df5201b65085fa92f82a43d434de1210487bf58a73e62"}
{"level":20,"time":1706467082727,"msg":"get_file","path":"test_repo","tpe":"index","name":"e7a4f9d759d37dbe5e1df5201b65085fa92f82a43d434de1210487bf58a73e62"}
{"level":20,"time":1706467082727,"msg":"auth","user":"","path":"test_repo","tpe":"index","allowed":true}
{"level":30,"time":1706467082727,"msg":"--> Response sent","method":"GET","path":"/test_repo/index/e7a4f9d759d37dbe5e1df5201b65085fa92f82a43d434de1210487bf58a73e62","status":"200 - OK","duration":"281.766µs"}
{"level":30,"time":1706467082728,"msg":"<-- Request received","method":"GET","path":"/test_repo/index/1feaabaa79a2b58eaf5c08a600294a19d0b78122b18ef8f03660fe353ffcd15a"}
{"level":20,"time":1706467082728,"msg":"get_file","path":"test_repo","tpe":"index","name":"1feaabaa79a2b58eaf5c08a600294a19d0b78122b18ef8f03660fe353ffcd15a"}
{"level":20,"time":1706467082728,"msg":"auth","user":"","path":"test_repo","tpe":"index","allowed":true}
{"level":30,"time":1706467082728,"msg":"--> Response sent","method":"GET","path":"/test_repo/index/1feaabaa79a2b58eaf5c08a600294a19d0b78122b18ef8f03660fe353ffcd15a","status":"200 - OK","duration":"318.25µs"}
{"level":30,"time":1706467083506,"msg":"<-- Request received","method":"GET","path":"/test_repo/snapshots/"}
{"level":20,"time":1706467083506,"msg":"list_files","path":"test_repo","tpe":"snapshots"}
{"level":20,"time":1706467083506,"msg":"auth","user":"","path":"test_repo","tpe":"snapshots","allowed":true}
{"level":30,"time":1706467083507,"msg":"--> Response sent","method":"GET","path":"/test_repo/snapshots/","status":"200 - OK","duration":"1.051235ms"}
{"level":30,"time":1706467084085,"msg":"<-- Request received","method":"POST","path":"/test_repo/snapshots/8c45319f87be23ed4a64a3abb686859ff683bde8f6b31708584daef43e74c987"}
{"level":20,"time":1706467084085,"msg":"get_save_file","path":"test_repo","tpe":"snapshots","name":"8c45319f87be23ed4a64a3abb686859ff683bde8f6b31708584daef43e74c987"}
{"level":20,"time":1706467084085,"msg":"auth","user":"","path":"test_repo","tpe":"snapshots","allowed":true}
{"level":20,"time":1706467084104,"msg":"file written","bytes":530}
{"level":30,"time":1706467084151,"msg":"--> Response sent","method":"POST","path":"/test_repo/snapshots/8c45319f87be23ed4a64a3abb686859ff683bde8f6b31708584daef43e74c987","status":"200 - OK","duration":"65.936036ms"}
simonsan commented 1 week ago

We just released a new version, can you try if this is fixed for you?

https://github.com/rustic-rs/rustic_server/releases/tag/v0.3.0