diff --git a/src/api/v1/pow/get_config.rs b/src/api/v1/pow/get_config.rs index e7477f82..5e796219 100644 --- a/src/api/v1/pow/get_config.rs +++ b/src/api/v1/pow/get_config.rs @@ -38,7 +38,8 @@ pub struct GetConfigPayload { // API keys are mcaptcha actor names -#[post("/api/v1/mcaptcha/pow/config")] +#[post("/config")] +//#[post("/pow/config")] pub async fn get_config( payload: web::Json, data: web::Data, @@ -149,7 +150,7 @@ mod tests { const NAME: &str = "powusrworks"; const PASSWORD: &str = "testingpas"; const EMAIL: &str = "randomuser@a.com"; - const GET_URL: &str = "/api/v1/mcaptcha/pow/config"; + const GET_URL: &str = "/api/v1/pow/config"; // const UPDATE_URL: &str = "/api/v1/mcaptcha/domain/token/duration/update"; { diff --git a/src/api/v1/pow/mod.rs b/src/api/v1/pow/mod.rs index 18132fc1..5d2f781f 100644 --- a/src/api/v1/pow/mod.rs +++ b/src/api/v1/pow/mod.rs @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -//use actix_cors::Cors; +use actix_cors::Cors; use actix_web::web; pub mod get_config; @@ -51,6 +51,27 @@ pub use super::mcaptcha::levels::I32Levels; //} pub fn services(cfg: &mut web::ServiceConfig) { + let captcha_api_cors = Cors::default() + .allow_any_origin() + .allowed_methods(vec!["POST"]) + .allow_any_header() + .max_age(0) + .send_wildcard(); + + cfg.service( + web::scope("/api/v1/pow/") + .wrap(captcha_api_cors) + .configure(intenral_services), + ); + + // cfg.service( + + // cfg.service(get_config::get_config); + // cfg.service(verify_pow::verify_pow); + // cfg.service(verify_token::validate_captcha_token); +} + +fn intenral_services(cfg: &mut web::ServiceConfig) { cfg.service(get_config::get_config); cfg.service(verify_pow::verify_pow); cfg.service(verify_token::validate_captcha_token); diff --git a/src/api/v1/pow/verify_pow.rs b/src/api/v1/pow/verify_pow.rs index 8aeab7b1..e7b612ff 100644 --- a/src/api/v1/pow/verify_pow.rs +++ b/src/api/v1/pow/verify_pow.rs @@ -29,7 +29,7 @@ pub struct ValidationToken { // API keys are mcaptcha actor names -#[post("/api/v1/mcaptcha/pow/verify")] +#[post("/verify")] pub async fn verify_pow( payload: web::Json, data: web::Data, diff --git a/src/main.rs b/src/main.rs index 07bc5879..5f107a81 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,12 +81,12 @@ async fn main() -> std::io::Result<()> { HttpServer::new(move || { let client = Client::default(); - let captcha_api_cors = Cors::default() - .allow_any_origin() - .allowed_methods(vec!["POST"]) - .allow_any_header() - .max_age(0) - .send_wildcard(); + // let captcha_api_cors = Cors::default() + // .allow_any_origin() + // .allowed_methods(vec!["POST"]) + // .allow_any_header() + // .max_age(0) + // .send_wildcard(); App::new() .wrap(middleware::Logger::default()) @@ -97,12 +97,13 @@ async fn main() -> std::io::Result<()> { .wrap(middleware::NormalizePath::new( middleware::normalize::TrailingSlash::Trim, )) + .configure(v1::pow::services) .configure(v1::services) - .service( - scope("/api/v1/pow") - .wrap(captcha_api_cors) - .configure(v1::pow::services), - ) + //.service( + // scope("/") + // .wrap(captcha_api_cors) + // .configure(v1::pow::services), + //) .configure(docs::services) .configure(templates::services) .configure(static_assets::services)