Skip to content

Commit

Permalink
perf: add rust proto , add face callbcak api
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron3S authored and LeeEirc committed Nov 12, 2024
1 parent ad3e277 commit 0a77455
Show file tree
Hide file tree
Showing 13 changed files with 5,714 additions and 2,060 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ proto_go_dir=./protobuf-go
protobuf_py_dir=./protobuf-py/protobuf

.PHONY: proto
proto: proto-go proto-java
proto: proto-go proto-java proto-rust

.PHONY: proto-go
proto-go:
Expand All @@ -103,4 +103,14 @@ proto-java:
protoc --proto_path=${proto_path} --java_out=./protobuf-java \
--grpc_out=./protobuf-java \
--plugin=protoc-gen-grpc=$(shell which protoc-gen-grpc-java) \
${proto_files}
${proto_files}


.PHONY: proto-rust
proto-rust:
@mkdir -p ./protobuf-rs
protoc --proto_path=${proto_path} \
--plugin=protoc-gen-tonic=$(shell which protoc-gen-tonic) \
--prost_out=./protobuf-rs \
--tonic_out=./protobuf-rs \
${proto_files}
27 changes: 27 additions & 0 deletions cmd/impl/jms_face_callback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package impl

import (
"context"
"github.com/jumpserver/wisp/pkg/jms-sdk-go/service"
pb "github.com/jumpserver/wisp/protobuf-go/protobuf"
)

func (j *JMServer) FaceRecognitionCallback(ctx context.Context, req *pb.FaceRecognitionCallbackRequest) (*pb.FaceRecognitionCallbackResponse, error) {
var status pb.Status

result := service.FaceRecognitionResult{
Token: req.Token,
Success: req.Success,
ErrorMessage: req.ErrorMessage,
FaceCode: req.FaceCode,
}
if err := j.apiClient.SendFaceRecognitionCallback(result); err != nil {
status.Ok = false
status.Err = err.Error()
} else {
status.Ok = true
}
return &pb.FaceRecognitionCallbackResponse{
Status: &status,
}, nil
}
16 changes: 16 additions & 0 deletions pkg/jms-sdk-go/service/jms_face_callback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package service

type FaceRecognitionResult struct {
Token string `json:"token"`
Success bool `json:"success"`
ErrorMessage string `json:"error_message"`
FaceCode string `json:"face_code"`
}

func (s *JMService) SendFaceRecognitionCallback(result FaceRecognitionResult) error {
var resp = map[string]interface{}{}
if _, err := s.authClient.Post(FaceRecognitionURL, &result, &resp); err != nil {
return err
}
return nil
}
4 changes: 4 additions & 0 deletions pkg/jms-sdk-go/service/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ const (
AssetLoginConfirmURL = "/api/v1/acls/login-asset/check/"
AclCommandReviewURL = "/api/v1/acls/command-filter-acls/command-review/"
)

const (
FaceRecognitionURL = "/api/v1/authentication/mfa/face/callback/"
)
Loading

0 comments on commit 0a77455

Please sign in to comment.