Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix axum tutorial in makefile #470

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

Firstyear
Copy link
Member

Fixes #469

Remove the wasm build from the axum tutorial, as it defaults to the js display anyway.

  • cargo test has been run and passes
  • documentation has been updated with relevant examples (if relevant)

@dpasirst
Copy link

dpasirst commented Jan 2, 2025

Please note, this currently only partially fixes #469 - specifically, it fixes the broken build, but the tutorial itself still does not work.

This change seems to result in not building or deploying the wasm which may be necessary to run the demo.

@yaleman
Copy link
Member

yaleman commented Jan 2, 2025

@dpasirst I just tested it and it worked fine on my machine?

@yaleman yaleman merged commit 78afc91 into kanidm:master Jan 2, 2025
43 checks passed
@dpasirst
Copy link

dpasirst commented Jan 2, 2025

@yaleman - It is possible that I'm doing something wrong. Perhaps to figure this out: would you please clarify how you tested? For example, Are you sure you tested in a 100% clean setup with a git pull to a new location (NOTE: cargo clean is insufficient because this uses Makefile and there is no make clean defined). I ask because with this change, the wasm code is never built or deployed for axum. Therefore, webauthn-rs/tutorial/server/axum/assets/wasm would only contain an index.html and no javascript or wasm. It may be worth checking if you have old artifacts in that location.

If you start from a completely clean setup and do the following:

git clone https://github.com/kanidm/webauthn-rs.git
cd webauthn-rs/tutorial/
make axum

The rust code builds and the webserver starts listening, the index.html file is served.
BUT:
The resulting web page only says "Welcome to the WebAuthn Server!" but no form is displayed.

webauthn-rs/tutorial/server/axum/assets/wasm only contains the index.html and nothing else as webauthn-rs/tutorial/server/axum/build_wasm.sh was never run.

@dpasirst dpasirst mentioned this pull request Jan 2, 2025
@yaleman
Copy link
Member

yaleman commented Jan 3, 2025

You're right, I hadn't taken into account having an already-built version, thanks for calling it out - the default feature for axum was set to wasm not javascript, so I've fixed that in #471

@dpasirst
Copy link

dpasirst commented Jan 3, 2025

@yaleman - yes, that does get the tutorial working for javascript as long as you go to http://localhost:8080/assets

Two observations:

  1. it is a bit non-obvious to go to "/assets" as opposed to just "/" - the other tutorials (actix_web and tide are just "/")

  2. the crate fixes also got the webauthn-rs/tutorial/server/axum/build_wasm.sh working - YAY! but... the output to webauthn-rs/tutorial/server/axum/assets/wasm is named wasm_tutorial.* which does not align with the content in index.html; thus:

        import init, { run_app } from './wasm.js';     <--- This line
        async function main() {
           await init('./wasm_bg.wasm');     <--- This line
           run_app();
        }

modify to:

        import init, { run_app } from './wasm_tutorial.js';
        async function main() {
           await init('./wasm_tutorial_bg.wasm');
           run_app();
        }

After that change, the wasm tutorial for axum will work too!

@dpasirst dpasirst mentioned this pull request Jan 3, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Axum tutorial is broken
3 participants