Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: add face acl failed msg #1613

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions locale/en_US/LC_MESSAGES/koko.po
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,18 @@ msgstr ""
#. lang.T
#: pkg/handler/asset.go:223
msgid ""
"Face verification is not supported yet. Please use the WebTerminal to "
"connect the asset."
"Face ACL is not supported yet. Please use the WebTerminal to connect the "
"asset."
msgstr ""

#. lang.T
#. lang.T
#: pkg/handler/asset.go:238 pkg/handler/asset.go:255
#: pkg/handler/asset.go:238 pkg/handler/asset.go:247
msgid "Unknown error code: %s, detail: %s"
msgstr ""

#. lang.T
#: pkg/handler/asset.go:258
msgid "get connect token err"
msgstr ""

Expand Down Expand Up @@ -233,12 +238,18 @@ msgstr ""
#. lang.T
#. lang.T
#. lang.T
#: pkg/handler/direct_handler.go:433 pkg/handler/direct_handler.go:439
#: pkg/handler/direct_handler.go:445
msgid ""
"Face verification is not supported yet. Please use the WebTerminal to "
"connect the asset."
msgstr ""

#. lang.T
#. lang.T
#. lang.T
#: pkg/handler/direct_handler.go:433 pkg/handler/direct_handler.go:439
#: pkg/handler/direct_handler.go:445 pkg/handler/direct_handler.go:460
#: pkg/handler/direct_handler.go:476 pkg/handler/dispatch.go:139
#: pkg/handler/direct_handler.go:460 pkg/handler/direct_handler.go:476
#: pkg/handler/dispatch.go:139
msgid "Node: [ ID.Name(Asset amount) ]"
msgstr ""

Expand Down
29 changes: 22 additions & 7 deletions locale/ja_JP/LC_MESSAGES/koko.po
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,20 @@ msgstr "は拒否されました"
#: pkg/handler/asset.go:223
#, fuzzy
msgid ""
"Face verification is not supported yet. Please use the WebTerminal to "
"connect the asset."
"Face ACL is not supported yet. Please use the WebTerminal to connect the "
"asset."
msgstr ""
"顔認証はまだサポートされていません。資産に接続するにはWebTerminalをご利用ください"
"該端末は顔認証アクセスルールをサポートしていません。資産に接続するにはWebTerminalをご利用くだ"
"さい"

#. lang.T
#. lang.T
#: pkg/handler/asset.go:238 pkg/handler/asset.go:255
#: pkg/handler/asset.go:238 pkg/handler/asset.go:247
msgid "Unknown error code: %s, detail: %s"
msgstr "不明なエラーコード: %s, 詳細: %s"

#. lang.T
#: pkg/handler/asset.go:258
msgid "get connect token err"
msgstr "接続トークン取得エラー"

Expand Down Expand Up @@ -245,12 +251,21 @@ msgstr "一致したユーザー名 %s が見つかりません"
#. lang.T
#. lang.T
#. lang.T
#: pkg/handler/direct_handler.go:433 pkg/handler/direct_handler.go:439
#: pkg/handler/direct_handler.go:445
#, fuzzy
msgid ""
"Face verification is not supported yet. Please use the WebTerminal to "
"connect the asset."
msgstr ""
"顔認証はまだサポートされていません。資産に接続するにはWebTerminalをご利用くだ"
"さい"

#. lang.T
#. lang.T
#. lang.T
#: pkg/handler/direct_handler.go:433 pkg/handler/direct_handler.go:439
#: pkg/handler/direct_handler.go:445 pkg/handler/direct_handler.go:460
#: pkg/handler/direct_handler.go:476 pkg/handler/dispatch.go:139
#: pkg/handler/direct_handler.go:460 pkg/handler/direct_handler.go:476
#: pkg/handler/dispatch.go:139
msgid "Node: [ ID.Name(Asset amount) ]"
msgstr "ノード: [ID.Name(アセット量)]"

