tolerate invalid config
This commit is contained in:
parent
68cd2c581e
commit
ec8d3cdb23
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -395,7 +395,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pam_fido2"
|
||||
version = "0.2.5"
|
||||
version = "0.2.7"
|
||||
dependencies = [
|
||||
"ctap_hmac 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ctrlc 3.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "pam_fido2"
|
||||
version = "0.2.5"
|
||||
version = "0.2.7"
|
||||
authors = ["shimun <shimun@shimun.net>"]
|
||||
edition = "2018"
|
||||
|
||||
|
14
default.nix
Normal file
14
default.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, callPackage ? pkgs.callPackage
|
||||
, name ? "pam_fido2"
|
||||
}:
|
||||
let
|
||||
crate2nix_tools = import "${builtins.fetchTarball { url = "https://github.com/kolloch/crate2nix/archive/0.8.0.tar.gz"; }}/tools.nix" { };
|
||||
overrides = pkgs.defaultCrateOverrides // {
|
||||
pam_fido2 = attrs: with pkgs; {
|
||||
buildInputs = [ linux-pam ];
|
||||
};
|
||||
};
|
||||
project = callPackage (crate2nix_tools.generatedCargoNix { name = name; src = "${./.}"; }) { defaultCrateOverrides = overrides; };
|
||||
in
|
||||
project.rootCrate.build
|
@ -90,14 +90,16 @@ impl Settings {
|
||||
let re = Regex::new(&pattern).expect(&["Invalid regex pattern:", &pattern].join(" "));
|
||||
if re.is_match(user) {
|
||||
let mut parts = cred.split(":");
|
||||
//TODO: use expect
|
||||
let id = parts.by_ref().next().unwrap();
|
||||
let key = parts.by_ref().next().unwrap();
|
||||
match (parts.by_ref().next(), parts.by_ref().next()) {
|
||||
(Some(id), Some(key)) => {
|
||||
creds.push(ctap::FidoCredential {
|
||||
id: hex::decode(id).unwrap(),
|
||||
public_key: hex::decode(key).ok(),
|
||||
});
|
||||
}
|
||||
_ => eprintln!("Failed to parse {}", cred),
|
||||
}
|
||||
}
|
||||
}
|
||||
creds
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user