mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
TIL: Its not as hard as I thought to make Rust deadlock
This commit is contained in:
parent
b567e91f68
commit
0ab5cce878
1 changed files with 10 additions and 6 deletions
|
@ -343,6 +343,7 @@ impl ZeroIDC {
|
||||||
|
|
||||||
fn do_token_exchange(&mut self, code: &str) {
|
fn do_token_exchange(&mut self, code: &str) {
|
||||||
let local = Arc::clone(&self.inner);
|
let local = Arc::clone(&self.inner);
|
||||||
|
let mut should_start = false;
|
||||||
(*local.lock().unwrap()).as_opt().map(|i| {
|
(*local.lock().unwrap()).as_opt().map(|i| {
|
||||||
if let Some(verifier) = i.pkce_verifier.take() {
|
if let Some(verifier) = i.pkce_verifier.take() {
|
||||||
let token_response = i.oidc_client.as_ref().map(|c| {
|
let token_response = i.oidc_client.as_ref().map(|c| {
|
||||||
|
@ -378,7 +379,7 @@ impl ZeroIDC {
|
||||||
if split.len() == 2 {
|
if split.len() == 2 {
|
||||||
let params = [("id_token", id_token.to_string()),("state", split[0].to_string())];
|
let params = [("id_token", id_token.to_string()),("state", split[0].to_string())];
|
||||||
let client = reqwest::blocking::Client::new();
|
let client = reqwest::blocking::Client::new();
|
||||||
let res = client.post((*self.inner.lock().unwrap()).auth_endpoint.clone())
|
let res = client.post(i.auth_endpoint.clone())
|
||||||
.form(¶ms)
|
.form(¶ms)
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
|
@ -390,20 +391,20 @@ impl ZeroIDC {
|
||||||
let at = tok.access_token().secret();
|
let at = tok.access_token().secret();
|
||||||
let exp = dangerous_insecure_decode::<Exp>(&at);
|
let exp = dangerous_insecure_decode::<Exp>(&at);
|
||||||
if let Ok(e) = exp {
|
if let Ok(e) = exp {
|
||||||
(*self.inner.lock().unwrap()).exp_time = e.claims.exp
|
i.exp_time = e.claims.exp
|
||||||
}
|
}
|
||||||
|
|
||||||
(*self.inner.lock().unwrap()).access_token = Some(tok.access_token().clone());
|
i.access_token = Some(tok.access_token().clone());
|
||||||
if let Some(t) = tok.refresh_token() {
|
if let Some(t) = tok.refresh_token() {
|
||||||
(*self.inner.lock().unwrap()).refresh_token = Some(t.clone());
|
i.refresh_token = Some(t.clone());
|
||||||
self.start();
|
should_start = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(res) => {
|
Err(res) => {
|
||||||
println!("hit url: {}", res.url().unwrap().as_str());
|
println!("hit url: {}", res.url().unwrap().as_str());
|
||||||
println!("Status: {}", res.status().unwrap());
|
println!("Status: {}", res.status().unwrap());
|
||||||
println!("Post error: {}", res.to_string());
|
println!("Post error: {}", res.to_string());
|
||||||
(*self.inner.lock().unwrap()).exp_time = 0;
|
i.exp_time = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,6 +419,9 @@ impl ZeroIDC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if should_start {
|
||||||
|
self.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue