mirror of
https://github.com/sadoyan/aralez.git
synced 2026-04-30 14:58:38 +08:00
Performance improvement. String removal from hot paths.
This commit is contained in:
@@ -3,6 +3,7 @@ use base64::engine::general_purpose::STANDARD;
|
||||
use base64::Engine;
|
||||
use pingora_proxy::Session;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use urlencoding::decode;
|
||||
|
||||
trait AuthValidator {
|
||||
@@ -56,18 +57,18 @@ fn validate(auth: &dyn AuthValidator, session: &Session) -> bool {
|
||||
auth.validate(session)
|
||||
}
|
||||
|
||||
pub fn authenticate(c: &[String], session: &Session) -> bool {
|
||||
match c[0].as_str() {
|
||||
pub fn authenticate(c: &[Arc<str>], session: &Session) -> bool {
|
||||
match &*c[0] {
|
||||
"basic" => {
|
||||
let auth = BasicAuth(c[1].as_str().into());
|
||||
let auth = BasicAuth(&*c[1]);
|
||||
validate(&auth, session)
|
||||
}
|
||||
"apikey" => {
|
||||
let auth = ApiKeyAuth(c[1].as_str().into());
|
||||
let auth = ApiKeyAuth(&*c[1]);
|
||||
validate(&auth, session)
|
||||
}
|
||||
"jwt" => {
|
||||
let auth = JwtAuth(c[1].as_str().into());
|
||||
let auth = JwtAuth(&*c[1]);
|
||||
validate(&auth, session)
|
||||
}
|
||||
_ => {
|
||||
|
||||
Reference in New Issue
Block a user