Can configure maximum inactivity of token
This commit is contained in:
@ -159,7 +159,7 @@ pub struct NewToken {
|
||||
pub description: String,
|
||||
pub rights: TokenRights,
|
||||
pub ip_restriction: Option<ipnetwork::IpNetwork>,
|
||||
pub delete_after_inactivity: Option<u64>,
|
||||
pub max_inactivity: Option<u64>,
|
||||
}
|
||||
|
||||
impl NewToken {
|
||||
@ -185,7 +185,7 @@ impl NewToken {
|
||||
return Some(err);
|
||||
}
|
||||
|
||||
if let Some(t) = self.delete_after_inactivity {
|
||||
if let Some(t) = self.max_inactivity {
|
||||
if t < 3600 {
|
||||
return Some("API tokens shall be valid for at least 1 hour!");
|
||||
}
|
||||
@ -209,7 +209,7 @@ pub async fn create(t: &NewToken) -> anyhow::Result<(Token, TokenPrivKey)> {
|
||||
rights: t.rights.clone(),
|
||||
last_used: time(),
|
||||
ip_restriction: t.ip_restriction,
|
||||
max_inactivity: t.delete_after_inactivity,
|
||||
max_inactivity: t.max_inactivity,
|
||||
};
|
||||
|
||||
token.save()?;
|
||||
|
Reference in New Issue
Block a user