update api
This commit is contained in:
@@ -39,37 +39,31 @@ func (c *DukcapilClient) FaceMatch(ctx context.Context, req *contract.FaceMatchR
|
||||
return nil, errors.New("dukcapil: incomplete configuration")
|
||||
}
|
||||
|
||||
// Load PEM public key from file
|
||||
pemBytes, err := os.ReadFile("infra/990030524100001.pem")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("dukcapil: failed to read PEM file: %w", err)
|
||||
}
|
||||
|
||||
ip := req.IP
|
||||
if strings.TrimSpace(ip) == "" {
|
||||
ip = c.cfg.DefaultIP
|
||||
}
|
||||
// Encrypt UserID and Password
|
||||
encryptedUserID, err := util.EncryptWithPublicKey(c.cfg.UserID, pemBytes)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("dukcapil: encrypt user_id: %w", err)
|
||||
}
|
||||
encryptedPassword, err := util.EncryptWithPublicKey(c.cfg.Password, pemBytes)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("dukcapil: encrypt password: %w", err)
|
||||
}
|
||||
|
||||
// Load PEM public key from file
|
||||
pemBytes, err := os.ReadFile("infra/990030524100001.pem")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("dukcapil: failed to read PEM file: %w", err)
|
||||
}
|
||||
|
||||
// Encrypt UserID and Password
|
||||
encryptedUserID, err := util.EncryptWithPublicKey(c.cfg.UserID, pemBytes)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("dukcapil: encrypt user_id: %w", err)
|
||||
}
|
||||
encryptedPassword, err := util.EncryptWithPublicKey(c.cfg.Password, pemBytes)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("dukcapil: encrypt password: %w", err)
|
||||
}
|
||||
|
||||
body := contract.DukcapilFaceRequest{
|
||||
TransactionID: req.TransactionID,
|
||||
TransactionSource: req.TransactionSource,
|
||||
Threshold: req.Threshold,
|
||||
Image: req.Image,
|
||||
UserID: encryptedUserID,
|
||||
Password: encryptedPassword,
|
||||
IP: ip,
|
||||
}
|
||||
body := contract.DukcapilFaceRequest{
|
||||
TransactionID: req.TransactionID,
|
||||
TransactionSource: req.TransactionSource,
|
||||
Threshold: req.Threshold,
|
||||
Image: req.Image,
|
||||
UserID: encryptedUserID,
|
||||
Password: encryptedPassword,
|
||||
IP: req.IP,
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user