mirror of
https://git.42l.fr/neil/sncf.git
synced 2024-06-03 00:02:19 +02:00
adding ALLOWED_ROUTES
This commit is contained in:
parent
cba8b52b32
commit
9f304c4069
11
src/sniff.rs
11
src/sniff.rs
|
@ -61,6 +61,7 @@ pub fn check_new_form(body: &web::Bytes) -> u64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// those routes won't be redirected
|
||||||
const BLOCKED_ROUTES: &[&str] = &[
|
const BLOCKED_ROUTES: &[&str] = &[
|
||||||
"/apps/settings",
|
"/apps/settings",
|
||||||
"/login",
|
"/login",
|
||||||
|
@ -70,6 +71,11 @@ const BLOCKED_ROUTES: &[&str] = &[
|
||||||
"/apps/files",
|
"/apps/files",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// ...except if they are in this list
|
||||||
|
const ALLOWED_ROUTES: &[&str] = &[
|
||||||
|
"/ocs/v2.php/apps/forms/",
|
||||||
|
];
|
||||||
|
|
||||||
// checks if the accessed route is allowed for the user.
|
// checks if the accessed route is allowed for the user.
|
||||||
// if it returns true, redirects elsewhere
|
// if it returns true, redirects elsewhere
|
||||||
pub fn check_route(route: &str) -> bool {
|
pub fn check_route(route: &str) -> bool {
|
||||||
|
@ -77,6 +83,11 @@ pub fn check_route(route: &str) -> bool {
|
||||||
|
|
||||||
for r in BLOCKED_ROUTES {
|
for r in BLOCKED_ROUTES {
|
||||||
if route.starts_with(r) {
|
if route.starts_with(r) {
|
||||||
|
for s in ALLOWED_ROUTES {
|
||||||
|
if route.starts_with(s) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue