Skip to content

Commit 2917296

Browse files
committed
Update and release yubico_ng
* Upgrade to `tokio` 1.44, `rand` 0.9 * Renamed to yubico_ng and published crate * Made edition 2024 compatible * Added several clippy/rust lints and fixed those * Fixed a panic if the `YK_API_HOST` was invalid * Use only the main api server, the others are deprecated * Run cargo fmt * Updated GHA to use hashes and run/fix zizmor Signed-off-by: BlackDex <[email protected]>
1 parent 00df148 commit 2917296

File tree

15 files changed

+246
-171
lines changed

15 files changed

+246
-171
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
github: BlackDex
2+
liberapay: BlackDex
3+
custom: ["https://paypal.me/MathijsvVeluw"]

.github/workflows/build.yml

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Build
2+
permissions: {}
23

34
on:
45
push:
@@ -9,17 +10,20 @@ on:
910
- "Cargo.toml"
1011
pull_request:
1112
paths:
12-
- ".github/workflows/build.yml"
13-
- "examples/**"
14-
- "src/**"
15-
- "Cargo.toml"
13+
- ".github/workflows/build.yml"
14+
- "examples/**"
15+
- "src/**"
16+
- "Cargo.toml"
1617

1718
## To trigger this workflow using `act` (https://github.com/nektos/act) you can do the following.
1819
# act push -j build
1920

2021
jobs:
2122
build:
22-
runs-on: ubuntu-22.04
23+
name: Build and Test
24+
permissions:
25+
contents: read
26+
runs-on: ubuntu-24.04
2327
timeout-minutes: 30
2428
# Make warnings errors, this is to prevent warnings slipping through.
2529
# This is done globally to prevent rebuilds when the RUSTFLAGS env variable changes.
@@ -28,15 +32,7 @@ jobs:
2832
strategy:
2933
fail-fast: false
3034

31-
name: Build and Test
32-
3335
steps:
34-
# Checkout the repo
35-
- name: "Checkout"
36-
uses: actions/checkout@v4
37-
# End Checkout the repo
38-
39-
4036
# Install dependencies
4137
- name: "Install dependencies Ubuntu"
4238
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential pkg-config openssl libssl-dev
@@ -45,22 +41,27 @@ jobs:
4541

4642
# Install Rust with clippy
4743
- name: "Install rust-toolchain version"
48-
uses: dtolnay/rust-toolchain@stable
44+
uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable at Mar 18, 2025, 8:14 PM GMT+1
4945
with:
5046
components: clippy
5147
# End Install Rust with clippy
5248

53-
5449
# Show environment
5550
- name: "Show environment"
5651
run: |
5752
rustc -vV
5853
cargo -vV
5954
# End Show environment
6055

56+
# Checkout the repo
57+
- name: "Checkout"
58+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
59+
with:
60+
persist-credentials: false
61+
# End Checkout the repo
6162

6263
# Enable Rust Caching
63-
- uses: Swatinem/rust-cache@v2
64+
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
6465
# End Enable Rust Caching
6566