Expand Down
26 changes: 19 additions & 7 deletions locale/zh_CN/LC_MESSAGES/koko.po
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,18 @@ msgstr "本次登录已拒绝,原因是访问控制策略的限制"
#: pkg/handler/asset.go:223
#, fuzzy
msgid ""
"Face verification is not supported yet. Please use the WebTerminal to "
"connect the asset."
msgstr "该终端不支持人脸识别认证,请使用web终端登录"
"Face ACL is not supported yet. Please use the WebTerminal to connect the "
"asset."
msgstr "该终端不支持人脸访问规则,请使用web终端登录"

#. lang.T
#. lang.T
#: pkg/handler/asset.go:238 pkg/handler/asset.go:255
#: pkg/handler/asset.go:238 pkg/handler/asset.go:247
msgid "Unknown error code: %s, detail: %s"
msgstr "未知错误代码:%s,详情:%s"

#. lang.T
#: pkg/handler/asset.go:258
msgid "get connect token err"
msgstr "获取 connect token 错误"

Expand Down Expand Up @@ -252,12 +257,19 @@ msgstr "未发现匹配的用户名 %s"
#. lang.T
#. lang.T
#. lang.T
#: pkg/handler/direct_handler.go:433 pkg/handler/direct_handler.go:439
#: pkg/handler/direct_handler.go:445
#, fuzzy
msgid ""
"Face verification is not supported yet. Please use the WebTerminal to "
"connect the asset."
msgstr "该终端不支持人脸识别认证,请使用web终端登录"

#. lang.T
#. lang.T
#. lang.T
#: pkg/handler/direct_handler.go:433 pkg/handler/direct_handler.go:439
#: pkg/handler/direct_handler.go:445 pkg/handler/direct_handler.go:460
#: pkg/handler/direct_handler.go:476 pkg/handler/dispatch.go:139
#: pkg/handler/direct_handler.go:460 pkg/handler/direct_handler.go:476
#: pkg/handler/dispatch.go:139
msgid "Node: [ ID.Name(Asset amount) ]"
msgstr "节点:[ ID.名称(资产数量) ]"

Expand Down
24 changes: 18 additions & 6 deletions locale/zh_Hant/LC_MESSAGES/koko.po
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,18 @@ msgstr "本次登入已拒絕,原因是訪問控制策略的限制"
#: pkg/handler/asset.go:223
#, fuzzy
msgid ""
"Face verification is not supported yet. Please use the WebTerminal to "
"connect the asset."
"Face ACL is not supported yet. Please use the WebTerminal to connect the "
"asset."
msgstr "該終端不支持人臉識別認證,請使用網頁終端登錄"

#. lang.T
#. lang.T
#: pkg/handler/asset.go:238 pkg/handler/asset.go:255
#: pkg/handler/asset.go:238 pkg/handler/asset.go:247
msgid "Unknown error code: %s, detail: %s"
msgstr "未知錯誤碼:%s,詳情:%s"

#. lang.T
#: pkg/handler/asset.go:258
msgid "get connect token err"
msgstr "獲取 connect token 錯誤"

Expand Down Expand Up @@ -252,12 +257,19 @@ msgstr "未發現匹配的使用者名稱 %s"
#. lang.T
#. lang.T
#. lang.T
#: pkg/handler/direct_handler.go:433 pkg/handler/direct_handler.go:439
#: pkg/handler/direct_handler.go:445
#, fuzzy
msgid ""
"Face verification is not supported yet. Please use the WebTerminal to "
"connect the asset."
msgstr "該終端不支持人臉識別認證,請使用網頁終端登錄"

#. lang.T
#. lang.T
#. lang.T
#: pkg/handler/direct_handler.go:433 pkg/handler/direct_handler.go:439
#: pkg/handler/direct_handler.go:445 pkg/handler/direct_handler.go:460
#: pkg/handler/direct_handler.go:476 pkg/handler/dispatch.go:139
#: pkg/handler/direct_handler.go:460 pkg/handler/direct_handler.go:476
#: pkg/handler/dispatch.go:139
msgid "Node: [ ID.Name(Asset amount) ]"
msgstr "節點:[ ID.名稱(資產數量) ]"

Expand Down
7 changes: 5 additions & 2 deletions pkg/handler/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ func (u *UserSelectHandler) proxyAsset(asset model.PermAsset) {
utils.IgnoreErrWriteString(u.h.term, lang.T("ACL reject"))
utils.IgnoreErrWriteString(u.h.term, utils.CharNewLine)
return
case model.ACLFaceVerify:
case model.ACLFaceVerify, model.ACLFaceOnline, model.ACLFaceOnlineNotSupported:
// todo: 需要人脸验证 后续需要发站内信通知用户,并且等待用户人脸验证通过
logger.Errorf("Create connect token and auth info failed: %s %s", tokenInfo.Code, tokenInfo.Detail)
msg := lang.T("Face verification is not supported yet. Please use the WebTerminal to connect the asset.")
msg := lang.T("Face ACL is not supported yet. Please use the WebTerminal to connect the asset.")
utils.IgnoreErrWriteString(u.h.term, msg)
utils.IgnoreErrWriteString(u.h.term, utils.CharNewLine)
return
Expand All @@ -244,6 +244,9 @@ func (u *UserSelectHandler) proxyAsset(asset model.PermAsset) {
}
tokenInfo = reviewHandler.tokenInfo
default:
msg := lang.T("Unknown error code: %s, detail: %s")
utils.IgnoreErrWriteString(u.h.term, fmt.Sprintf(msg, tokenInfo.Code, tokenInfo.Detail))
utils.IgnoreErrWriteString(u.h.term, utils.CharNewLine)
logger.Errorf("Create connect token and auth info failed: %s %s", tokenInfo.Code, tokenInfo.Detail)
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code does not contain any known issues or improvements. However, it could be more streamlined by using a single return statement after checking the case for all types of assets. Also, consider if adding a comment at default case provides additional help to someone reading this function, such that they can understand what will happen when no specific case matches. Here is an example:

func (u *UserSelectHandler) proxyAsset(asset model.PermAsset) {
	if aclCheckType(u, &asset) && !hasTokenError(&tokenInfo) {

This change should improve readability and maintainability without altering functionality.

Let me know if you have another question!

Expand Down
4 changes: 3 additions & 1 deletion pkg/jms-sdk-go/model/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ const (
ACLReview = "acl_review"
ACLReject = "acl_reject"

ACLFaceVerify = "acl_face_verify"
ACLFaceVerify = "acl_face_verify"
ACLFaceOnline = "acl_face_online"
ACLFaceOnlineNotSupported = "acl_face_online_not_supported"
)

type ConnectOptions struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code provided appears to be related to an open-source project and is used for connecting various authentication types with specific functions and operations. The first difference I noticed is that the ACLRejected function has been renamed to AclReject. This change suggests there may have been confusion about what each of these values actually represents.

For instance, the documentation indicates two different ways to authenticate user identities:

const ACLReview = "acl_review";
const ACLReject = "acl_reject";

// User reviews an identity based on information from external services
ACLReview();

// User denies a request for approval through a security mechanism such as an ID Verification tool 

In contrast, you're referring to:

_ACLFaceVerify               = "acl_face_verify"  
_ACLFaceOnline             = "acl_face_online"
_ACLFaceOnlineNotSupported = "acl_face_online_not_supported"

// A client facing API which can only perform face identification tasks.
_ACLFaceIdentify = "face_auth_identi..."
// An external service which performs face verification tasks (e.g., Google's Image Matching Service).
_ACLFaceVerification  ...
// A service which authenticates users' access given their faces, allowing non-biometric methods like photo IDs etc.
_ACLFaceAuth                = ...

 // Performs authentication via Face Online, without checking if it supports it
_ACLFaceOnline                  = ""
_ACLFaceOnlineNotSuppor...     -- Not supported

// Represents an operation where no further action was taken due to missing support or other factors at this time
_ACLFaceOnlineNotSuport...
// For a service which doesn't handle authentication by default but still requires support of its own algorithms or logic
_ACLFaceUnsupportedService   = ""
// For a feature not implemented yet
_ACLFeatureUnimplemented      =

This could indicate some sort of miscommunication between authors or maintainers when naming these interfaces/authentications.
I recommend revisiting the design rationale and possibly creating separate interfaces/functions for different aspects rather than conflating everything under one name. For example, ACLFaceVerified, ACLFaceOffline, ACLFaceAuthorized, ACLFaceUnsupported would clearly specify the state of each operation more accurately.
It should help avoid ambiguity and ensure clear, understandable usage.

Expand Down
Loading