Skip to content

Commit bd3626f

Browse files
authored
Merge pull request #30 from Manta-Network/cors-release-check
feat: add unsafe CORS disable feature for dev
2 parents 6df2c6e + 2c75be7 commit bd3626f

File tree

6 files changed

+142
-83
lines changed

6 files changed

+142
-83
lines changed

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ is-it-maintained-issue-resolution = { repository = "Manta-Network/manta-signer"
2424
is-it-maintained-open-issues = { repository = "Manta-Network/manta-signer" }
2525
maintenance = { status = "actively-developed" }
2626

27+
[features]
28+
# Disable CORS Check
29+
unsafe-disable-cors = []
30+
2731
[dependencies]
2832
ark-serialize = { version = "0.3.0", default-features = false }
2933
async-std = { version = "1.10.0" }
30-
bip0039 = { version = "0.9.0" }
34+
bip0039 = { version = "0.10.0" }
3135
bip32 = { version = "0.2.2" }
3236
bs58 = { version = "0.4.0" }
3337
cocoon = { version = "0.3.0" }
@@ -43,7 +47,7 @@ manta-data = { git = "https://github.com/Manta-Network/manta-types", branch = "m
4347
rand = { version = "0.8.4", default-features = false }
4448
rand_chacha = { version = "0.3.1", default-features = false }
4549
secrecy = { version = "0.8.0", default-features = false, features = ["alloc"] }
46-
serde = { version = "1.0.130", default-features = false, features = ["derive"] }
50+
serde = { version = "1.0.131", default-features = false, features = ["derive"] }
4751
serde_json = { version = "1.0.68", default-features = false }
4852
subtle = { version = "2.4.1" }
4953
tide = { version = "0.16.0" }

release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ EOF
4141

4242
# curl ...
4343
# mv *.bin ui
44-
# cd ui
45-
# cargo tauri build --bundle dmg deb msi
44+
cd ui
45+
cargo tauri build
4646

4747
echo "release"
4848

src/config.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ pub struct Config {
5757
/// Service URL
5858
pub service_url: String,
5959

60-
/// Dev origin URL
61-
pub dev_origin_url: String,
62-
63-
/// Prod origin URL
64-
pub prod_origin_url: String,
60+
/// Origin URL
61+
pub origin_url: String,
6562
}
6663

6764
impl Config {
@@ -72,8 +69,10 @@ impl Config {
7269
root_seed_file: file(dirs_next::config_dir(), "root_seed.aes")?,
7370
proving_key_directory: directory(dirs_next::data_local_dir())?,
7471
service_url: String::from("http://127.0.0.1:29987"),
75-
dev_origin_url: String::from("http://localhost:8000"),
76-
prod_origin_url: String::from("https://app.dolphin.manta.network"),
72+
#[cfg(feature = "unsafe-disable-cors")]
73+
origin_url: String::from("*"),
74+
#[cfg(not(feature = "unsafe-disable-cors"))]
75+
origin_url: String::from("https://app.dolphin.manta.network"),
7776
})
7877
}
7978

src/service.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,9 @@ where
312312
/// Builds a new [`Service`] from `config` and `authorizer`.
313313
#[inline]
314314
pub fn build(config: Config, authorizer: A) -> Self {
315-
// FIXME: This is not the best strategy for choosing which URL we want.
316-
#[cfg(debug_assertions)]
317-
let url = config.dev_origin_url.as_str();
318-
#[cfg(not(debug_assertions))]
319-
let url = config.prod_origin_url.as_str();
320-
321315
let cors = CorsMiddleware::new()
322316
.allow_methods("GET, POST".parse::<HeaderValue>().unwrap())
323-
.allow_origin(Origin::from(url))
317+
.allow_origin(Origin::from(config.origin_url.as_str()))
324318
.allow_credentials(false);
325319
let mut server = Server::with_state(State::new(config, authorizer));
326320
server.with(cors);

0 commit comments

Comments
 (0)