6667
# Run cargo commands
@@ -127,29 +128,39 @@ jobs:
127128
# This is useful so all test/clippy/fmt actions are done, and they can all be addressed
128129
- name: "Some checks failed"
129130
if: ${{ failure() }}
131+
env:
132+
RUN_CARGO_UPDATE: ${{ steps.run_cargo_update.outcome }}
133+
RUN_CARGO_TEST: ${{ steps.run_cargo_test.outcome }}
134+
BUILD_ALL: ${{ steps.build_all_features.outcome }}
135+
EXAMPLE_OTP: ${{ steps.build_example_otp.outcome }}
136+
EXAMPLE_OTP_ASYNC: ${{ steps.build_example_otp_async.outcome }}
137+
EXAMPLE_OTP_CUSTOM: ${{ steps.build_example_otp_custom.outcome }}
138+
EXAMPLE_OTP_WITH_PROXY: ${{ steps.build_example_otp_with_proxy.outcome }}
139+
RUN_CARGO_CLIPPY: ${{ steps.run_cargo_clippy.outcome }}
140+
RUN_CARGO_CLIPPY_EXAMPLES: ${{ steps.run_cargo_clippy_examples.outcome }}
130141
run: |
131-
echo "### :x: Checks Failed!" >> $GITHUB_STEP_SUMMARY
132-
echo "" >> $GITHUB_STEP_SUMMARY
133-
echo "|Job|Status|" >> $GITHUB_STEP_SUMMARY
134-
echo "|---|------|" >> $GITHUB_STEP_SUMMARY
135-
echo "|cargo update|${{ steps.run_cargo_update.outcome }}|" >> $GITHUB_STEP_SUMMARY
136-
echo "|cargo test|${{ steps.run_cargo_test.outcome }}|" >> $GITHUB_STEP_SUMMARY
137-
echo "|build all features|${{ steps.build_all_features.outcome }}|" >> $GITHUB_STEP_SUMMARY
138-
echo "|build example otp|${{ steps.build_example_otp.outcome }}|" >> $GITHUB_STEP_SUMMARY
139-
echo "|build example otp_async|${{ steps.build_example_otp_async.outcome }}|" >> $GITHUB_STEP_SUMMARY
140-
echo "|build example otp_custom|${{ steps.build_example_otp_custom.outcome }}|" >> $GITHUB_STEP_SUMMARY
141-
echo "|build example otp_with_proxy|${{ steps.build_example_otp_with_proxy.outcome }}|" >> $GITHUB_STEP_SUMMARY
142-
echo "|clippy all features|${{ steps.run_cargo_clippy.outcome }}|" >> $GITHUB_STEP_SUMMARY
143-
echo "|clippy examples|${{ steps.run_cargo_clippy_examples.outcome }}|" >> $GITHUB_STEP_SUMMARY
144-
echo "" >> $GITHUB_STEP_SUMMARY
145-
echo "Please check the failed jobs and fix where needed." >> $GITHUB_STEP_SUMMARY
146-
echo "" >> $GITHUB_STEP_SUMMARY
142+
echo "### :x: Checks Failed!" >> ${GITHUB_STEP_SUMMARY}
143+
echo "" >> ${GITHUB_STEP_SUMMARY}
144+
echo "|Job|Status|" >> ${GITHUB_STEP_SUMMARY}
145+
echo "|---|------|" >> ${GITHUB_STEP_SUMMARY}
146+
echo "|cargo update|${RUN_CARGO_UPDATE}|" >> ${GITHUB_STEP_SUMMARY}
147+
echo "|cargo test|${RUN_CARGO_TEST}|" >> ${GITHUB_STEP_SUMMARY}
148+
echo "|build all features|${BUILD_ALL}|" >> ${GITHUB_STEP_SUMMARY}
149+
echo "|build example otp|${EXAMPLE_OTP}|" >> ${GITHUB_STEP_SUMMARY}
150+
echo "|build example otp_async|${EXAMPLE_OTP_ASYNC}|" >> ${GITHUB_STEP_SUMMARY}
151+
echo "|build example otp_custom|${EXAMPLE_OTP_CUSTOM}|" >> ${GITHUB_STEP_SUMMARY}
152+
echo "|build example otp_with_proxy|${EXAMPLE_OTP_WITH_PROXY}|" >> ${GITHUB_STEP_SUMMARY}
153+
echo "|clippy all features|${RUN_CARGO_CLIPPY}|" >> ${GITHUB_STEP_SUMMARY}
154+
echo "|clippy examples|${RUN_CARGO_CLIPPY_EXAMPLES}|" >> ${GITHUB_STEP_SUMMARY}
155+
echo "" >> ${GITHUB_STEP_SUMMARY}
156+
echo "Please check the failed jobs and fix where needed." >> ${GITHUB_STEP_SUMMARY}
157+
echo "" >> ${GITHUB_STEP_SUMMARY}
147158
exit 1
148159
149160
150161
# If all was ok, then we show this
151162
- name: "All checks passed"
152163
if: ${{ success() }}
153164
run: |
154-
echo "### :tada: Checks Passed!" >> $GITHUB_STEP_SUMMARY
155-
echo "" >> $GITHUB_STEP_SUMMARY
165+
echo "### :tada: Checks Passed!" >> ${GITHUB_STEP_SUMMARY}
166+
echo "" >> ${GITHUB_STEP_SUMMARY}

Cargo.toml

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,102 @@
11
[package]
2-
name = "yubico"
3-
version = "0.12.0"
4-
authors = ["Flavio Oliveira <[email protected]>", "Pierre Larger <pierre.larger@gmail.com>"]
2+
name = "yubico_ng"
3+
version = "0.13.0"
4+
authors = ["Mathijs van Veluw <black.dex@gmail.com>"]
55
edition = "2021"
66

77
description = "Yubikey client API library"
88
license = "MIT OR Apache-2.0"
99
keywords = ["yubikey", "authentication", "encryption", "OTP", "Challenge-Response"]
1010
categories = ["authentication"]
11-
repository = "https://github.com/wisespace-io/yubico-rs"
11+
repository = "https://github.com/BlackDex/yubico-rs"
1212
readme = "README.md"
1313

14-
[badges]
15-
travis-ci = { repository = "wisespace-io/yubico-rs" }
16-
1714
[lib]
18-
name = "yubico"
15+
name = "yubico_ng"
1916
path = "src/lib.rs"
2017

