Skip to content

Commit 1733e59

Browse files
committed
Clippy/Rust lints and other updates
* Upgrade to `tokio` 1.47 * Bumped MSRV to v1.82.0 needed by latest packages * Added more clippy/rust lints including `pedantic` and fixed found items * Use only the main api server, the others are deprecated * Updated GHA * Added dotenvy as a dev dependency to load `.env` files Signed-off-by: BlackDex <black.dex@gmail.com>
1 parent d05565c commit 1733e59

17 files changed

Lines changed: 183 additions & 103 deletions

.env.template

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Used for running the examples
2+
# Copy this template and rename it to `.env` for it to be used
3+
# Or provided the variables below inline during a run
4+
5+
# Mandatory Client ID. A number like 111111
6+
YK_CLIENT_ID=111111
7+
8+
# Mandatory API Key. A base64 encoded value
9+
YK_API_KEY=AAAAAAAAAAAAAAAAAAAAAAAA==
10+
11+
# Optional
12+
YK_API_HOST=https://api2.yubico.com/wsapi/2.0/verify
13+
14+
# Optional
15+
YK_PROXY=http://127.0.0.1:1080

.github/workflows/build.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ jobs:
2929
# This is done globally to prevent rebuilds when the RUSTFLAGS env variable changes.
3030
env:
3131
RUSTFLAGS: "-D warnings"
32-
strategy:
33-
fail-fast: false
3432

3533
steps:
3634
# Install dependencies
@@ -41,7 +39,7 @@ jobs:
4139

4240
# Install Rust with clippy
4341
- name: "Install rust-toolchain version"
44-
uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable at Mar 18, 2025, 8:14 PM GMT+1
42+
uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable at Apr 29, 2025, 9:23 PM GMT+2
4543
with:
4644
components: clippy
4745
# End Install Rust with clippy
@@ -55,13 +53,13 @@ jobs:
5553

5654
# Checkout the repo
5755
- name: "Checkout"
58-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
56+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
5957
with:
6058
persist-credentials: false
6159
# End Checkout the repo
6260

6361
# Enable Rust Caching
64-
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
62+
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
6563
# End Enable Rust Caching
6664

6765
# Run cargo commands

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
.vscode/
2+
13
target
24
Cargo.lock
35

46
*.fmt
57
*.iml
8+
*.env

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

Cargo.toml

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
name = "yubico_ng"
3-
version = "0.13.0"
3+
version = "0.14.0"
44
authors = ["Mathijs van Veluw <black.dex@gmail.com>"]
55
edition = "2021"
6-
rust-version = "1.81.0"
6+
rust-version = "1.82.0"
77

88
description = "Yubikey client API library"
99
license = "MIT OR Apache-2.0"
@@ -27,8 +27,9 @@ threadpool = "1.8"
2727
form_urlencoded = "1"
2828

2929
[dev-dependencies]
30-
tokio = { version = "1.44", features = ["macros", "rt-multi-thread"] }
30+
tokio = { version = ">=1.47", features = ["macros", "rt-multi-thread"], default-features = false }
3131
futures = "0.3"
32+
dotenvy = "0.15"
3233

3334
[features]
3435
default = ["online-tokio", "native-tls"]
@@ -44,18 +45,26 @@ unsafe_code = "forbid"
4445
non_ascii_idents = "forbid"
4546

4647
# Deny
48+
arithmetic_overflow = "deny"
4749
deprecated_in_future = "deny"
50+
deprecated_safe = { level = "deny", priority = -1 }
4851
future_incompatible = { level = "deny", priority = -1 }
4952
keyword_idents = { level = "deny", priority = -1 }
5053
let_underscore = { level = "deny", priority = -1 }
54+
missing_copy_implementations = "deny"
55+
nonstandard_style = { level = "deny", priority = -1 }
5156
noop_method_call = "deny"
5257
refining_impl_trait = { level = "deny", priority = -1 }
5358
rust_2018_idioms = { level = "deny", priority = -1 }
5459
rust_2021_compatibility = { level = "deny", priority = -1 }
5560
rust_2024_compatibility = { level = "deny", priority = -1 }
61+
rust-2018-compatibility = { level = "deny", priority = -1 }
5662
single_use_lifetimes = "deny"
5763
trivial_casts = "deny"
5864
trivial_numeric_casts = "deny"
65+
unknown_or_malformed_diagnostic_attributes = { level = "deny", priority = -2 }
66+
unreachable_pub = "deny"
67+
unstable_features = "deny"
5968
unused = { level = "deny", priority = -1 }
6069
unused_import_braces = "deny"
6170
unused_lifetimes = "deny"
@@ -69,35 +78,25 @@ dbg_macro = "warn"
6978
todo = "warn"
7079

7180
# Deny
72-
case_sensitive_file_extension_comparisons = "deny"
73-
cast_lossless = "deny"
81+
bool_comparison = "deny"
7482
clone_on_ref_ptr = "deny"
83+
empty_structs_with_brackets = "deny"
7584
equatable_if_let = "deny"
76-
filter_map_next = "deny"
7785
float_cmp_const = "deny"
78-
inefficient_to_string = "deny"
86+
indexing_slicing = "deny"
7987
iter_on_empty_collections = "deny"
8088
iter_on_single_items = "deny"
81-
linkedlist = "deny"
82-
macro_use_imports = "deny"
83-
manual_assert = "deny"
84-
manual_instant_elapsed = "deny"
85-
manual_string_new = "deny"
86-
match_on_vec_items = "deny"
87-
match_wildcard_for_single_variants = "deny"
89+
manual_map = "deny"
8890
mem_forget = "deny"
89-
needless_continue = "deny"
9091
needless_lifetimes = "deny"
91-
option_option = "deny"
92-
string_add_assign = "deny"
93-
string_to_string = "deny"
94-
unnecessary_join = "deny"
92+
nonminimal_bool = "deny"
93+
pedantic = { level = "deny", priority = -1 }
94+
redundant_clone = "deny"
95+
str_to_string = "deny"
96+
unnecessary_lazy_evaluations = "deny"
9597
unnecessary_self_imports = "deny"
96-
unnested_or_patterns = "deny"
97-
unused_async = "deny"
98-
unused_self = "deny"
98+
unwrap_used = "deny"
9999
verbose_file_reads = "deny"
100-
zero_sized_map_values = "deny"
101100

102101
[lints]
103102
workspace = true

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
- [X] Synchronous Yubikey client API library, [validation protocol version 2.0](https://developers.yubico.com/OTP/Specifications/OTP_validation_protocol.html).
1818
- [X] Asynchronous Yubikey client API library relying on [Tokio](https://github.com/tokio-rs/tokio)
1919

20-
**Note:** The USB-related features have been moved to a sepatated repository, [yubico-manager](https://github.com/wisespace-io/yubico-manager)
20+
**Note:** The USB-related features have been moved to a separated repository, [yubico-manager](https://github.com/wisespace-io/yubico-manager)
2121

2222
## Usage
2323

2424
Add this to your Cargo.toml
2525

2626
```toml
2727
[dependencies]
28-
yubico_ng = "0.13"
28+
yubico_ng = "0.14"
2929
```
3030

3131
Or, since this crate is still backwards compatible with the yubico crate.
3232
```toml
3333
[dependencies]
34-
yubico = { version = "0.13", package = "yubico_ng" }
34+
yubico = { version = "0.14", package = "yubico_ng" }
3535
```
3636

3737
The following are a list of Cargo features that can be enabled or disabled:
@@ -179,6 +179,14 @@ The OTP is valid.
179179

180180
## Changelog
181181

182+
- 0.14.0 (2025-08-13):
183+
* Upgrade to `tokio` 1.47
184+
* Bumped MSRV to v1.82.0 needed by latest packages
185+
* Added more clippy/rust lints including `pedantic` and fixed found items
186+
* Use only the main api server, the others are deprecated
187+
* Updated GHA
188+
* Added dotenvy as a dev dependency to load `.env` files
189+
182190
- 0.13.0 (2025-04-23):
183191
* Upgrade to `tokio` 1.44, `rand` 0.9
184192
* Renamed to yubico_ng and published crate

examples/README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,30 @@ All these examples need some environment variables to work.
66

77
If you run the example it will show you which variables are missing.
88

9+
You can also copy the `.env.template` file to `.env` adjust the variables where needed and run the examples.
10+
11+
The `.env` file is excluded from git.
12+
913
## OTP (One Time Password)
1014

11-
cargo run --release --example "otp"
15+
```bash
16+
cargo run --release --example otp
17+
```
1218

1319
## OTP (One Time Password) with a HTTP Proxy
1420

15-
cargo run --release --example "otp_with_proxy"
21+
```bash
22+
cargo run --release --example otp_with_proxy
23+
```
1624

1725
## OTP (One Time Password) with Custom Servers
1826

19-
cargo run --release --example "otp_custom"
27+
```bash
28+
cargo run --release --example otp_custom
29+
```
2030

2131
## Asynchronous OTP check
2232

23-
cargo run --release --example "otp_async"
33+
```bash
34+
cargo run --release --example otp_async
35+
```

examples/otp.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
use dotenvy::dotenv;
12
use std::io::stdin;
23
use yubico_ng::config::Config;
34
use yubico_ng::verify;
45

56
fn main() {
7+
match dotenv() {
8+
Ok(_) => println!("Loaded .env"),
9+
Err(_) => eprintln!("Unable to load .env, provide proper environment variables manually"),
10+
}
11+
612
println!("Please plug in a yubikey and enter an OTP");
713

814
let client_id = std::env::var("YK_CLIENT_ID")
@@ -16,8 +22,8 @@ fn main() {
1622
let otp = read_user_input();
1723

1824
match verify(otp, config) {
19-
Ok(answer) => println!("{}", answer),
20-
Err(e) => println!("Error: {}", e),
25+
Ok(answer) => println!("{answer}"),
26+
Err(e) => println!("Error: {e}"),
2127
}
2228
}
2329

examples/otp_async.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
use futures::TryFutureExt;
22

3+
use dotenvy::dotenv;
34
use std::io::stdin;
45
use yubico_ng::config::Config;
56
use yubico_ng::verify_async;
67

78
#[tokio::main]
89
async fn main() -> Result<(), ()> {
10+
match dotenv() {
11+
Ok(_) => println!("Loaded .env"),
12+
Err(_) => eprintln!("Unable to load .env, provide proper environment variables manually"),
13+
}
14+
915
println!("Please plug in a yubikey and enter an OTP");
1016

1117
let client_id = std::env::var("YK_CLIENT_ID")
@@ -20,7 +26,7 @@ async fn main() -> Result<(), ()> {
2026

2127
verify_async(otp, config)
2228
.map_ok(|()| println!("Valid OTP."))
23-
.map_err(|err| println!("Invalid OTP. Cause: {:?}", err))
29+
.map_err(|err| println!("Invalid OTP. Cause: {err:?}"))
2430
.await
2531
}
2632

examples/otp_custom.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
use dotenvy::dotenv;
12
use std::io::stdin;
23
use yubico_ng::config::Config;
34
use yubico_ng::verify;
45

56
fn main() {
7+
match dotenv() {
8+
Ok(_) => println!("Loaded .env"),
9+
Err(_) => eprintln!("Unable to load .env, provide proper environment variables manually"),
10+
11+
}
12+
613
println!("Please plug in a yubikey and enter an OTP");
714

815
let client_id = std::env::var("YK_CLIENT_ID")
@@ -22,8 +29,8 @@ fn main() {
2229
let otp = read_user_input();
2330

2431
match verify(otp, config) {
25-
Ok(answer) => println!("{}", answer),
26-
Err(e) => println!("Error: {}", e),
32+
Ok(answer) => println!("{answer}"),
33+
Err(e) => println!("Error: {e}"),
2734
}
2835
}
2936

0 commit comments

Comments
 (0)