diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..47695ec --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +CAOM_INSTANCE_URL=https:// +CAOM_TAG= +CAOM_ADMIN_PASSWORD= +CAOM_JWT_SECRET= # Required +CAOM_JWT_ISSUER= +CAOM_JWT_AUDIENCE= \ No newline at end of file diff --git a/.gitignore b/.gitignore index bd58fa1..b1c4634 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.db *.sqlite -build/ \ No newline at end of file +build/ +*.txt +.env \ No newline at end of file diff --git a/go.mod b/go.mod index 3243e03..68f3366 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/golang-jwt/jwt/v5 v5.2.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/leodido/go-urn v1.4.0 // indirect diff --git a/go.sum b/go.sum index d640934..380d19f 100644 --- a/go.sum +++ b/go.sum @@ -36,6 +36,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/internal/config/config.go b/internal/config/config.go index 362b619..762087b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,21 +3,28 @@ package config import ( "log" "os" + + "github.com/joho/godotenv" ) type config struct { AdminPassword string - Instance string - Tag string + Instance string + Tag string - JwtSecret string - JwtIssuer string + JwtSecret string + JwtIssuer string JwtAudience string } var Config *config func Load() *config { + err := godotenv.Load() + if err != nil { + log.Fatal("Error loading .env file") + } + // Get mastodon instance instance := os.Getenv("CAOM_INSTANCE") if instance == "" { @@ -51,15 +58,14 @@ func Load() *config { audience = "CatsOfMastodonBotGo" } - // Inititlize AppContext var appContext = &config{ AdminPassword: adminPassword, - Instance: instance, - Tag: tag, + Instance: instance, + Tag: tag, - JwtSecret: secret, - JwtIssuer: issuer, + JwtSecret: secret, + JwtIssuer: issuer, JwtAudience: audience, } return appContext diff --git a/internal/server/router.go b/internal/server/router.go index e5aad0f..d7e481f 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -18,9 +18,9 @@ func SetupRouter() *gin.Engine { AllowCredentials: true, })) + auth.InitJwtTokenGenerator() // Must be befor initializing admin handler, otherwise 'panic: runtime error: invalid memory address or nil pointer dereference' handlers.InitAdminDashboardHandler() handlers.InitApiEndpointHandler() - auth.InitJwtTokenGenerator() admin := r.Group("/admin") diff --git a/internal/web/handlers/adminDash.go b/internal/web/handlers/adminDash.go index 047cc15..40789f4 100644 --- a/internal/web/handlers/adminDash.go +++ b/internal/web/handlers/adminDash.go @@ -3,6 +3,7 @@ package handlers import ( "net/http" + "CatsOfMastodonBotGo/internal/auth" "CatsOfMastodonBotGo/internal/config" "CatsOfMastodonBotGo/internal/domain/requestModels" "CatsOfMastodonBotGo/internal/services" @@ -12,6 +13,7 @@ import ( type AdminDashboardHandler struct { PostService services.PostService + Jwt auth.JwtTokenGenerator } var AdminDashboardHandlerInstance *AdminDashboardHandler @@ -19,6 +21,7 @@ var AdminDashboardHandlerInstance *AdminDashboardHandler func InitAdminDashboardHandler() { AdminDashboardHandlerInstance = &AdminDashboardHandler{ PostService: *services.PostServiceInstance, + Jwt: *auth.JwtTokenGeneratorInstance, } } @@ -64,13 +67,13 @@ func (ps *AdminDashboardHandler) Login(c *gin.Context) { } if input.Password == config.Config.AdminPassword { // Its more than enough for this project - // token, err := ps.ps.Jwt.GenerateToken(map[string]interface{}{"role": "admin"}) - // if err != nil { - // c.JSON(http.StatusInternalServerError, gin.H{"error": "Token generation failed"}) - // return - // } + token, err := ps.Jwt.GenerateToken(map[string]interface{}{"role": "admin"}) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": "Token generation failed"}) + return + } - c.JSON(http.StatusOK, gin.H{"message": "Login successful", "token": "yoy"}) // TODO: Add token + c.JSON(http.StatusOK, gin.H{"message": "Login successful", "token": token}) } else { c.JSON(401, gin.H{ diff --git a/project-structure.txt b/project-structure.txt deleted file mode 100644 index a08d344..0000000 --- a/project-structure.txt +++ /dev/null @@ -1,772 +0,0 @@ -internal/AppContext.go - -package internal - -import ( - "CatsOfMastodonBotGo/internal/auth" - "CatsOfMastodonBotGo/internal/services" - - "gorm.io/gorm" -) - - -type AppContext struct { - Db *gorm.DB - PostService *services.PostService - Jwt *auth.JwtTokenGenerator - AdminPassword string - Instance string - Tag string -} - -internal/auth/jwt.go - -package auth - -import ( - "strings" - "time" - - "github.com/gin-gonic/gin" - "github.com/golang-jwt/jwt/v5" -) - -type JwtTokenGenerator struct { - Key string - Issuer string - Audience string -} - -func NewJwtTokenGenerator(key string, issuer string, audience string) *JwtTokenGenerator { - return &JwtTokenGenerator{ - Key: key, - Issuer: issuer, - Audience: audience, - } -} - -func (j *JwtTokenGenerator) GenerateToken(claims map[string]interface{}) (string, error) { - token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ - "exp": time.Now().AddDate(0, 0, 3).Unix(), - "iat": time.Now().Unix(), - "iss": j.Issuer, - "aud": j.Audience, - }) - for k, v := range claims { - token.Claims.(jwt.MapClaims)[k] = v - } - - return token.SignedString([]byte(j.Key)) -} - -// Gin middleware -func (j *JwtTokenGenerator) GinMiddleware() gin.HandlerFunc { - return func(c *gin.Context) { - authHeader := c.GetHeader("Authorization") - if authHeader == "" { - c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"}) - return - } - - tokenString := strings.TrimPrefix(authHeader, "Bearer ") - t, err := jwt.Parse(tokenString, func(t *jwt.Token) (interface{}, error) { - if _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok { - return nil, jwt.ErrSignatureInvalid - } - return []byte(j.Key), nil - }) - - if err != nil { - c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"}) - return - } - - claims, ok := t.Claims.(jwt.MapClaims) - if !ok || claims["role"] != "admin" { - c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"}) - return - } - - c.Next() - } -} - -internal/helpers/dbHelpers.go - -package helpers - -import ( - "CatsOfMastodonBotGo/internal/models" - - "gorm.io/gorm" -) - -func AddMigrations(db *gorm.DB) { - db.AutoMigrate(&models.Post{}, &models.MediaAttachment{}, &models.Account{}) -} - - - - -internal/helpers/SetupAppContext.go - -package helpers - -import ( - "CatsOfMastodonBotGo/internal" - "CatsOfMastodonBotGo/internal/auth" - "CatsOfMastodonBotGo/internal/services" - "log" - "os" - - "gorm.io/driver/sqlite" - "gorm.io/gorm" - "gorm.io/gorm/logger" -) - -func SetupAppContext() *internal.AppContext { - // Setup AppContext - instance := os.Getenv("CAOM_INSTANCE") - if instance == "" { - instance = "https://mstdn.party" - } - tag := os.Getenv("CAOM_TAG") - if tag == "" { - tag = "catsofmastodon" - } - adminPassword := os.Getenv("CAOM_ADMIN_PASSWORD") - if adminPassword == "" { - log.Println("No admin password provided, using default password 'catsaregood'") - adminPassword = "catsaregood" - } - - // Jwt params - secret := os.Getenv("CAOM_JWT_SECRET") - if secret == "" { - log.Fatal("No jwt secret provided, using default secret 'secret'") - } - issuer := os.Getenv("CAOM_JWT_ISSUER") - if issuer == "" { - log.Println("No jwt issuer provided, using default issuer 'CatsOfMastodonBotGo'") - issuer = "CatsOfMastodonBotGo" - } - audience := os.Getenv("CAOM_JWT_AUDIENCE") - if audience == "" { - log.Println("No jwt audience provided, using default audience 'CatsOfMastodonBotGo'") - audience = "CatsOfMastodonBotGo" - } - - // Setup database - db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{Logger: logger.Default.LogMode(logger.Warn)}) - if err != nil { - panic("failed to connect database") - } - AddMigrations(db) - - //Setup PostService - var postService = services.NewPostService(db) - - // Setup Jwt - var jwt = auth.NewJwtTokenGenerator(secret, issuer, audience) - - // Inititlize AppContext - var appContext = &internal.AppContext{ - Db: db, - PostService: postService, - Jwt: jwt, - AdminPassword: adminPassword, - Instance: instance, - Tag: tag, - } - return appContext - -} - - -internal/models/account.go - -package models - -type Account struct { - AccId string `json:"id" gorm:"primaryKey"` - Username string `json:"username"` - Acct string `json:"acct"` - DisplayName string `json:"display_name"` - IsBot bool `json:"bot"` - Url string `json:"url"` - AvatarStatic string `json:"avatar_static"` -} - -internal/models/mediaAttachment.go - -package models - -type MediaAttachment struct { - ID string `json:"id" gorm:"primaryKey"` - Type string `json:"type"` - Url string `json:"url"` - PreviewUrl string `json:"preview_url"` - RemoteUrl string `json:"remote_url"` - PostID string // Foreign key to Post - Approved bool `json:"approved"` - Rejected bool `json:"rejected"` -} - - -internal/models/post.go - -package models - -type Post struct { - ID string `json:"id" gorm:"primaryKey"` - Url string `json:"url"` - AccountID string // Foreign key field (must match Account.AccId) - Account Account `json:"account" gorm:"foreignKey:AccountID;references:AccId"` - Attachments []MediaAttachment `json:"media_attachments" gorm:"foreignKey:PostID;references:ID"` -} - - -internal/models/requestModels/approveMedia.go - -package requestmodels - -type ApproveMediaInput struct { - MediaId string `json:"mediaId" binding:"required"` -} - -internal/models/requestModels/login.go - -package requestmodels - -type LoginInput struct { - Password string `json:"password" binding:"required"` -} - -internal/models/requestModels/rejectMedia.go - -package requestmodels - -type RejectMediaInput struct { - MediaId string `json:"mediaId" binding:"required"` -} - -internal/server/router.go - -package server - -import ( - "CatsOfMastodonBotGo/internal" - handlers_admin "CatsOfMastodonBotGo/internal/web/handlers/admin" - handlers_api "CatsOfMastodonBotGo/internal/web/handlers/api" - - "github.com/gin-contrib/cors" - "github.com/gin-gonic/gin" -) - -func SetupRouter(appContext *internal.AppContext) *gin.Engine { - r := gin.Default() - - r.Use(cors.New(cors.Config{ - AllowOrigins: []string{"https://extra-mama-chiz.surge.sh"}, // Just for test - AllowMethods: []string{"POST", "GET", "OPTIONS"}, - AllowHeaders: []string{"Origin", "Content-Type", "Authorization"}, - AllowCredentials: true, - })) - - adminDashboardHandler := handlers_admin.NewAdminDashboardHandler(appContext) - apiHandler := handlers_api.NewApiEndpointHandler(appContext) - - admin := r.Group("/admin") - - // My man, this is done way more efficient and fast in .NET, specially the authentication part - admin.POST("/login", adminDashboardHandler.Login) - admin.GET("/getmedia", appContext.Jwt.GinMiddleware(), adminDashboardHandler.GetMedia) - admin.POST("/approve", appContext.Jwt.GinMiddleware(), adminDashboardHandler.ApproveMedia) - admin.POST("/reject", appContext.Jwt.GinMiddleware(), adminDashboardHandler.RejectMedia) - - api := r.Group("/api") - - api.GET("/post/random", apiHandler.GetRandomPost) - - return r -} - - -internal/services/postService.go - -package services - -import ( - "CatsOfMastodonBotGo/internal/models" - "context" - "encoding/json" - "fmt" - "net/http" - "strings" - - "gorm.io/gorm" - "gorm.io/gorm/clause" -) - -type PostService struct { - db *gorm.DB -} - -// Constructor -func NewPostService(db *gorm.DB) *PostService { - return &PostService{db: db} -} - -func (*PostService) GetPostsFromApi(ctx context.Context, tag string, instance string) (error, []models.Post) { - var requestUrl = instance + "/api/v1/timelines/tag/" + tag + "?limit=40" - req, err := http.NewRequestWithContext(ctx, "GET", requestUrl, nil) - if err != nil { - return err, nil - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return err, nil - } - if resp.StatusCode != 200 || strings.Split(strings.ToLower(resp.Header.Get("Content-Type")), ";")[0] != "application/json" { - return fmt.Errorf("Status code:", resp.StatusCode, " Content-Type:", resp.Header.Get("Content-Type")), nil - } - - var posts []models.Post = nil - err = json.NewDecoder(resp.Body).Decode(&posts) - if err != nil { - return err, nil - } - // defer: it basically means "do this later when the function returns" - defer resp.Body.Close() - if posts == nil { - return fmt.Errorf("no posts found for tag %s on instance %s", tag, instance), nil - } - return nil, posts -} - -func (ps *PostService) GetExistingPostIds() []string { - var existingPostIds []string - ps.db.Model(&models.Post{}).Pluck("id", &existingPostIds) - return existingPostIds -} - -func (ps *PostService) GetExistingAccountIds() []string { - var existingAccountIds []string - ps.db.Model(&models.Account{}).Pluck("acc_id", &existingAccountIds) - return existingAccountIds -} - - -func (*PostService) GetNewPosts(existingPostIds []string, posts []models.Post) []models.Post { - var newPosts []models.Post = nil - for _, post := range posts { - if !arrayContains(existingPostIds, post.ID) && len(post.Attachments) > 0 && !post.Account.IsBot { - var allImageMedia = true - for _, attachment := range post.Attachments { - if attachment.Type != "image" { - allImageMedia = false - break - } - } // Inefficient but anyways - if allImageMedia { - newPosts = append(newPosts, post) - } - } - } - return newPosts -} - -func (*PostService) GetNewAccounts(existingAccountIds []string, posts []models.Post) []models.Account { - var newAccounts []models.Account = nil - for _, post := range posts { - if !arrayContains(existingAccountIds, post.Account.AccId) { - newAccounts = append(newAccounts, post.Account) - } - } - return newAccounts -} - -func (ps *PostService) InsertNewPosts(newPosts []models.Post) int { - return int(ps.db.Create(&newPosts).RowsAffected) -} - -func (ps *PostService) InsertNewAccounts(newAccounts []models.Account) int { - return int(ps.db.Clauses(clause.OnConflict{UpdateAll: true}).Create(&newAccounts).RowsAffected) -} - -// From this point on, its for the api endpoints - -func (ps *PostService) GetRandomPost() models.Post { - var post models.Post - ps.db. - Preload("Account"). - Preload("Attachments", "approved = ?", true). - Order("RANDOM()"). - First(&post) - if len(post.Attachments) > 0 { - post.Attachments = []models.MediaAttachment{post.Attachments[0]} - } - return post -} - -func (ps *PostService) ApproveMedia(mediaId string) bool { - return ps.db.Model(&models.MediaAttachment{}). - Where("id = ?", mediaId). - Update("approved", true).RowsAffected > 0 -} - -func (ps *PostService) RejectMedia(mediaId string) bool { - return ps.db.Model(&models.MediaAttachment{}). - Where("id = ?", mediaId). - Update("rejected", true).RowsAffected > 0 -} - -// Get a post which approve and rejet are false (For admin panel) -func (ps *PostService) GetMedia() models.MediaAttachment { - var media models.MediaAttachment - ps.db.Model(&models.MediaAttachment{}). - Where("approved = ?", false). - Where("rejected = ?", false). - Order("RANDOM()"). - First(&media) - return media -} - - -func arrayContains(arr []string, str string) bool { - for _, a := range arr { - if a == str { - return true - } - } - return false -} - - -internal/web/handlers/admin/adminDash.go - -package handlers_admin - -import ( - "CatsOfMastodonBotGo/internal" - "net/http" - - requestmodels "CatsOfMastodonBotGo/internal/models/requestModels" - - "github.com/gin-gonic/gin" -) - -type AdminDashboardHandler struct { - AppContext *internal.AppContext -} - -func NewAdminDashboardHandler(appContext *internal.AppContext) *AdminDashboardHandler { - return &AdminDashboardHandler{ - AppContext: appContext, - } -} - -func (appContext *AdminDashboardHandler) ApproveMedia(c *gin.Context) { - var input requestmodels.ApproveMediaInput - if err := c.ShouldBindJSON(&input); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) - return - } - if appContext.AppContext.PostService.ApproveMedia(input.MediaId) { - c.JSON(http.StatusOK, gin.H{"message": "Media approved successfully"}) - } else { - c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to approve media"}) - } -} - -func (appContext *AdminDashboardHandler) RejectMedia(c *gin.Context) { - var input requestmodels.RejectMediaInput - if err := c.ShouldBindJSON(&input); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) - return - } - if appContext.AppContext.PostService.RejectMedia(input.MediaId) { - c.JSON(http.StatusOK, gin.H{"message": "Media rejected successfully"}) - } else { - c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to reject media"}) - } -} - -func (appContext *AdminDashboardHandler) GetMedia(c *gin.Context) { - media := appContext.AppContext.PostService.GetMedia() - c.JSON(http.StatusOK, media) -} - -func (appContext *AdminDashboardHandler) Login(c *gin.Context) { - - var input requestmodels.LoginInput - - // Validate data - if err := c.ShouldBindJSON(&input); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) - return - } - - if input.Password == appContext.AppContext.AdminPassword { // Its more than enough for this project - token, err := appContext.AppContext.Jwt.GenerateToken(map[string]interface{}{"role": "admin"}) - if err != nil { - c.JSON(http.StatusInternalServerError, gin.H{"error": "Token generation failed"}) - return - } - - c.JSON(http.StatusOK, gin.H{"message": "Login successful", "token": token}) - - } else { - c.JSON(401, gin.H{ - "error": "wrong password", - }) - return - } - -} - - -internal/web/handlers/api/apiEndpoint.go - -package handlers_api - -import ( - "CatsOfMastodonBotGo/internal" - "github.com/gin-gonic/gin" -) - -type ApiEndpointHandler struct { - AppContext *internal.AppContext -} - -func NewApiEndpointHandler(appContext *internal.AppContext) *ApiEndpointHandler { - return &ApiEndpointHandler{ - AppContext: appContext, - } -} - -func (appContext *ApiEndpointHandler) GetRandomPost(c *gin.Context) { - c.JSON(200,appContext.AppContext.PostService.GetRandomPost()) -} - -cmd/main.go - -package main - -import ( - "CatsOfMastodonBotGo/internal/helpers" - "CatsOfMastodonBotGo/internal/models" - "CatsOfMastodonBotGo/internal/server" - "context" - "log" - "time" - -) - -func main() { - // Setup AppContext - var appContext = helpers.SetupAppContext() - - ticker := time.NewTicker(10 * time.Minute) - - runFetchPosts := func() { - // Get posts - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - var posts []models.Post = nil - err, posts := appContext.PostService.GetPostsFromApi(ctx, appContext.Tag, appContext.Instance) - if err != nil { - log.Println(err) - return - } - - var existingPostIds = appContext.PostService.GetExistingPostIds() - var existingAccountIds = appContext.PostService.GetExistingAccountIds() - var newPosts = appContext.PostService.GetNewPosts(existingPostIds, posts) - var newAccounts = appContext.PostService.GetNewAccounts(existingAccountIds, newPosts) - - // Save to database - log.Printf("Fetched %d posts; %d existing posts; %d new posts and %d new accounts\n", len(posts), len(existingPostIds), len(newPosts), len(newAccounts)) - - // Additional logging - if newAccounts != nil { - log.Printf("Inserted %d accounts\n", appContext.PostService.InsertNewAccounts(newAccounts)) - } - if newPosts != nil { - log.Printf("Inserted %d posts\n", appContext.PostService.InsertNewPosts(newPosts)) - } - } - - go func() { - for range ticker.C { - runFetchPosts() - } - }() - - // Run initial fetch on startup - go func() { - runFetchPosts() - }() - - // https://seefnasrul.medium.com/create-your-first-go-rest-api-with-jwt-authentication-in-gin-framework-dbe5bda72817 - - r := server.SetupRouter(appContext) - err := r.Run(":8080") - if err != nil { - log.Fatal(err) - } - -} - - -go.mod - -module CatsOfMastodonBotGo - -go 1.24.2 - -require ( - github.com/appleboy/gin-jwt/v2 v2.10.3 // indirect - github.com/bytedance/sonic v1.13.2 // indirect - github.com/bytedance/sonic/loader v0.2.4 // indirect - github.com/cloudwego/base64x v0.1.5 // indirect - github.com/cloudwego/iasm v0.2.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.9 // indirect - github.com/gin-contrib/cors v1.7.5 // indirect - github.com/gin-contrib/sse v1.1.0 // indirect - github.com/gin-gonic/gin v1.10.0 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.26.0 // indirect - github.com/goccy/go-json v0.10.5 // indirect - github.com/golang-jwt/jwt/v4 v4.5.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.5 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.10 // indirect - github.com/leodido/go-urn v1.4.0 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-sqlite3 v1.14.22 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.2.4 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.12 // indirect - github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect - golang.org/x/arch v0.17.0 // indirect - golang.org/x/crypto v0.38.0 // indirect - golang.org/x/net v0.40.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.25.0 // indirect - google.golang.org/protobuf v1.36.6 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - gorm.io/driver/sqlite v1.5.7 // indirect - gorm.io/gorm v1.26.1 // indirect -) - - -go.sum - -github.com/appleboy/gin-jwt/v2 v2.10.3 h1:KNcPC+XPRNpuoBh+j+rgs5bQxN+SwG/0tHbIqpRoBGc= -github.com/appleboy/gin-jwt/v2 v2.10.3/go.mod h1:LDUaQ8mF2W6LyXIbd5wqlV2SFebuyYs4RDwqMNgpsp8= -github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= -github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= -github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= -github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY= -github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= -github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= -github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= -github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY= -github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok= -github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk= -github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0= -github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= -github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= -github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= -github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= -github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= -github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= -github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= -github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= -github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= -github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= -github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= -github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= -github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= -github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= -github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= -github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= -github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= -golang.org/x/arch v0.17.0 h1:4O3dfLzd+lQewptAHqjewQZQDyEdejz3VwgeYwkZneU= -golang.org/x/arch v0.17.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= -golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= -golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= -google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= -google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I= -gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4= -gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde h1:9DShaph9qhkIYw7QF91I/ynrr4cOO2PZra2PFD7Mfeg= -gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= -gorm.io/gorm v1.26.1 h1:ghB2gUI9FkS46luZtn6DLZ0f6ooBJ5IbVej2ENFDjRw= -gorm.io/gorm v1.26.1/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE= -nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= - -