Skip to content

Commit

Permalink
feat(wallet): wallet daemon new auth method (#1291)
Browse files Browse the repository at this point in the history
Description
---
I introduced an authentication method configuration and it has the
following possible values at the moment: `none` (no authentication as
before), `webauthn` (authenticate using `Webauthn` which is a
public/private key based authentication when the authenticator decides
where to store the private key(USB device, Google Chrome profile or any
other methods), for more info: [webauthn.io](https://webauthn.io/) ).
This new authentication method allows for the first time to register via
Webauthn and later login.

Also fixed/updated:
- Logic to check periodically when our JWT token has been expired
- Handle redirection when we want to access a protected URL
- `/access-token` page where we force login as well and returns current
JWT token for CLI usage

Motivation and Context
---
There was no authentication in wallet daemon, so whoever would access
the UI even through a local network, then that person could manipulate
all the accounts and possibly steal funds.

How Has This Been Tested?
---
1. Start a local swarm with the following extra CLI arg:
`--wallet-daemon-auth=webauthn` (default is `none`)
Example command: 
```shell
cargo run --bin tari_swarm_daemon --release -- -c data/config.toml start --wallet-daemon-auth=webauthn
```
2. Open up the wallet daemon UI (important that in the URL, use
`localhost` instead of `127.0.0.1` because webauthn must have a domain
present instead of an IP address)
3. Press Register button
4. Follow the steps in popup to register a new key
5. Press Login button and do login with your key

Demo:


https://github.com/user-attachments/assets/c7608bf7-fb82-4a0b-8f6f-fb0ac8fc0af8


What process can a PR reviewer use to test or verify this change?
---



Breaking Changes
---

- [ ] None
- [x] Requires data directory to be deleted
- [ ] Other - Please specify

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced robust WebAuthn support for secure user registration and
login.
- Added dedicated authentication screens with guarded routes and access
token display (with copy-to-clipboard) for a smoother wallet experience.
- Implemented new methods for handling WebAuthn registration and
authentication processes.
- Added support for checking if a user is already registered with
WebAuthn.
- Enhanced authentication mechanisms with new options for WebAuthn and
traditional methods.
- Integrated new authentication methods and WebAuthn capabilities in the
WalletDaemonClient.
- Introduced session management for WebAuthn registrations and passkeys
in the wallet storage.
  
- **Refactor**
- Enhanced session management and backend processes to improve security
and performance across wallet services.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Stan Bondi <[email protected]>
  • Loading branch information
ksrichard and sdbondi authored Feb 28, 2025
1 parent 619c78e commit 2b8845b
Show file tree
Hide file tree
Showing 110 changed files with 2,373 additions and 155 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ env:
jobs:
fmt:
name: fmt
runs-on: [ self-hosted, ubuntu-high-cpu ]
runs-on: [ ubuntu-latest ]

steps:
- name: checkout
Expand All @@ -60,7 +60,7 @@ jobs:

prettier:
name: prettier
runs-on: [ self-hosted, ubuntu-high-cpu ]
runs-on: [ ubuntu-latest ]

steps:
- name: checkout
Expand All @@ -76,7 +76,7 @@ jobs:
clippy:
name: clippy
runs-on: [ self-hosted, ubuntu-high-cpu ]
runs-on: [ ubuntu-latest ]

steps:
- name: checkout
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
build:
name: check nightly
runs-on: [ self-hosted, ubuntu-high-cpu ]
runs-on: [ ubuntu-latest ]

steps:
- name: checkout
Expand All @@ -157,7 +157,7 @@ jobs:

build-stable:
name: check stable
runs-on: [ self-hosted, ubuntu-high-cpu ]
runs-on: [ ubuntu-latest ]
env:
RUSTUP_PERMIT_COPY_RENAME: true

Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:

test:
name: test
runs-on: [ self-hosted, ubuntu-high-cpu ]
runs-on: [ ubuntu-latest ]

steps:
- name: checkout
Expand Down
Loading

0 comments on commit 2b8845b

Please sign in to comment.