2118
[dependencies]
2219
base64 = "0.22"
2320
futures = { version = "0.3", optional = true }
2421
hmac = "0.12"
25-
rand = "0.8"
22+
rand = "0.9"
2623
reqwest = { version = "0.12", features = ["blocking"], default-features = false }
2724
sha1 = "0.10"
2825
threadpool = "1.8"
2926
form_urlencoded = "1"
3027

3128
[dev-dependencies]
32-
tokio = { version = "1.37", features = ["macros"] }
29+
tokio = { version = "1.44", features = ["macros", "rt-multi-thread"] }
3330
futures = "0.3"
3431

3532
[features]
3633
default = ["online-tokio", "native-tls"]
3734
online-tokio = ["futures"]
38-
rustls-tls = ["reqwest/rustls-tls"]
3935
native-tls = ["reqwest/native-tls"]
36+
rustls-tls = ["reqwest/rustls-tls"]
37+
38+
# Linting config
39+
# https://doc.rust-lang.org/rustc/lints/groups.html
40+
[workspace.lints.rust]
41+
# Forbid
42+
unsafe_code = "forbid"
43+
non_ascii_idents = "forbid"
44+
45+
# Deny
46+
deprecated_in_future = "deny"
47+
future_incompatible = { level = "deny", priority = -1 }
48+
keyword_idents = { level = "deny", priority = -1 }
49+
let_underscore = { level = "deny", priority = -1 }
50+
noop_method_call = "deny"
51+
refining_impl_trait = { level = "deny", priority = -1 }
52+
rust_2018_idioms = { level = "deny", priority = -1 }
53+
rust_2021_compatibility = { level = "deny", priority = -1 }
54+
rust_2024_compatibility = { level = "deny", priority = -1 }
55+
single_use_lifetimes = "deny"
56+
trivial_casts = "deny"
57+
trivial_numeric_casts = "deny"
58+
unused = { level = "deny", priority = -1 }
59+
unused_import_braces = "deny"
60+
unused_lifetimes = "deny"
61+
unused_qualifications = "deny"
62+
variant_size_differences = "deny"
63+
64+
# https://rust-lang.github.io/rust-clippy/stable/index.html
65+
[workspace.lints.clippy]
66+
# Warn
67+
dbg_macro = "warn"
68+
todo = "warn"
69+
70+
# Deny
71+
case_sensitive_file_extension_comparisons = "deny"
72+
cast_lossless = "deny"
73+
clone_on_ref_ptr = "deny"
74+
equatable_if_let = "deny"
75+
filter_map_next = "deny"
76+
float_cmp_const = "deny"
77+
inefficient_to_string = "deny"
78+
iter_on_empty_collections = "deny"
79+
iter_on_single_items = "deny"
80+
linkedlist = "deny"
81+
macro_use_imports = "deny"
82+
manual_assert = "deny"
83+
manual_instant_elapsed = "deny"
84+
manual_string_new = "deny"
85+
match_on_vec_items = "deny"
86+
match_wildcard_for_single_variants = "deny"
87+
mem_forget = "deny"
88+
needless_continue = "deny"
89+
needless_lifetimes = "deny"
90+
option_option = "deny"
91+
string_add_assign = "deny"
92+
string_to_string = "deny"
93+
unnecessary_join = "deny"
94+
unnecessary_self_imports = "deny"
95+
unnested_or_patterns = "deny"
96+
unused_async = "deny"
97+
unused_self = "deny"
98+
verbose_file_reads = "deny"
99+
zero_sized_map_values = "deny"
100+
101+
[lints]
102+
workspace = true

README.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# Yubico &emsp; [![Build Status]][travis] [![Latest Version]][crates.io] [![MIT licensed]][MIT] [![Apache-2.0 licensed]][APACHE]
1+
# Yubico NG &emsp; [![Latest Version]][crates.io] [![deps.rs]][deps.rs] [![MIT licensed]][MIT] [![Apache-2.0 licensed]][APACHE]
22

3-
[Build Status]: https://travis-ci.org/wisespace-io/yubico-rs.png?branch=master
4-
[travis]: https://travis-ci.org/wisespace-io/yubico-rs
5-
[Latest Version]: https://img.shields.io/crates/v/yubico.svg
6-
[crates.io]: https://crates.io/crates/yubico
3+
[Latest Version]: https://img.shields.io/crates/v/yubico_ng.svg
4+
[crates.io]: https://crates.io/crates/yubico_ng
5+
[deps.rs]: https://deps.rs/repo/github/BlackDex/yubico-rs/status.svg
76
[MIT licensed]: https://img.shields.io/badge/License-MIT-blue.svg
87
[MIT]: ./LICENSE-MIT
98
[Apache-2.0 licensed]: https://img.shields.io/badge/License-Apache%202.0-blue.svg
@@ -15,7 +14,7 @@
1514

1615
## Current features
1716

