Can create read only clients
This commit is contained in:
@ -51,6 +51,9 @@ pub struct FormRequest {
|
||||
/// Restrict new client to a given network
|
||||
ip_network: Option<String>,
|
||||
|
||||
/// Grant read only access to client
|
||||
readonly_client: Option<String>,
|
||||
|
||||
/// Delete a specified client id
|
||||
delete_client_id: Option<uuid::Uuid>,
|
||||
}
|
||||
@ -111,7 +114,8 @@ pub async fn home(session: Session, form_req: Option<web::Form<FormRequest>>) ->
|
||||
};
|
||||
|
||||
if error_message.is_none() {
|
||||
let token = APIClient::generate(new_token_desc, ip_net);
|
||||
let mut token = APIClient::generate(new_token_desc, ip_net);
|
||||
token.readonly_client = form_req.0.readonly_client.is_some();
|
||||
success_message = Some(format!("The secret of your new token is '{}'. Be sure to write it somewhere as you will not be able to recover it later!", token.secret));
|
||||
config.clients.push(token);
|
||||
config.save().await?;
|
||||
|
@ -49,6 +49,9 @@ pub struct APIClient {
|
||||
|
||||
/// Client last usage time
|
||||
pub used: u64,
|
||||
|
||||
/// Read only access
|
||||
pub readonly_client: bool,
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
@ -71,6 +74,7 @@ impl APIClient {
|
||||
secret: rand_str(TOKEN_LEN),
|
||||
created: curr_time().unwrap(),
|
||||
used: curr_time().unwrap(),
|
||||
readonly_client: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user