Kilerd/rubble

Seems cannot locate the templates folder

Closed this issue · 11 comments

Hi Kilerd,
I got an error like this when I was trying it on my Mac,

thread 'actix-rt:worker:0' panicked at 'called Result::unwrap() on an Err value: Error { kind: TemplateNotFound("homepage.html"), source: None }', src/libcore/result.rs:1188:5
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.
thread 'actix-rt:worker:1' panicked at 'called Result::unwrap() on an Err value: Error { kind: TemplateNotFound("homepage.html"), source: None }', src/libcore/result.rs:1188:5
thread 'actix-rt:worker:2' panicked at 'called Result::unwrap() on an Err value: Error { kind: TemplateNotFound("homepage.html"), source: None }', src/libcore/result.rs:1188:5
thread 'actix-rt:worker:3' panicked at 'called Result::unwrap() on an Err value: Error { kind: TemplateNotFound("homepage.html"), source: None }', src/libcore/result.rs:1188:5

It seems it cannot find the templates folder. Do I need to config env file or something else?
Thank you.

Did you run it in Docker or just in your mac barely? it seems that the application cannot find template homepage.html. could you please check whether the template is included in your templates folder?

Yes, all the html files are there.
I didn't use Docker, just created a .env file for the DATABASE_URL and ROCKET_SECRET_KEY. Maybe because I didn't config the backend properly?

sorry, I can't reproduce this issue on my own mac.
could you please print your rust version using rustc -Vv and rustup show, and project rubble folder's structure would be necessary using the command tree or some commands like that.
and please make sure you have the latest version of rubble and clean the cargo cache before running rubble.

I moved the Rubble folder out, from /Documents/GitHub/rubble to the users folder directly. Now it works.

But when I log in with admin/password, I get "{"message":"invalid jwt token"}". I've cleaned cookies, history, etc. Any idea?

Thank you.

for the api /admin/password, it is protected with JWT which can be provided by cookies or header.

if you are browsing the page in the browser, you must go to /admin for logging in which would detect your JWT automatically.
or if you are using api, before changing the password of admin, you can get the JWT from the API POST /user/token

the JWT authentication logic is in here, you can pass the JWT token in two ways:

  • Header named Authorization with value JWT YOUR_TOKEN_HERE
  • Cookie named Authorization with value YOUR_TOKEN_HERE

and the API POST /user/token would pass back the JWT in http reponse payload as JSON, login in /admin would store the JWT in Cookies.

Hi Kilerd, I'm trying to input the password in the browser on the admin/login page. The password seems correct. The cookie was created successfully and the browser was going to "admin/panel" page. but only showing a blank page with {"message":"invalid jwt token"}. I'm a little bit confused...

it seems that it fail to decode JWT token, you can set TOKEN_KEY to your .env file like that:

TOKEN_KEY=00000000000000000000000000000000

zero-token is very easy to reproduce issues.

if it occurs again, pls paste your JWT here, and I would try to reproduce it( PLEASE MAKE SURE YOU SET TOKEN TO ALL ZERO).

I've set TOKEN_KEY to all zero as you say, but It still didn't change. The JWT is
JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODU4MTkwNzQsInN1YiI6IkxPR0lOX1RPS0VOIiwiZXhwIjoxNTg2NDIzODc0LCJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiJ9.SaAWMT3m4PtNe3mqMXw1r4xrLefw4ZL3RNoJnqkMQS4

Thank you.

with the same payload, the JWT token i sign is eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODU4MTkwNzQsInN1YiI6IkxPR0lOX1RPS0VOIiwiZXhwIjoxNTg2NDIzODc0LCJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiJ9.OOuCqTbqmcs9X9WOeIWYo8k05fEPfxQ1rCO_c0CAffc(link) (it seems that you are not using the all-zero-token to sign the JWT)

maybe you need to delete your cookies and try again? 😂

Yes, the token_key value was not passed through. It seems that it takes time to refresh values in .env. I had tried a whole day on everything(change names, values, restart, etc). The DATABASE_URL works properly, but the std::env::var("TOKEN_KEY") just showed Err(NotPresent), which is very weird. Then suddenly it started working. I still have no idea why that happened. But anyway, I can keep going now.

Thank you very much!

seems that you've solved the problem, then I closed this issue.
and have fun with rubble.