Chaning the default of permitted_users to depend on [[users]]
This commit is contained in:
3 files changed
+21
-5
No files matched your search
@@ -112,7 +112,9 @@ Anywhere a username is accepted it can take any username or one of the following
|
||||
- `anyone` means any user with a valid user/pass
|
||||
- `anonymous` means no user/pass required
|
||||
|
||||
The default `permitted_users` list is `[ "anonymous" ]` meaning no authentication required. If you want to use authenitcation then after adding your users through `[[users]]` please ensure you update the `permittted_users` for each camera.
|
||||
The default `permitted_users` list is:
|
||||
- `[ "anonymous"]` if no `[[users]]` were given in the config meaning no authentication required to connect.
|
||||
- `[ "anyone" ]` if `[[users]]` were provided meaning any authourised users can connect.
|
||||
|
||||
You can change the Neolink log level by setting the `RUST_LOG` environment variable (not in the configuration file) to one of `error`, `warn`, `info`, `debug`, or `trace`:
|
||||
|
||||
|
||||
+3
-3
@@ -70,7 +70,7 @@ pub struct CameraConfig {
|
||||
pub stream: String,
|
||||
|
||||
#[serde(default = "default_permitted_users")]
|
||||
pub permitted_users: Vec<String>,
|
||||
pub permitted_users: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Validate, Clone)]
|
||||
@@ -108,8 +108,8 @@ fn default_tls_client_auth() -> String {
|
||||
"none".to_string()
|
||||
}
|
||||
|
||||
fn default_permitted_users() -> Vec<String> {
|
||||
vec!["anonymous".to_string()]
|
||||
fn default_permitted_users() -> Option<Vec<String>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn default_users() -> Vec<UserConfig> {
|
||||
|
||||
+15
-1
@@ -177,8 +177,22 @@ fn set_up_users(users: &Vec<UserConfig>, rtsp: &RtspServer) {
|
||||
|
||||
fn get_permitted_users(
|
||||
users: &Vec<UserConfig>,
|
||||
current_permitted_users: &Vec<String>,
|
||||
permitted_users: &Option<Vec<String>>,
|
||||
) -> Vec<String> {
|
||||
let current_permitted_users = match permitted_users {
|
||||
Some(permitted_users) => permitted_users.clone().to_owned(),
|
||||
None => {
|
||||
// If None then the users didn't specify permitted_users
|
||||
// In this case we do either
|
||||
// - Any authourised user if [[users]] was specified
|
||||
// - Any connecting user if [[users]] was not added
|
||||
if users.len() > 0 {
|
||||
vec!("anyone".to_string())
|
||||
} else {
|
||||
vec!("anonymous".to_string())
|
||||
}
|
||||
}
|
||||
};
|
||||
// This is required to handle the special case of "anyone"
|
||||
// ===Special set up of "anyone"===
|
||||
// If in the camera config there is the user "anyone"
|
||||
|
||||
Reference in new issue
Block a user