Skip to content

Commit

Permalink
improve: 飞书事件鉴权与日志打印
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx233 committed Nov 2, 2023
1 parent abf22bb commit c048e27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions internal/api/controllers/feishu/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package controllers
import (
"github.com/gin-gonic/gin"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/callback"
"github.com/ncuhome/GeniusAuthoritarian/internal/global"
"github.com/ncuhome/GeniusAuthoritarian/internal/pkg/feishu"
log "github.com/sirupsen/logrus"
)

func Webhook(c *gin.Context) {
Expand All @@ -14,4 +16,11 @@ func Webhook(c *gin.Context) {
return
}

if event.Header.Token != global.Config.Feishu.WebhookVerificationToken {
callback.Error(c, callback.ErrUnauthorized, err)
return
}

log.Infof("[飞书事件] %s:%s", event.Header.EventType, event.Header.EventID)

}
5 changes: 3 additions & 2 deletions internal/global/models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ type Config struct {
}

type Feishu struct {
ClientID string `yaml:"clientID"`
Secret string `yaml:"secret"`
ClientID string `yaml:"clientID"`
Secret string `yaml:"secret"`
WebhookVerificationToken string `json:"webhook_verification_token"`
}

type DingTalk struct {
Expand Down

0 comments on commit c048e27

Please sign in to comment.