mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Cleanup rust-analyzer warnings
This commit is contained in:
parent
da179d9930
commit
b329fb68a9
3 changed files with 16 additions and 35 deletions
|
@ -364,13 +364,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
char* doTokenExchange(const char *code) {
|
char* doTokenExchange(const char *code) {
|
||||||
|
char *ret = nullptr;
|
||||||
#if ZT_SSO_ENABLED
|
#if ZT_SSO_ENABLED
|
||||||
if (_idc == nullptr) {
|
if (_idc == nullptr) {
|
||||||
fprintf(stderr, "ainfo or idc null\n");
|
fprintf(stderr, "ainfo or idc null\n");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ret = zeroidc::zeroidc_token_exchange(_idc, code);
|
ret = zeroidc::zeroidc_token_exchange(_idc, code);
|
||||||
zeroidc::zeroidc_set_nonce_and_csrf(
|
zeroidc::zeroidc_set_nonce_and_csrf(
|
||||||
_idc,
|
_idc,
|
||||||
_config.ssoState,
|
_config.ssoState,
|
||||||
|
@ -381,11 +382,8 @@ public:
|
||||||
memcpy(_config.authenticationURL, url, strlen(url));
|
memcpy(_config.authenticationURL, url, strlen(url));
|
||||||
_config.authenticationURL[strlen(url)] = 0;
|
_config.authenticationURL[strlen(url)] = 0;
|
||||||
zeroidc::free_cstr(url);
|
zeroidc::free_cstr(url);
|
||||||
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
return "";
|
|
||||||
#endif
|
#endif
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getExpiryTime() {
|
uint64_t getExpiryTime() {
|
||||||
|
@ -1899,8 +1897,7 @@ public:
|
||||||
scode = _controller->handleControlPlaneHttpPOST(std::vector<std::string>(ps.begin()+1,ps.end()),urlArgs,headers,body,responseBody,responseContentType);
|
scode = _controller->handleControlPlaneHttpPOST(std::vector<std::string>(ps.begin()+1,ps.end()),urlArgs,headers,body,responseBody,responseContentType);
|
||||||
else scode = 404;
|
else scode = 404;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scode = 401; // isAuth == false
|
scode = 401; // isAuth == false
|
||||||
}
|
}
|
||||||
} else if (httpMethod == HTTP_DELETE) {
|
} else if (httpMethod == HTTP_DELETE) {
|
||||||
|
|
|
@ -219,7 +219,7 @@ pub extern "C" fn zeroidc_get_auth_url(ptr: *mut ZeroIDC) -> *mut c_char {
|
||||||
let idc = unsafe { &mut *ptr };
|
let idc = unsafe { &mut *ptr };
|
||||||
|
|
||||||
let s = CString::new(idc.auth_url()).unwrap();
|
let s = CString::new(idc.auth_url()).unwrap();
|
||||||
return s.into_raw();
|
s.into_raw()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
|
|
|
@ -337,10 +337,7 @@ impl ZeroIDC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!(
|
println!("Central post failed: {}", e);
|
||||||
"Central post failed: {}",
|
|
||||||
e.to_string()
|
|
||||||
);
|
|
||||||
println!(
|
println!(
|
||||||
"hit url: {}",
|
"hit url: {}",
|
||||||
e.url().unwrap().as_str()
|
e.url().unwrap().as_str()
|
||||||
|
@ -403,7 +400,7 @@ impl ZeroIDC {
|
||||||
|
|
||||||
pub fn set_nonce_and_csrf(&mut self, csrf_token: String, nonce: String) {
|
pub fn set_nonce_and_csrf(&mut self, csrf_token: String, nonce: String) {
|
||||||
let local = Arc::clone(&self.inner);
|
let local = Arc::clone(&self.inner);
|
||||||
(*local.lock().expect("can't lock inner"))
|
let _ = (*local.lock().expect("can't lock inner"))
|
||||||
.as_opt()
|
.as_opt()
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
if i.running {
|
if i.running {
|
||||||
|
@ -411,27 +408,16 @@ impl ZeroIDC {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let need_verifier = match i.pkce_verifier {
|
let need_verifier = matches!(i.pkce_verifier, None);
|
||||||
None => true,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let csrf_diff = if let Some(csrf) = i.csrf_token.clone() {
|
let csrf_diff = if let Some(csrf) = i.csrf_token.clone() {
|
||||||
if *csrf.secret() != csrf_token {
|
*csrf.secret() != csrf_token
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
let nonce_diff = if let Some(n) = i.nonce.clone() {
|
let nonce_diff = if let Some(n) = i.nonce.clone() {
|
||||||
if *n.secret() != nonce {
|
*n.secret() != nonce
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
@ -474,7 +460,7 @@ impl ZeroIDC {
|
||||||
});
|
});
|
||||||
|
|
||||||
match url {
|
match url {
|
||||||
Some(url) => url.to_string(),
|
Some(url) => url,
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,16 +617,14 @@ impl ZeroIDC {
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(bytes)
|
Ok(bytes)
|
||||||
} else {
|
} else if res.status() == 402 {
|
||||||
if res.status() == 402 {
|
|
||||||
Err(SSOExchangeError::new(
|
Err(SSOExchangeError::new(
|
||||||
"additional license seats required. Please contact your network administrator.".to_string(),
|
"additional license seats required. Please contact your network administrator.".to_string(),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Err(SSOExchangeError::new(
|
Err(SSOExchangeError::new(
|
||||||
"error from central endpoint".to_string(),
|
"error from central endpoint".to_string(),
|
||||||
))
|
))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(res) => {
|
Err(res) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue