mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-18 00:03:50 +08:00
feat: fix bugs in webauthn (#1173)
This commit is contained in:

committed by
GitHub

parent
645c631db9
commit
9c48582e0c
@ -121,6 +121,7 @@ func (c *ApiController) WebAuthnSigninBegin() {
|
|||||||
// @Success 200 {object} Response "The Response object"
|
// @Success 200 {object} Response "The Response object"
|
||||||
// @router /webauthn/signin/finish [post]
|
// @router /webauthn/signin/finish [post]
|
||||||
func (c *ApiController) WebAuthnSigninFinish() {
|
func (c *ApiController) WebAuthnSigninFinish() {
|
||||||
|
responseType := c.Input().Get("responseType")
|
||||||
webauthnObj := object.GetWebAuthnObject(c.Ctx.Request.Host)
|
webauthnObj := object.GetWebAuthnObject(c.Ctx.Request.Host)
|
||||||
sessionObj := c.GetSession("authentication")
|
sessionObj := c.GetSession("authentication")
|
||||||
sessionData, ok := sessionObj.(webauthn.SessionData)
|
sessionData, ok := sessionObj.(webauthn.SessionData)
|
||||||
@ -138,5 +139,11 @@ func (c *ApiController) WebAuthnSigninFinish() {
|
|||||||
}
|
}
|
||||||
c.SetSessionUsername(userId)
|
c.SetSessionUsername(userId)
|
||||||
util.LogInfo(c.Ctx, "API: [%s] signed in", userId)
|
util.LogInfo(c.Ctx, "API: [%s] signed in", userId)
|
||||||
c.ResponseOk(userId)
|
|
||||||
|
application := object.GetApplicationByUser(user)
|
||||||
|
var form RequestForm
|
||||||
|
form.Type = responseType
|
||||||
|
resp := c.HandleLoggedIn(application, user, &form)
|
||||||
|
c.Data["json"] = resp
|
||||||
|
c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ export function getEmailAndPhone(values) {
|
|||||||
}).then((res) => res.json());
|
}).then((res) => res.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
function oAuthParamsToQuery(oAuthParams) {
|
export function oAuthParamsToQuery(oAuthParams) {
|
||||||
// login
|
// login
|
||||||
if (oAuthParams === null) {
|
if (oAuthParams === null) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -599,7 +599,7 @@ class LoginPage extends React.Component {
|
|||||||
const rawId = assertion.rawId;
|
const rawId = assertion.rawId;
|
||||||
const sig = assertion.response.signature;
|
const sig = assertion.response.signature;
|
||||||
const userHandle = assertion.response.userHandle;
|
const userHandle = assertion.response.userHandle;
|
||||||
return fetch(`${Setting.ServerUrl}/api/webauthn/signin/finish`, {
|
return fetch(`${Setting.ServerUrl}/api/webauthn/signin/finish${AuthBackend.oAuthParamsToQuery(oAuthParams)}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
Reference in New Issue
Block a user