Add more debugging information in authorize route, and cargo fmt
This commit is contained in:
parent
9481c0ff7e
commit
907f22bfd4
17 changed files with 307 additions and 164 deletions
|
|
@ -1,3 +1,5 @@
|
|||
#[macro_use] extern crate log;
|
||||
|
||||
mod cache;
|
||||
pub use cache::JsonCache;
|
||||
mod credentials;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ impl SSOWatConfig {
|
|||
if let Some(domain) = uri.domain() {
|
||||
if ! self.domains.contains(&domain.to_string()) {
|
||||
// Domain not managed
|
||||
trace!("Domain {} not managed by Yunohost", &domain);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -31,19 +32,25 @@ impl SSOWatConfig {
|
|||
.trim_start_matches("s")
|
||||
.trim_start_matches("://");
|
||||
|
||||
trace!("Checking permissions for {}", stripped_uri);
|
||||
|
||||
// Check which app matches this URI, to find corresponding permission
|
||||
for (key, val) in &self.permissions {
|
||||
for uri_format in &val.uris {
|
||||
if uri_format.starts_with("re:") {
|
||||
trace!("Checking if URI matches regex: {}", uri_format);
|
||||
let uri_format = uri_format.trim_start_matches("re:");
|
||||
// TODO: generate regex in advance
|
||||
// TODO: error
|
||||
let re = Regex::new(uri_format).unwrap();
|
||||
if re.is_match(stripped_uri) {
|
||||
trace!("Found URI matches regex app: {}", key);
|
||||
return Some(key.clone());
|
||||
}
|
||||
} else {
|
||||
trace!("Checking if URI starts with: {}", uri_format);
|
||||
if stripped_uri.starts_with(uri_format) {
|
||||
trace!("Found URI matches app: {}", key);
|
||||
return Some(key.clone());
|
||||
}
|
||||
}
|
||||
|
|
@ -51,9 +58,11 @@ impl SSOWatConfig {
|
|||
}
|
||||
|
||||
// No app URI matched
|
||||
trace!("No application matched for URI {}", stripped_uri);
|
||||
return None;
|
||||
} else {
|
||||
// No domain (eg. http://8.8.8.8/)
|
||||
trace!("No domain requested for permission request");
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -96,3 +105,9 @@ pub struct Permission {
|
|||
pub struct PermissionName {
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for PermissionName {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.name.fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue