mirror of
https://github.com/YFGaia/dify-plus.git
synced 2026-06-14 20:41:21 +08:00
7ba4db8888
需要 x-csrf-token header 需要 csrf_token cookie 两者必须一致,且是有效的JWT(包含 exp 和 sub=user_id)
40 lines
873 B
Go
40 lines
873 B
Go
package request
|
|
|
|
import (
|
|
"github.com/gofrs/uuid/v5"
|
|
jwt "github.com/golang-jwt/jwt/v4"
|
|
)
|
|
|
|
// Custom claims structure
|
|
type CustomClaims struct {
|
|
BaseClaims
|
|
BufferTime int64
|
|
jwt.RegisteredClaims
|
|
// Extend Start: add gaia token
|
|
UserId string `json:"user_id"`
|
|
Exp int64 `json:"exp"`
|
|
Sub string `json:"sub"`
|
|
Email string `json:"email,omitempty"`
|
|
// Extend Start: add gaia token
|
|
}
|
|
|
|
type BaseClaims struct {
|
|
UUID uuid.UUID
|
|
ID uint
|
|
Username string
|
|
NickName string
|
|
AuthorityId uint
|
|
// Extend Start: add gaia token
|
|
UserId string `json:"user_id,omitempty"`
|
|
Exp int64 `json:"exp,omitempty"`
|
|
Email string `json:"email,omitempty"`
|
|
Sub string `json:"sub,omitempty"`
|
|
// Extend Start: add gaia token
|
|
}
|
|
|
|
// CSRFClaims CSRF token claims (与Dify API兼容)
|
|
type CSRFClaims struct {
|
|
jwt.RegisteredClaims
|
|
Sub string `json:"sub"`
|
|
}
|