init
This commit is contained in:
commit
c5731665a3
25 changed files with 1110 additions and 0 deletions
50
yunohost-api/src/permissions/ssowat.rs
Normal file
50
yunohost-api/src/permissions/ssowat.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
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,
|
||||
}
|
||||
Loading…
Reference in a new issue