Skip to content

Commit

Permalink
feat: add FaceIdSigninBegin() to verify user information before face …
Browse files Browse the repository at this point in the history
…login
  • Loading branch information
HGZ-20 committed Mar 17, 2024
1 parent 2c4b109 commit 04cb2f0
Show file tree
Hide file tree
Showing 27 changed files with 88 additions and 5 deletions.
1 change: 1 addition & 0 deletions authz/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ p, *, *, GET, /api/get-all-objects, *, *
p, *, *, GET, /api/get-all-actions, *, *
p, *, *, GET, /api/get-all-roles, *, *
p, *, *, GET, /api/get-invitation-info, *, *
p, *, *, GET, /api/faceid-signin-begin, *, *
`

sa := stringadapter.NewAdapter(ruleText)
Expand Down
38 changes: 38 additions & 0 deletions controllers/face.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package controllers

import (
"fmt"

Check failure on line 4 in controllers/face.go

View workflow job for this annotation

GitHub Actions / Go-Linter

File is not `gofumpt`-ed (gofumpt)
"github.com/casdoor/casdoor/object"
"github.com/casdoor/casdoor/util"
)

// FaceIdSigninBegin
// @Title FaceIdSigninBegin
// @Tag Login API
// @Description Face Id Login Flow 1st stage
// @Param owner query string true "owner"
// @Param name query string true "name"
// @Success 200 {object} controllers.Response The Response object
// @router /faceid-signin-begin [get]
func (c *ApiController) FaceIdSigninBegin() {
userOwner := c.Input().Get("owner")
userName := c.Input().Get("name")
user, err := object.GetUserByFields(userOwner, userName)
if err != nil {
c.ResponseError(err.Error())
return
}

if user == nil {
c.ResponseError(fmt.Sprintf(c.T("general:The user: %s doesn't exist"), util.GetId(userOwner, userName)))
return
}
if len(user.FaceIds) == 0 {
c.ResponseError(c.T("check:Face data does not exist, cannot log in"))
return
}

resp := &Response{Status: "ok", Msg: ""}
c.Data["json"] = resp
c.ServeJSON()
}
2 changes: 2 additions & 0 deletions routers/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,6 @@ func initAPI() {
beego.Router("/cas/:organization/:application/samlValidate", &controllers.RootController{}, "POST:SamlValidate")

beego.Router("/scim/*", &controllers.RootController{}, "*:HandleScim")

beego.Router("/api/faceid-signin-begin", &controllers.ApiController{}, "GET:FaceIdSigninBegin")
}
29 changes: 24 additions & 5 deletions web/src/auth/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,28 @@ class LoginPage extends React.Component {
return;
}
if (this.state.loginMethod === "faceId") {
this.setState({
openFaceRecognitionModal: true,
values: values,
});
let username = this.state.username;
if (username === null || username === "") {
username = values["username"];
}
const application = this.getApplicationObj();
fetch(`${Setting.ServerUrl}/api/faceid-signin-begin?owner=${application.organization}&name=${username}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json())
.then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({
openFaceRecognitionModal: true,
values: values,
});
});
return;
}
if (this.state.loginMethod === "password" || this.state.loginMethod === "ldap") {
Expand Down Expand Up @@ -666,7 +684,8 @@ class LoginPage extends React.Component {
>
{
this.state.loginMethod === "webAuthn" ? i18next.t("login:Sign in with WebAuthn") :
i18next.t("login:Sign In")
this.state.loginMethod === "faceId" ? i18next.t("login:Sign in with Face ID") :
i18next.t("login:Sign In")
}
</Button>
{
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/ar/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/de/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Umleitung, bitte warten.",
"Sign In": "Anmelden",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Melden Sie sich mit WebAuthn an",
"Sign in with {type}": "Melden Sie sich mit {type} an",
"Signing in...": "Anmelden...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/en/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/es/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirigiendo, por favor espera.",
"Sign In": "Iniciar sesión",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Iniciar sesión con WebAuthn",
"Sign in with {type}": "Inicia sesión con {tipo}",
"Signing in...": "Iniciando sesión...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/fa/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/fi/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/fr/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Veuillez entrer une organisation pour vous connecter",
"Redirecting, please wait.": "Redirection en cours, veuillez patienter.",
"Sign In": "Se connecter",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Connectez-vous avec WebAuthn",
"Sign in with {type}": "Connectez-vous avec {type}",
"Signing in...": "Connexion en cours...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/he/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/id/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Mengalihkan, harap tunggu.",
"Sign In": "Masuk",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Masuk dengan WebAuthn",
"Sign in with {type}": "Masuk dengan {type}",
"Signing in...": "Masuk...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/it/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/ja/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "リダイレクト中、お待ちください。",
"Sign In": "サインイン",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "WebAuthnでサインインしてください",
"Sign in with {type}": "{type}でサインインしてください",
"Signing in...": "サインイン中...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/kk/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/ko/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "리디렉팅 중입니다. 잠시 기다려주세요.",
"Sign In": "로그인",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "WebAuthn으로 로그인하세요",
"Sign in with {type}": "{type}로 로그인하세요",
"Signing in...": "로그인 중...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/ms/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/nl/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/pl/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/pt/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecionando, por favor aguarde.",
"Sign In": "Entrar",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Entrar com WebAuthn",
"Sign in with {type}": "Entrar com {type}",
"Signing in...": "Entrando...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/ru/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Перенаправление, пожалуйста, подождите.",
"Sign In": "Войти",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Войти с помощью WebAuthn",
"Sign in with {type}": "Войти с помощью {type}",
"Signing in...": "Вход в систему...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/sv/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/tr/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Yönlendiriliyor, lütfen bekleyiniz.",
"Sign In": "Oturum aç",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "{type} ile giriş yap",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/uk/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Redirecting, please wait.",
"Sign In": "Sign In",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Sign in with WebAuthn",
"Sign in with {type}": "Sign in with {type}",
"Signing in...": "Signing in...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/vi/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "Please type an organization to sign in",
"Redirecting, please wait.": "Đang chuyển hướng, vui lòng đợi.",
"Sign In": "Đăng nhập",
"Sign in with Face ID": "Sign in with Face ID",
"Sign in with WebAuthn": "Đăng nhập với WebAuthn",
"Sign in with {type}": "Đăng nhập bằng {type}",
"Signing in...": "Đăng nhập...",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/zh/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"Please type an organization to sign in": "请输入要登录的组织",
"Redirecting, please wait.": "正在跳转, 请稍等.",
"Sign In": "登录",
"Sign in with Face ID": "人脸登录",
"Sign in with WebAuthn": "WebAuthn登录",
"Sign in with {type}": "{type}登录",
"Signing in...": "正在登录...",
Expand Down

0 comments on commit 04cb2f0

Please sign in to comment.