-
-
Notifications
You must be signed in to change notification settings - Fork 137
Refactor auth flow #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor auth flow #425
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
let is_auth = creds.map(|creds| { | ||
let (username, password) = creds; | ||
Users.authenticate(username, password, self.action, stream) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is is_auth
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type is result of authentication and authorization. Type of creds is Result<> which i can only return in the async block down below. So have to .map
for calling authenticate
Users.authenticate
does both authentication and authorization.
pub static USER_AUTHORIZATION_MAP: OnceCell<RwLock<UserPermMap>> = OnceCell::new(); | ||
pub static USER_MAP: OnceCell<RwLock<UserMap>> = OnceCell::new(); | ||
pub static AUTH_MAP: OnceCell<RwLock<AuthMap>> = OnceCell::new(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of two different maps here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any changes made to user ( password change, role update, etc.. ) it is updated in memory in the Usermap Hashmap<username, User>
. The User contains password hash and role information. While AuthMap
is for quick authentication and authorization, it is HashMap<(user, pass), Vec>. Any changes made to User will reset the AuthMap and upon authentication user perms is reloaded into this map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM & Tested
Part of #250
Description