Repository navigation
Password provider: Rust crate for argon2id hashes #362
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: argon2-wasm CI | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "src/components/passwordProvider/argon2-wasm/**" | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| build-and-test: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| defaults: | ||
| run: | ||
| working-directory: src/components/passwordProvider/argon2-wasm | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2 | ||
|
|
||
| # Reads rust-toolchain.toml and installs the pinned toolchain + targets. | ||
| - name: Install pinned Rust toolchain | ||
| run: rustup toolchain install | ||
|
|
||
| - name: Cache cargo registry and build artifacts | ||
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| src/components/passwordProvider/argon2-wasm/target | ||
| key: ${{ runner.os }}-cargo-argon2-wasm-${{ hashFiles('src/components/passwordProvider/argon2-wasm/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo-argon2-wasm- | ||
|
|
||
| - name: cargo fmt | ||
| run: just fmt | ||
|
|
||
| - name: cargo clippy | ||
| run: just lint | ||
|
|
||
| - name: cargo test | ||
| run: just test | ||
|
|
||
| - name: Compile for wasm32 target | ||
| run: just check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /target | ||
| /pkg |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| [package] | ||
| name = "argon2-wasm" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| [lib] | ||
| crate-type = ["cdylib"] | ||
|
|
||
| [dependencies] | ||
| wasm-bindgen = "0.2.100" | ||
| argon2 = { version = "0.5", features = ["password-hash"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| set shell := ["bash", "-uc"] | ||
|
|
||
| wasm-pack-version := "0.15.0" | ||
|
|
||
| _default: | ||
| @just --list | ||
|
|
||
| # Install the pinned wasm-pack version. | ||
| install-wasm-pack: | ||
| cargo install wasm-pack --version {{ wasm-pack-version }} --locked --force | ||
|
|
||
| # Regenerate the wasm-bindgen bindings in pkg/. | ||
| build: install-wasm-pack | ||
| wasm-pack build --release --target web --out-dir pkg --out-name argon2_wasm | ||
|
|
||
| test: | ||
| cargo test --locked | ||
|
|
||
| # Compile for the wasm32 target without regenerating bindings (fast syntax/type check). | ||
| check: | ||
| cargo build --locked --release --target wasm32-unknown-unknown | ||
|
|
||
| fmt: | ||
| cargo fmt --check | ||
|
|
||
| lint: | ||
| cargo clippy --locked --all-targets -- -D warnings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # argon2-wasm | ||
|
|
||
| A tiny Rust crate that wraps [`argon2`](https://docs.rs/argon2) and compiles to WebAssembly | ||
| via `wasm-bindgen`, used by the password provider component to hash and verify passwords. | ||
|
|
||
| ## Building | ||
|
|
||
| Requires [`just`](https://github.com/casey/just) and the toolchain pinned in | ||
| `rust-toolchain.toml` (installed automatically by `rustup` on first use). | ||
|
|
||
| ```sh | ||
| just test # cargo test | ||
| just check # compile for wasm32 (fast syntax/type check, no bindings) | ||
| just build # regenerate pkg/ via wasm-pack (pinned version) | ||
| ``` | ||
|
|
||
| `pkg/` is gitignored and regenerated by `just build`. After changing `src/lib.rs`, run | ||
| `just build` before using the password provider component. | ||
|
|
||
| TODO: once this crate lives in a monorepo, `just build` should be invoked from a `prepare` | ||
| script instead of run manually. |
4 changes: 4 additions & 0 deletions
4
src/components/passwordProvider/argon2-wasm/rust-toolchain.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [toolchain] | ||
| channel = "1.96.1" | ||
| targets = ["wasm32-unknown-unknown"] | ||
| components = ["rustfmt", "clippy"] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using wasm32-unknown-unknown because: