mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
Show sso errors on the last step of the oidc process
This commit is contained in:
parent
93076dde56
commit
3f19e7d73c
@ -147,8 +147,47 @@ size_t curlResponseWrite(void *ptr, size_t size, size_t nmemb, std::string *data
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
|
const char *ssoResponseTemplate = "<html>\
|
||||||
|
<head>\
|
||||||
|
<style type=\"text/css\">\
|
||||||
|
html,body {\
|
||||||
|
background: #eeeeee;\
|
||||||
|
margin: 0;\
|
||||||
|
padding: 0;\
|
||||||
|
font-family: \"Helvetica\";\
|
||||||
|
font-weight: bold;\
|
||||||
|
font-size: 12pt;\
|
||||||
|
height: 100%;\
|
||||||
|
width: 100%;\
|
||||||
|
}\
|
||||||
|
div.icon {\
|
||||||
|
background: #ffb354;\
|
||||||
|
color: #000000;\
|
||||||
|
font-size: 120pt;\
|
||||||
|
border-radius: 2.5rem;\
|
||||||
|
display: inline-block;\
|
||||||
|
width: 1.3em;\
|
||||||
|
height: 1.3em;\
|
||||||
|
padding: 0;\
|
||||||
|
margin: 15;\
|
||||||
|
line-height: 1.4em;\
|
||||||
|
vertical-align: middle;\
|
||||||
|
text-align: center;\
|
||||||
|
}\
|
||||||
|
</style>\
|
||||||
|
</head>\
|
||||||
|
<body>\
|
||||||
|
<br><br><br><br><br><br>\
|
||||||
|
<center>\
|
||||||
|
<div class=\"icon\">⏁</div>\
|
||||||
|
<div class=\"text\">%s</div>\
|
||||||
|
</center>\
|
||||||
|
</body>\
|
||||||
|
</html>";
|
||||||
|
|
||||||
// Configured networks
|
// Configured networks
|
||||||
class NetworkState
|
class NetworkState
|
||||||
{
|
{
|
||||||
@ -1668,8 +1707,21 @@ public:
|
|||||||
}
|
}
|
||||||
#if OIDC_SUPPORTED
|
#if OIDC_SUPPORTED
|
||||||
} else if (ps[0] == "sso") {
|
} else if (ps[0] == "sso") {
|
||||||
|
char resBuf[4096] = {0};
|
||||||
|
const char *error = zeroidc::zeroidc_get_url_param_value("error", path.c_str());
|
||||||
|
if (error != nullptr) {
|
||||||
|
const char *desc = zeroidc::zeroidc_get_url_param_value("error_description", path.c_str());
|
||||||
|
scode = 500;
|
||||||
|
char errBuff[256] = {0};
|
||||||
|
sprintf(errBuff, "ERROR %s: %s", error, desc);
|
||||||
|
sprintf(resBuf, ssoResponseTemplate, errBuff);
|
||||||
|
responseBody = std::string(resBuf);
|
||||||
|
responseContentType = "text/html";
|
||||||
|
return scode;
|
||||||
|
}
|
||||||
|
|
||||||
// SSO redirect handling
|
// SSO redirect handling
|
||||||
const char* state = zeroidc::zeroidc_get_url_param_value("state", path.c_str());
|
const char* state = zeroidc::zeroidc_get_url_param_value("state", path.c_str());
|
||||||
const char* nwid = zeroidc::zeroidc_network_id_from_state(state);
|
const char* nwid = zeroidc::zeroidc_network_id_from_state(state);
|
||||||
|
|
||||||
const uint64_t id = Utils::hexStrToU64(nwid);
|
const uint64_t id = Utils::hexStrToU64(nwid);
|
||||||
@ -1679,43 +1731,9 @@ public:
|
|||||||
const char* code = zeroidc::zeroidc_get_url_param_value("code", path.c_str());
|
const char* code = zeroidc::zeroidc_get_url_param_value("code", path.c_str());
|
||||||
ns.doTokenExchange(code);
|
ns.doTokenExchange(code);
|
||||||
scode = 200;
|
scode = 200;
|
||||||
responseBody = "<html>\
|
sprintf(resBuf, ssoResponseTemplate, "Authentication Successful. You may now access the network.");
|
||||||
<head>\
|
responseBody = std::string(resBuf);
|
||||||
<style type=\"text/css\">\
|
|
||||||
html,body {\
|
|
||||||
background: #eeeeee;\
|
|
||||||
margin: 0;\
|
|
||||||
padding: 0;\
|
|
||||||
font-family: \"Helvetica\";\
|
|
||||||
font-weight: bold;\
|
|
||||||
font-size: 12pt;\
|
|
||||||
height: 100%;\
|
|
||||||
width: 100%;\
|
|
||||||
}\
|
|
||||||
div.icon {\
|
|
||||||
background: #ffb354;\
|
|
||||||
color: #000000;\
|
|
||||||
font-size: 120pt;\
|
|
||||||
border-radius: 2.5rem;\
|
|
||||||
display: inline-block;\
|
|
||||||
width: 1.3em;\
|
|
||||||
height: 1.3em;\
|
|
||||||
padding: 0;\
|
|
||||||
margin: 15;\
|
|
||||||
line-height: 1.4em;\
|
|
||||||
vertical-align: middle;\
|
|
||||||
text-align: center;\
|
|
||||||
}\
|
|
||||||
</style>\
|
|
||||||
</head>\
|
|
||||||
<body>\
|
|
||||||
<br><br><br><br><br><br>\
|
|
||||||
<center>\
|
|
||||||
<div class=\"icon\">⏁</div>\
|
|
||||||
<div class=\"text\">Authentication Successful. You may now access the network.</div>\
|
|
||||||
</center>\
|
|
||||||
</body>\
|
|
||||||
</html>";
|
|
||||||
responseContentType = "text/html";
|
responseContentType = "text/html";
|
||||||
return scode;
|
return scode;
|
||||||
} else {
|
} else {
|
||||||
|
@ -325,6 +325,13 @@ impl ZeroIDC {
|
|||||||
println!("Central post failed: {}", r.status().to_string());
|
println!("Central post failed: {}", r.status().to_string());
|
||||||
println!("hit url: {}", r.url().as_str());
|
println!("hit url: {}", r.url().as_str());
|
||||||
println!("Status: {}", r.status());
|
println!("Status: {}", r.status());
|
||||||
|
if let Ok(body) = r.bytes() {
|
||||||
|
if let Ok(body) = std::str::from_utf8(&body) {
|
||||||
|
println!("Body: {}", body);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
(*inner_local.lock().unwrap()).exp_time = 0;
|
(*inner_local.lock().unwrap()).exp_time = 0;
|
||||||
(*inner_local.lock().unwrap()).running = false;
|
(*inner_local.lock().unwrap()).running = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user