-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webhooks): add support for "subdomain"-based webhook URLs
- Loading branch information
Showing
23 changed files
with
1,384 additions
and
594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,9 @@ mod templates; | |
mod users; | ||
mod utils; | ||
|
||
use crate::config::{ | ||
ComponentsConfig, Config, SchedulerJobsConfig, SmtpCatchAllConfig, SmtpConfig, | ||
use crate::{ | ||
config::{ComponentsConfig, Config, SchedulerJobsConfig, SmtpCatchAllConfig, SmtpConfig}, | ||
server::WebhookUrlType, | ||
}; | ||
use anyhow::{anyhow, Context}; | ||
use bytes::Buf; | ||
|
@@ -81,6 +82,13 @@ fn process_command(version: &str, matches: ArgMatches) -> Result<(), anyhow::Err | |
Url::parse(public_url) | ||
.with_context(|| "Cannot parse public URL parameter.".to_string()) | ||
})?, | ||
webhook_url_type: matches | ||
.get_one::<String>("WEBHOOK_URL_TYPE") | ||
.ok_or_else(|| anyhow!("<WEBHOOK_URL_TYPE> argument is not provided.")) | ||
.and_then(|webhook_url_type| { | ||
WebhookUrlType::from_str(webhook_url_type) | ||
.with_context(|| "Cannot parse webhook URL type parameter.".to_string()) | ||
})?, | ||
components: ComponentsConfig { | ||
web_scraper_url: matches | ||
.get_one::<String>("COMPONENT_WEB_SCRAPER_URL") | ||
|
@@ -228,6 +236,15 @@ fn main() -> Result<(), anyhow::Error> { | |
.default_value("http://localhost:7070") | ||
.help("External/public URL through which service is being accessed."), | ||
) | ||
.arg( | ||
Arg::new("WEBHOOK_URL_TYPE") | ||
.long("webhook-url-type") | ||
.global(true) | ||
.env("SECUTILS_WEBHOOK_URL_TYPE") | ||
.default_value("path") | ||
.value_names(["path", "subdomain"]) | ||
.help("Describes how Secutils.dev WebUI should construct webhook URLs. The server supports all types of URL simultaneously."), | ||
) | ||
.arg( | ||
Arg::new("COMPONENT_WEB_SCRAPER_URL") | ||
.long("component-web-scraper-url") | ||
|
@@ -290,7 +307,7 @@ mod tests { | |
use url::Url; | ||
|
||
pub use crate::{network::tests::*, server::tests::*, utils::tests::*}; | ||
use crate::{search::SearchIndex, templates::create_templates}; | ||
use crate::{search::SearchIndex, server::WebhookUrlType, templates::create_templates}; | ||
|
||
pub struct MockUserBuilder { | ||
user: User, | ||
|
@@ -451,6 +468,7 @@ mod tests { | |
version: "1.0.0".to_string(), | ||
http_port: 1234, | ||
public_url: Url::parse("http://localhost:1234")?, | ||
webhook_url_type: WebhookUrlType::Subdomain, | ||
smtp: Some(SmtpConfig { | ||
username: "[email protected]".to_string(), | ||
password: "password".to_string(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.