18-
- [X] Synchronous Yubikey client API library, [validation protocol version 2.0](https://developers.yubico.com/yubikey-val/Validation_Protocol_V2.0.html).
17+
- [X] Synchronous Yubikey client API library, [validation protocol version 2.0](https://developers.yubico.com/OTP/Specifications/OTP_validation_protocol.html).
1918
- [X] Asynchronous Yubikey client API library relying on [Tokio](https://github.com/tokio-rs/tokio)
2019

2120
**Note:** The USB-related features have been moved to a sepatated repository, [yubico-manager](https://github.com/wisespace-io/yubico-manager)
@@ -26,19 +25,27 @@ Add this to your Cargo.toml
2625

2726
```toml
2827
[dependencies]
29-
yubico = "0.12"
28+
yubico_ng = "0.13"
29+
```
30+
31+
Or, since this crate is still backwards compatible with the yubico crate.
32+
```toml
33+
[dependencies]
34+
yubico = { version = "0.13", package = "yubico_ng" }
3035
```
3136

3237
The following are a list of Cargo features that can be enabled or disabled:
3338

3439
- online-tokio (enabled by default): Provides integration to Tokio using futures.
40+
- native-tls (enabled by default): Use native-tls provided by the OS.
41+
- rustls-tls: Use rustls instead of native-tls.
3542

3643
You can enable or disable them using the example below:
3744

3845
```toml
39-
[dependencies.yubico]
40-
version = "0.12"
41-
# don't include the default features (online-tokio)
46+
[dependencies.yubico_ng]
47+
version = "0.13"
48+
# don't include the default features (online-tokio, native-tls)
4249
default-features = false
4350
# cherry-pick individual features
4451
features = []
@@ -49,10 +56,10 @@ You can enable or disable them using the example below:
4956
### OTP with Default Servers
5057

5158
```rust
52-
extern crate yubico;
59+
extern crate yubico_ng;
5360

54-
use yubico::config::*;
55-
use yubico::verify;
61+
use yubico_ng::config::*;
62+
use yubico_ng::verify;
5663

5764
fn main() {
5865
let config = Config::default()
@@ -69,8 +76,8 @@ fn main() {
6976
## OTP with custom API servers
7077

7178
```rust
72-
use yubico::verify;
73-
use yubico::config::Config;
79+
use yubico_ng::verify;
80+
use yubico_ng::config::Config;
7481

7582
fn main() {
7683
let config = Config::default()
@@ -92,8 +99,8 @@ fn main() {
9299
use futures::TryFutureExt;
93100

94101
use std::io::stdin;
95-
use yubico::config::Config;
96-
use yubico::verify_async;
102+
use yubico_ng::config::Config;
103+
use yubico_ng::verify_async;
97104

98105
#[tokio::main]
99106
async fn main() -> Result<(), ()> {
@@ -172,6 +179,16 @@ The OTP is valid.
172179

173180
## Changelog
174181

182+
- 0.13.0 (2025-04-23):
183+
* Upgrade to `tokio` 1.44, `rand` 0.9
184+
* Renamed to yubico_ng and published crate
185+
* Made edition 2024 compatible
186+
* Added several clippy/rust lints and fixed those
187+
* Fixed a panic if the `YK_API_HOST` was invalid
188+
* Use only the main api server, the others are deprecated
189+
* Run cargo fmt
190+
* Updated GHA to use hashes and run/fix zizmor
191+
175192
- 0.12.0: Upgrade to `tokio` 1.37, `reqwest` 0.12, `base64` 0.22, clippy fixes.
176193
- 0.10.0: Upgrade to `tokio` 1.1 and `reqwest` 0.11
177194
- 0.9.2: (Yanked) Dependencies update

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ cargo run --release --example "otp_custom"
2020

2121
## Asynchronous OTP check
2222

23-
cargo run --release --example "otp_async"
23+
cargo run --release --example "otp_async"

examples/otp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::io::stdin;
2-
use yubico::config::Config;
3-
use yubico::verify;
2+
use yubico_ng::config::Config;
3+
use yubico_ng::verify;
44

55
fn main() {
66
println!("Please plug in a yubikey and enter an OTP");

examples/otp_async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use futures::TryFutureExt;
22

33
use std::io::stdin;
4-
use yubico::config::Config;
5-
use yubico::verify_async;
4+
use yubico_ng::config::Config;
5+
use yubico_ng::verify_async;
66

77
#[tokio::main]
88
async fn main() -> Result<(), ()> {

examples/otp_custom.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::io::stdin;
2-
use yubico::config::Config;
3-
use yubico::verify;
2+
use yubico_ng::config::Config;
3+
use yubico_ng::verify;
44

55
fn main() {
66
println!("Please plug in a yubikey and enter an OTP");

0 commit comments

Comments
 (0)