fix redirect. config for login domain
This commit is contained in:
parent
9d7d6c2b22
commit
0406b0dc8d
@ -35,6 +35,7 @@ redirect_rpc_key_url = "https://llamanodes.com/dashboard/keys?key={rpc_key_id}"
|
|||||||
public_max_concurrent_requests = 3
|
public_max_concurrent_requests = 3
|
||||||
# 0 = block all public requests
|
# 0 = block all public requests
|
||||||
public_requests_per_period = 200
|
public_requests_per_period = 200
|
||||||
|
login_domain = "llamanodes.com"
|
||||||
|
|
||||||
# 10GB of cache
|
# 10GB of cache
|
||||||
response_cache_max_bytes = 10_000_000_000
|
response_cache_max_bytes = 10_000_000_000
|
||||||
|
@ -79,6 +79,7 @@ pub struct AppConfig {
|
|||||||
/// Restrict user registration.
|
/// Restrict user registration.
|
||||||
/// None = no code needed
|
/// None = no code needed
|
||||||
pub invite_code: Option<String>,
|
pub invite_code: Option<String>,
|
||||||
|
pub login_domain: Option<String>,
|
||||||
|
|
||||||
/// Rate limit for bearer token authenticated entrypoints.
|
/// Rate limit for bearer token authenticated entrypoints.
|
||||||
/// This is separate from the rpc limits.
|
/// This is separate from the rpc limits.
|
||||||
|
@ -56,7 +56,7 @@ pub async fn websocket_handler(
|
|||||||
None => {
|
None => {
|
||||||
if let Some(redirect) = &app.config.redirect_public_url {
|
if let Some(redirect) = &app.config.redirect_public_url {
|
||||||
// this is not a websocket. redirect to a friendly page
|
// this is not a websocket. redirect to a friendly page
|
||||||
Ok(Redirect::to(redirect).into_response())
|
Ok(Redirect::permanent(redirect).into_response())
|
||||||
} else {
|
} else {
|
||||||
// TODO: do not use an anyhow error. send the user a 400
|
// TODO: do not use an anyhow error. send the user a 400
|
||||||
Err(
|
Err(
|
||||||
@ -117,7 +117,7 @@ pub async fn websocket_handler_with_key(
|
|||||||
None,
|
None,
|
||||||
)),
|
)),
|
||||||
(Some(redirect_public_url), _, None) => {
|
(Some(redirect_public_url), _, None) => {
|
||||||
Ok(Redirect::to(redirect_public_url).into_response())
|
Ok(Redirect::permanent(redirect_public_url).into_response())
|
||||||
}
|
}
|
||||||
(_, Some(redirect_rpc_key_url), rpc_key_id) => {
|
(_, Some(redirect_rpc_key_url), rpc_key_id) => {
|
||||||
let reg = Handlebars::new();
|
let reg = Handlebars::new();
|
||||||
@ -138,7 +138,7 @@ pub async fn websocket_handler_with_key(
|
|||||||
.expect("templating should always work");
|
.expect("templating should always work");
|
||||||
|
|
||||||
// this is not a websocket. redirect to a page for this user
|
// this is not a websocket. redirect to a page for this user
|
||||||
Ok(Redirect::to(&redirect_rpc_key_url).into_response())
|
Ok(Redirect::permanent(&redirect_rpc_key_url).into_response())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// any other combinations get a simple error
|
// any other combinations get a simple error
|
||||||
|
@ -85,13 +85,20 @@ pub async fn user_login_get(
|
|||||||
// TODO: map_err so this becomes a 401
|
// TODO: map_err so this becomes a 401
|
||||||
.context("bad input")?;
|
.context("bad input")?;
|
||||||
|
|
||||||
|
let login_domain = app
|
||||||
|
.config
|
||||||
|
.login_domain
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| "llamanodes.com".to_string());
|
||||||
|
|
||||||
// TODO: get most of these from the app config
|
// TODO: get most of these from the app config
|
||||||
let message = Message {
|
let message = Message {
|
||||||
// TODO: get this from app config
|
// TODO: don't unwrap
|
||||||
domain: "llamanodes.com".parse().unwrap(),
|
domain: login_domain.parse().unwrap(),
|
||||||
address: user_address.to_fixed_bytes(),
|
address: user_address.to_fixed_bytes(),
|
||||||
statement: Some("🦙🦙🦙🦙🦙".to_string()),
|
statement: Some("🦙🦙🦙🦙🦙".to_string()),
|
||||||
uri: "https://llamanodes.com/".parse().unwrap(),
|
// TODO: don't unwrap
|
||||||
|
uri: format!("https://{}/", login_domain).parse().unwrap(),
|
||||||
version: siwe::Version::V1,
|
version: siwe::Version::V1,
|
||||||
chain_id: 1,
|
chain_id: 1,
|
||||||
expiration_time: Some(expiration_time.into()),
|
expiration_time: Some(expiration_time.into()),
|
||||||
|
Loading…
Reference in New Issue
Block a user