mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
refactor(deps): use foundation shared utilities
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/ez-api/ez-api/internal/model"
|
||||
"github.com/ez-api/ez-api/internal/util"
|
||||
"github.com/ez-api/foundation/tokenhash"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -32,7 +32,7 @@ func (s *MasterService) CreateMaster(name, group string, maxChildKeys, globalQPS
|
||||
return nil, "", fmt.Errorf("failed to hash master key: %w", err)
|
||||
}
|
||||
|
||||
masterKeyDigest := util.HashToken(rawMasterKey)
|
||||
masterKeyDigest := tokenhash.HashToken(rawMasterKey)
|
||||
|
||||
master := &model.Master{
|
||||
Name: name,
|
||||
@@ -53,7 +53,7 @@ func (s *MasterService) CreateMaster(name, group string, maxChildKeys, globalQPS
|
||||
}
|
||||
|
||||
func (s *MasterService) ValidateMasterKey(masterKey string) (*model.Master, error) {
|
||||
digest := util.HashToken(masterKey)
|
||||
digest := tokenhash.HashToken(masterKey)
|
||||
|
||||
var master model.Master
|
||||
if err := s.db.Where("master_key_digest = ?", digest).First(&master).Error; err != nil {
|
||||
@@ -108,7 +108,7 @@ func (s *MasterService) IssueChildKey(masterID uint, group string, scopes string
|
||||
return nil, "", fmt.Errorf("failed to generate child key: %w", err)
|
||||
}
|
||||
|
||||
tokenHash := util.HashToken(rawChildKey)
|
||||
tokenHash := tokenhash.HashToken(rawChildKey)
|
||||
|
||||
hashedChildKey, err := bcrypt.GenerateFromPassword([]byte(rawChildKey), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user