From 9db1bd3865df6dedbde6995399c5ede88aa59d5d Mon Sep 17 00:00:00 2001 From: vicanso Date: Sat, 28 Dec 2024 11:05:12 +0800 Subject: [PATCH] refactor: adjust comibined auth plugin exec step --- src/plugin/combined_auth.rs | 10 +++++++++- src/plugin/jwt.rs | 9 ++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/plugin/combined_auth.rs b/src/plugin/combined_auth.rs index 834cf4fc..4e818673 100644 --- a/src/plugin/combined_auth.rs +++ b/src/plugin/combined_auth.rs @@ -16,7 +16,7 @@ use super::{ get_hash_key, get_int_conf, get_step_conf, get_str_conf, get_str_slice_conf, Error, Plugin, Result, }; -use crate::config::{PluginConf, PluginStep}; +use crate::config::{PluginCategory, PluginConf, PluginStep}; use crate::http_extra::{HttpResponse, HTTP_HEADER_NO_STORE}; use crate::state::State; use crate::util; @@ -84,6 +84,14 @@ impl TryFrom<&PluginConf> for CombinedAuth { }, ); } + if PluginStep::Request != step { + return Err(Error::Invalid { + category: PluginCategory::CombinedAuth.to_string(), + message: + "Combined auth plugin should be executed at request step" + .to_string(), + }); + } Ok(Self { plugin_step: step, diff --git a/src/plugin/jwt.rs b/src/plugin/jwt.rs index e72228bc..8614cc61 100644 --- a/src/plugin/jwt.rs +++ b/src/plugin/jwt.rs @@ -101,12 +101,11 @@ impl TryFrom<&PluginConf> for JwtAuth { }); } - if ![PluginStep::Request] - .contains(¶ms.plugin_step) - { + if PluginStep::Request != params.plugin_step { return Err(Error::Invalid { - category: PluginCategory::IpRestriction.to_string(), - message: "Jwt auth plugin should be executed at request step".to_string(), + category: PluginCategory::Jwt.to_string(), + message: "Jwt auth plugin should be executed at request step" + .to_string(), }); }