fix: check credential existence when signing via WebAuthn (#1336)

* fix: check credential existence when signing via WebAuthn

* fix review problem
This commit is contained in:
Mr Forest 2022-11-28 21:47:17 +08:00 committed by GitHub
parent 6e6a0a074a
commit 8890d1d7c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 2 deletions

View File

@ -104,6 +104,11 @@ func (c *ApiController) WebAuthnSigninBegin() {
c.ResponseError(fmt.Sprintf(c.T("UserErr.DoNotExistInOrg"), userOwner, userName)) c.ResponseError(fmt.Sprintf(c.T("UserErr.DoNotExistInOrg"), userOwner, userName))
return return
} }
if len(user.WebauthnCredentials) == 0 {
c.ResponseError(c.T("UserErr.NoWebAuthnCredential"))
return
}
options, sessionData, err := webauthnObj.BeginLogin(user) options, sessionData, err := webauthnObj.BeginLogin(user)
if err != nil { if err != nil {
c.ResponseError(err.Error()) c.ResponseError(err.Error())

View File

@ -134,4 +134,5 @@ NameTooLang = Username is too long (maximum is 39 characters).
NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline. NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline.
PasswordLessThanSixCharacters = Password must have at least 6 characters PasswordLessThanSixCharacters = Password must have at least 6 characters
InvalidInformation = Invalid information InvalidInformation = Invalid information
NoWebAuthnCredential = Found no credentials for this user

View File

@ -134,4 +134,5 @@ NameTooLang = Username is too long (maximum is 39 characters).
NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline. NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline.
PasswordLessThanSixCharacters = Password must have at least 6 characters PasswordLessThanSixCharacters = Password must have at least 6 characters
InvalidInformation = Invalid information InvalidInformation = Invalid information
NoWebAuthnCredential = Found no credentials for this user

View File

@ -134,4 +134,5 @@ NameTooLang = Username is too long (maximum is 39 characters).
NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline. NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline.
PasswordLessThanSixCharacters = Password must have at least 6 characters PasswordLessThanSixCharacters = Password must have at least 6 characters
InvalidInformation = Invalid information InvalidInformation = Invalid information
NoWebAuthnCredential = Found no credentials for this user

View File

@ -134,4 +134,5 @@ NameTooLang = Username is too long (maximum is 39 characters).
NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline. NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline.
PasswordLessThanSixCharacters = Password must have at least 6 characters PasswordLessThanSixCharacters = Password must have at least 6 characters
InvalidInformation = Invalid information InvalidInformation = Invalid information
NoWebAuthnCredential = Found no credentials for this user

View File

@ -134,4 +134,5 @@ NameTooLang = Username is too long (maximum is 39 characters).
NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline. NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline.
PasswordLessThanSixCharacters = Password must have at least 6 characters PasswordLessThanSixCharacters = Password must have at least 6 characters
InvalidInformation = Invalid information InvalidInformation = Invalid information
NoWebAuthnCredential = Found no credentials for this user

View File

@ -134,4 +134,5 @@ NameTooLang = Username is too long (maximum is 39 characters).
NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline. NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline.
PasswordLessThanSixCharacters = Password must have at least 6 characters PasswordLessThanSixCharacters = Password must have at least 6 characters
InvalidInformation = Invalid information InvalidInformation = Invalid information
NoWebAuthnCredential = Found no credentials for this user

View File

@ -134,4 +134,5 @@ NameTooLang = Username is too long (maximum is 39 characters).
NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline. NameFormatErr = The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline.
PasswordLessThanSixCharacters = Password must have at least 6 characters PasswordLessThanSixCharacters = Password must have at least 6 characters
InvalidInformation = Invalid information InvalidInformation = Invalid information
NoWebAuthnCredential = Found no credentials for this user

View File

@ -1,5 +1,5 @@
[ApplicationErr] [ApplicationErr]
AppNotFound = 应用 %%s 未找到 AppNotFound = 应用 %s 未找到
AppNotFoundForUserID = 找不到该用户的应用程序 %s AppNotFoundForUserID = 找不到该用户的应用程序 %s
GrantTypeNotSupport = 此应用中不支持此授权类型 GrantTypeNotSupport = 此应用中不支持此授权类型
HasNoProviders = 该应用无提供商 HasNoProviders = 该应用无提供商
@ -25,7 +25,7 @@ EmptyErr = 邮箱不可为空
EmailInvalid = 无效邮箱 EmailInvalid = 无效邮箱
EmailCheckResult = Email: %s EmailCheckResult = Email: %s
EmptyParam = 邮件参数为空: %v EmptyParam = 邮件参数为空: %v
InvalidReceivers = 无效的邮箱接收者: %%s InvalidReceivers = 无效的邮箱接收者: %s
UnableGetModifyRule = 无法得到Email修改规则 UnableGetModifyRule = 无法得到Email修改规则
[EnforcerErr] [EnforcerErr]
@ -131,6 +131,7 @@ NameFormatErr = 用户名只能包含字母数字字符、下划线或连字符
PasswordLessThanSixCharacters = 密码至少为6字符 PasswordLessThanSixCharacters = 密码至少为6字符
DoNotExistSignUp = 用户不存在,请先注册 DoNotExistSignUp = 用户不存在,请先注册
InvalidInformation = 无效信息 InvalidInformation = 无效信息
NoWebAuthnCredential = 该用户没有WebAuthn凭据
[StorageErr] [StorageErr]
ObjectKeyNotAllowed = object key :%s 不被允许 ObjectKeyNotAllowed = object key :%s 不被允许