Skip to content

Commit 3e93989

Browse files
committed
update deps and remove CORS
1 parent e583569 commit 3e93989

7 files changed

Lines changed: 784 additions & 1422 deletions

File tree

Cargo.lock

Lines changed: 769 additions & 1376 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ authors = ["Florian Merz <flomerz@gmail.com>"]
55
edition = "2018"
66

77
[dependencies]
8-
dino_park_gate = { git = "https://github.com/fiji-flo/dino-park-gate", branch = "0.3.0", version = "0.3.0" }
9-
cis_client = { git = "https://github.com/mozilla-iam/cis_client-rust", branch = "0.4.0", version = "0.4.0", features = ["sync"] }
10-
cis_profile = { git = "https://github.com/mozilla-iam/cis_profile-rust", branch = "0.3.1", version = "0.3.1" }
8+
cis_client = { git = "https://github.com/mozilla-iam/cis_client-rust", tag = "0.6.2", version = "0.6.2", features = ["sync"] }
9+
cis_profile = { git = "https://github.com/mozilla-iam/cis_profile-rust", tag = "0.4.1", version = "0.4.1", features = ["aws", "vendored"] }
10+
dino_park_gate = { git = "https://github.com/mozilla-iam/dino-park-gate", tag = "0.7.0", version = "0.7.0" }
1111
actix-web = "2.0"
1212
actix-rt = "1.0"
1313
actix-cors = "0.2"

src/events/app.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use crate::notification::Notification;
22
use crate::updater::UpdaterClient;
3-
use actix_cors::Cors;
43
use actix_web::dev::HttpServiceFactory;
5-
use actix_web::http;
64
use actix_web::web;
75
use actix_web::web::Data;
86
use actix_web::web::Json;
@@ -22,14 +20,6 @@ pub fn update_app<U: UpdaterClient + Clone + Send + 'static>(
2220
updater: U,
2321
) -> impl HttpServiceFactory {
2422
web::scope("/update")
25-
.wrap(
26-
Cors::new()
27-
.allowed_methods(vec!["POST"])
28-
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
29-
.allowed_header(http::header::CONTENT_TYPE)
30-
.max_age(3600)
31-
.finish(),
32-
)
3323
.data(updater)
3424
.service(web::resource("").route(web::post().to(update_event::<U>)))
3525
}

src/healthz.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use actix_cors::Cors;
21
use actix_web::dev::HttpServiceFactory;
3-
use actix_web::http;
42
use actix_web::web;
53
use actix_web::HttpRequest;
64
use actix_web::HttpResponse;
@@ -10,14 +8,5 @@ fn healthz(_: HttpRequest) -> HttpResponse {
108
}
119

1210
pub fn healthz_app() -> impl HttpServiceFactory {
13-
web::scope("/healthz")
14-
.wrap(
15-
Cors::new()
16-
.allowed_methods(vec!["GET", "HEAD"])
17-
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
18-
.allowed_header(http::header::CONTENT_TYPE)
19-
.max_age(3600)
20-
.finish(),
21-
)
22-
.service(web::resource("").to(healthz))
11+
web::scope("/healthz").service(web::resource("").to(healthz))
2312
}

src/internal/app.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ use crate::bulk::Bulk;
22
use crate::settings::DinoParkSettings;
33
use crate::updater::send_profile;
44
use crate::updater::UpdaterClient;
5-
use actix_cors::Cors;
65
use actix_web::dev::HttpServiceFactory;
76
use actix_web::error;
87
use actix_web::error::Error;
9-
use actix_web::http;
108
use actix_web::web;
119
use actix_web::web::Data;
1210
use actix_web::web::Json;
@@ -56,14 +54,6 @@ pub fn internal_app<U: UpdaterClient + Clone + Send + 'static>(
5654
updater: U,
5755
) -> impl HttpServiceFactory {
5856
web::scope("")
59-
.wrap(
60-
Cors::new()
61-
.allowed_methods(vec!["POST"])
62-
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
63-
.allowed_header(http::header::CONTENT_TYPE)
64-
.max_age(3600)
65-
.finish(),
66-
)
6757
.data(updater)
6858
.data(dino_park_settings)
6959
.app_data(web::JsonConfig::default().limit(1_048_576))

src/main.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ fn main() -> Result<(), Error> {
3939
);
4040
env_logger::init();
4141
info!("building the lookout");
42+
let mut rt = System::new("lookout-actix-rt");
4243
let s = settings::Settings::new().map_err(|e| format_err!("unable to load settings: {}", e))?;
43-
let cis_client = CisClient::from_settings(&s.cis)
44-
.map_err(|e| format_err!("unable to create cis_client: {}", e))?;
44+
let cis_settings = s.cis.clone();
45+
let cis_client = rt.block_on(async move {
46+
CisClient::from_settings(&cis_settings)
47+
.await
48+
.map_err(|e| format_err!("unable to create cis_client: {}", e))
49+
})?;
4550
let dino_park = s.dino_park.clone();
4651
let validation_settings = s.auth.validation.clone();
47-
let mut rt = tokio::runtime::Runtime::new()?;
48-
let provider = rt.block_on(Provider::from_issuer(&s.auth.issuer))?;
52+
let issuer = s.auth.issuer;
53+
let provider = rt.block_on(async move { Provider::from_issuer(&issuer).await })?;
4954
// Start http server
5055
let updater = InternalUpdater::new(cis_client, dino_park.clone());
5156

@@ -76,7 +81,7 @@ fn main() -> Result<(), Error> {
7681
})
7782
.bind("0.0.0.0:8082")?;
7883

79-
System::new("lookout-actix-rt").block_on(async move { server.run().await })?;
84+
rt.block_on(async move { server.run().await })?;
8085

8186
info!("Stopped http server");
8287
stop_client.stop();

src/updater.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,7 @@ pub async fn update(
204204
};
205205
info!(
206206
"{} is active: {}",
207-
profile
208-
.user_id
209-
.value
210-
.as_ref()
211-
.map(String::as_str)
212-
.unwrap_or_else(|| "?"),
207+
profile.user_id.value.as_deref().unwrap_or_else(|| "?"),
213208
profile.active.value.as_ref().unwrap_or_else(|| &false)
214209
);
215210
send_profile(dp, profile).await

0 commit comments

Comments
 (0)