mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-18 13:23:50 +08:00
fix: fix bugs about 3rd-party login in cas flow (#1096)
This commit is contained in:

committed by
GitHub

parent
7599e2715a
commit
d8b60f838e
@ -50,8 +50,12 @@ class AuthCallback extends React.Component {
|
|||||||
// Casdoor's own login page, so "code" is not necessary
|
// Casdoor's own login page, so "code" is not necessary
|
||||||
if (realRedirectUri === null) {
|
if (realRedirectUri === null) {
|
||||||
const samlRequest = innerParams.get("SAMLRequest");
|
const samlRequest = innerParams.get("SAMLRequest");
|
||||||
|
// cas don't use 'redirect_url', it is called 'service'
|
||||||
|
const casService = innerParams.get("service");
|
||||||
if (samlRequest !== null && samlRequest !== undefined && samlRequest !== "") {
|
if (samlRequest !== null && samlRequest !== undefined && samlRequest !== "") {
|
||||||
return "saml";
|
return "saml";
|
||||||
|
} else if (casService !== null && casService !== undefined && casService !== "") {
|
||||||
|
return "cas";
|
||||||
}
|
}
|
||||||
return "login";
|
return "login";
|
||||||
}
|
}
|
||||||
@ -97,6 +101,7 @@ class AuthCallback extends React.Component {
|
|||||||
const providerName = innerParams.get("provider");
|
const providerName = innerParams.get("provider");
|
||||||
const method = innerParams.get("method");
|
const method = innerParams.get("method");
|
||||||
const samlRequest = innerParams.get("SAMLRequest");
|
const samlRequest = innerParams.get("SAMLRequest");
|
||||||
|
const casService = innerParams.get("service");
|
||||||
|
|
||||||
const redirectUri = `${window.location.origin}/callback`;
|
const redirectUri = `${window.location.origin}/callback`;
|
||||||
|
|
||||||
@ -111,6 +116,31 @@ class AuthCallback extends React.Component {
|
|||||||
redirectUri: redirectUri,
|
redirectUri: redirectUri,
|
||||||
method: method,
|
method: method,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.getResponseType() === "cas") {
|
||||||
|
// user is using casdoor as cas sso server, and wants the ticket to be acquired
|
||||||
|
AuthBackend.loginCas(body, {"service": casService}).then((res) => {
|
||||||
|
if (res.status === "ok") {
|
||||||
|
let msg = "Logged in successfully.";
|
||||||
|
if (casService === "") {
|
||||||
|
// If service was not specified, Casdoor must display a message notifying the client that it has successfully initiated a single sign-on session.
|
||||||
|
msg += "Now you can visit apps protected by Casdoor.";
|
||||||
|
}
|
||||||
|
Util.showMessage("success", msg);
|
||||||
|
|
||||||
|
if (casService !== "") {
|
||||||
|
const st = res.data;
|
||||||
|
const newUrl = new URL(casService);
|
||||||
|
newUrl.searchParams.append("ticket", st);
|
||||||
|
window.location.href = newUrl.toString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Util.showMessage("error", `Failed to log in: ${res.msg}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// OAuth
|
||||||
const oAuthParams = Util.getOAuthGetParameters(innerParams);
|
const oAuthParams = Util.getOAuthGetParameters(innerParams);
|
||||||
const concatChar = oAuthParams?.redirectUri?.includes("?") ? "&" : "?";
|
const concatChar = oAuthParams?.redirectUri?.includes("?") ? "&" : "?";
|
||||||
AuthBackend.login(body, oAuthParams)
|
AuthBackend.login(body, oAuthParams)
|
||||||
|
Reference in New Issue
Block a user