Skip to content

Commit

Permalink
Allow LocalStack to run Authress Local.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Aug 27, 2023
1 parent ad8acf3 commit 78ca6b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"cSpell.words": [
"accidentally",
"chrono",
"localstack",
"Permissioned",
"RESOURCEURI",
"rustup",
"accidentally"
"rustup"
],
"cSpell.ignoreRegExpList": ["[a-z]+ID"]
}
13 changes: 9 additions & 4 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ pub const CREATE_AN_AUTHRESS_ACCOUNT: &str = "
Your configuration of Authress Local is currently open to vulnerabilities. To prevent these vulnerabilities the container blocked access. To use Authress Local in production, first create a free Authress account at: https://authress.io.
****************************************************
****************************************************\n";
********************************************************************************
********************************************************************************\n";

mod paths {
use lazy_static::lazy_static;
Expand Down Expand Up @@ -425,11 +425,16 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where

if let Some(header_value) = host_header {
// if let header_values = header::IntoHeaderValue::<String>::try_from((*header_value).clone()) {
if !header_value.is_empty() && !header_value.to_str().unwrap().starts_with("localhost") && !header_value.to_str().unwrap().starts_with("127.0.")
if !header_value.is_empty()
&& !header_value.to_str().unwrap().starts_with("localhost")
&& !header_value.to_str().unwrap().starts_with("authress.localhost.localstack.cloud")
&& !header_value.to_str().unwrap().starts_with("127.0.")
&& !header_value.to_str().unwrap().starts_with("0.0.0.0") && !header_value.to_str().unwrap().starts_with("::1") {
let host_value = header_value.to_str().unwrap();
info!("The Host header '{}' was found with the request. To use Authress Local in production, first create a free Authress account at: https://authress.io.", host_value);
return Ok(Response::builder().status(StatusCode::IM_A_TEAPOT).body(Body::from(CREATE_AN_AUTHRESS_ACCOUNT))?);
return Ok(Response::builder()
.status(StatusCode::IM_A_TEAPOT)
.body(Body::from(CREATE_AN_AUTHRESS_ACCOUNT))?);
}
};

Expand Down

0 comments on commit 78ca6b3

Please sign in to comment.