50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
|
|
use serde::{Serialize, Deserialize};
|
||
|
|
use url::Url;
|
||
|
|
|
||
|
|
use std::collections::HashMap;
|
||
|
|
|
||
|
|
use crate::Username;
|
||
|
|
|
||
|
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||
|
|
pub struct SSOWatConfig {
|
||
|
|
domains: Vec<String>,
|
||
|
|
permissions: HashMap<PermissionName, Permission>,
|
||
|
|
portal_domain: String,
|
||
|
|
portal_path: String,
|
||
|
|
redirected_urls: HashMap<String, String>,
|
||
|
|
theme: String,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl SSOWatConfig {
|
||
|
|
pub fn permission_for_uri(&self, uri: &Url) -> Option<PermissionName> {
|
||
|
|
// First check if the domain is actually managed by SSOWat
|
||
|
|
if let Some(domain) = uri.domain() {
|
||
|
|
if ! self.domains.contains(&domain.to_string()) {
|
||
|
|
// Domain not managed
|
||
|
|
return None;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
// No domain (eg. http://8.8.8.8/)
|
||
|
|
return None;
|
||
|
|
}
|
||
|
|
|
||
|
|
todo!();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||
|
|
pub struct Permission {
|
||
|
|
auth_header: bool,
|
||
|
|
label: String,
|
||
|
|
public: bool,
|
||
|
|
show_tile: bool,
|
||
|
|
uris: Vec<String>,
|
||
|
|
use_remote_user_in_nginx_conf: bool,
|
||
|
|
users: Vec<Username>,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||
|
|
pub struct PermissionName {
|
||
|
|
#[serde(flatten)]
|
||
|
|
name: String,
|
||
|
|
}
|