asterust_junos/system/login/
user.rs1use crate::system::authentication_methods;
9use crate::system::authentication_secret::authentication_secrets;
10use crate::system::AuthenticationSecret;
11use crate::{arg_of, child_block};
12use asterust::config::ConfigLine;
13
14#[derive(Clone, Debug, PartialEq, Eq)]
17#[non_exhaustive]
18pub struct LoginUser {
19 pub name: String,
20 pub class: Option<String>,
21 pub uid: Option<String>,
22 pub full_name: Option<String>,
23 pub authentication_methods: Vec<String>,
25 pub authentication_secrets: Vec<AuthenticationSecret>,
27}
28
29pub(super) fn parse_user(name: &str, user: &ConfigLine) -> LoginUser {
30 LoginUser {
31 name: name.to_string(),
32 class: arg_of(user, "class").map(str::to_string),
33 uid: arg_of(user, "uid").map(str::to_string),
34 full_name: arg_of(user, "full-name").map(str::to_string),
35 authentication_methods: child_block(user, "authentication")
36 .map(authentication_methods)
37 .unwrap_or_default(),
38 authentication_secrets: child_block(user, "authentication")
39 .map(authentication_secrets)
40 .unwrap_or_default(),
41 }
42}