Skip to content

Commit

Permalink
refactor: adjust comibined auth plugin exec step
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Dec 28, 2024
1 parent c53a1eb commit 9db1bd3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/plugin/combined_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 4 additions & 5 deletions src/plugin/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ impl TryFrom<&PluginConf> for JwtAuth {
});
}

if ![PluginStep::Request]
.contains(&params.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(),
});
}

Expand Down

0 comments on commit 9db1bd3

Please sign in to comment.