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
|
||||
# 0 = block all public requests
|
||||
public_requests_per_period = 200
|
||||
login_domain = "llamanodes.com"
|
||||
|
||||
# 10GB of cache
|
||||
response_cache_max_bytes = 10_000_000_000
|
||||
|
@ -79,6 +79,7 @@ pub struct AppConfig {
|
||||
/// Restrict user registration.
|
||||
/// None = no code needed
|
||||
pub invite_code: Option<String>,
|
||||
pub login_domain: Option<String>,
|
||||
|
||||
/// Rate limit for bearer token authenticated entrypoints.
|
||||
/// This is separate from the rpc limits.
|
||||
|
@ -56,7 +56,7 @@ pub async fn websocket_handler(
|
||||
None => {
|
||||
if let Some(redirect) = &app.config.redirect_public_url {
|
||||
// this is not a websocket. redirect to a friendly page
|
||||
Ok(Redirect::to(redirect).into_response())
|
||||
Ok(Redirect::permanent(redirect).into_response())
|
||||
} else {
|
||||
// TODO: do not use an anyhow error. send the user a 400
|
||||
Err(
|
||||
@ -117,7 +117,7 @@ pub async fn websocket_handler_with_key(
|
||||
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) => {
|
||||
let reg = Handlebars::new();
|
||||
@ -138,7 +138,7 @@ pub async fn websocket_handler_with_key(
|
||||
.expect("templating should always work");
|
||||
|
||||
// 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
|
||||
|
@ -85,13 +85,20 @@ pub async fn user_login_get(
|
||||
// TODO: map_err so this becomes a 401
|
||||
.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
|
||||
let message = Message {
|
||||
// TODO: get this from app config
|
||||
domain: "llamanodes.com".parse().unwrap(),
|
||||
// TODO: don't unwrap
|
||||
domain: login_domain.parse().unwrap(),
|
||||
address: user_address.to_fixed_bytes(),
|
||||
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,
|
||||
chain_id: 1,
|
||||
expiration_time: Some(expiration_time.into()),
|
||||
|
Loading…
Reference in New Issue
Block a user