cors for pow routes

This commit is contained in:
realaravinth
2021-04-11 23:40:36 +05:30
parent 0d1ba0d150
commit 8851b1f7b7
4 changed files with 40 additions and 10 deletions

View File

@@ -52,11 +52,6 @@ pub fn services(cfg: &mut ServiceConfig) {
// duration
cfg.service(mcaptcha::duration::update_duration);
cfg.service(mcaptcha::duration::get_duration);
// pow
cfg.service(pow::get_config::get_config);
cfg.service(pow::verify_pow::verify_pow);
cfg.service(pow::verify_token::validate_captcha_token);
}
#[cfg(test)]

View File

@@ -16,7 +16,7 @@
*/
//use actix_cors::Cors;
//use lazy_static::lazy_static;
use actix_web::web;
pub mod get_config;
pub mod verify_pow;
@@ -34,3 +34,24 @@ pub use super::mcaptcha::levels::I32Levels;
// .max_age(0)
// .send_wildcard();
//}
//pub fn services(cfg: &mut web::ServiceConfig) -> web::Scope<impl actix_service::ServiceFactory> {
// let captcha_api_cors = Cors::default()
// .allow_any_origin()
// .allowed_methods(vec!["POST"])
// .allow_any_header()
// .max_age(0)
// .send_wildcard();
//
// web::scope("/api/v1/pow/*")
// .wrap(captcha_api_cors)
// .configure(pow_services)
//
// // pow
//}
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.service(get_config::get_config);
cfg.service(verify_pow::verify_pow);
cfg.service(verify_token::validate_captcha_token);
}

View File

@@ -29,7 +29,7 @@ pub struct CaptchaValidateResp {
// API keys are mcaptcha actor names
#[post("/api/v1/siteverify")]
#[post("/api/v1/pow/siteverify")]
pub async fn validate_captcha_token(
payload: web::Json<VerifyCaptchaResult>,
data: web::Data<Data>,
@@ -64,7 +64,7 @@ mod tests {
const EMAIL: &str = "verifyuser@enter.com";
const VERIFY_CAPTCHA_URL: &str = "/api/v1/mcaptcha/pow/verify";
const GET_URL: &str = "/api/v1/mcaptcha/pow/config";
const VERIFY_TOKEN_URL: &str = "/api/v1/siteverify";
const VERIFY_TOKEN_URL: &str = "/api/v1/pow/siteverify";
// const UPDATE_URL: &str = "/api/v1/mcaptcha/domain/token/duration/update";
{