acl: Return details to caller when authenticating user
This commit is contained in:
parent
6d752cd050
commit
3215630aab
1 changed files with 20 additions and 4 deletions
|
@ -20,6 +20,13 @@ pub struct ResourceShortcuts {
|
||||||
pub id: i8,
|
pub id: i8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct LogEntry {
|
||||||
|
pub username: String,
|
||||||
|
pub resource: String,
|
||||||
|
pub method: String,
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialEq for AuthMethod {
|
impl PartialEq for AuthMethod {
|
||||||
fn eq(&self, other: &Self) -> bool{
|
fn eq(&self, other: &Self) -> bool{
|
||||||
(self.method == other.method)
|
(self.method == other.method)
|
||||||
|
@ -82,13 +89,22 @@ pub trait ACL {
|
||||||
self.add_shortcut(username, resource, shortcut);
|
self.add_shortcut(username, resource, shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn auth_user(&self, method: String, identifier: String, shortcut: i8) {
|
fn auth_user(&self, method: String, identifier: String, shortcut: i8) -> Option<LogEntry> {
|
||||||
if let Some(username) = self.get_username(method, identifier) {
|
let mut ret = None;
|
||||||
|
if let Some(username) = self.get_username(method.clone(), identifier) {
|
||||||
if let Some(resource) = self.get_resource(username.clone(), shortcut) {
|
if let Some(resource) = self.get_resource(username.clone(), shortcut) {
|
||||||
if self.is_allowed(username.clone(), resource).is_some() {
|
if self
|
||||||
println!("Open Sesame! {}", username);
|
.is_allowed(username.clone(), resource.clone())
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
|
ret = Some(LogEntry {
|
||||||
|
username,
|
||||||
|
resource,
|
||||||
|
method,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue