Fix: cookie timeout
All checks were successful
Go test / run-go-vet (push) Successful in 6s
Go test / check-swagger-up-to-date (push) Successful in 10s
Go test / run-go-test (push) Successful in 36s
Go test / cleanup-go-test (push) Successful in 14s
Go test / release-image (push) Successful in 3m20s

This commit is contained in:
2025-12-12 02:09:46 +08:00
parent 87ae3b76c2
commit 1cf3a9ef0b
6 changed files with 57 additions and 8 deletions

37
cmds/genToken.go Normal file
View File

@@ -0,0 +1,37 @@
package cmds
import (
"fmt"
"net/http"
"github.com/go-resty/resty/v2"
"github.com/spf13/cobra"
)
type genLoginUrlPayload struct {
LoginUrl string `json:"loginUrl"`
}
type loginPayload struct {
Token string `json:"token"`
}
var genTokenCmd = &cobra.Command{
Use: "gen-token",
Run: func(cmd *cobra.Command, args []string) {
client := resty.New()
var payload genLoginUrlPayload
resp, err := client.R().
SetBody(`{"userId": "testuser1"}`).
SetAuthToken("poop").
SetResult(&payload).
Post("http://localhost:8080/auth/gen-login-url")
if err != nil || resp.StatusCode() != http.StatusOK {
panic(err)
}
fmt.Printf("url: %s\n", payload.LoginUrl)
},
}

View File

@@ -21,4 +21,5 @@ func init() {
cobra.EnableTraverseRunHooks = true
RootCmd.AddCommand(serveCmd)
RootCmd.AddCommand(genTokenCmd)
}

View File

@@ -101,6 +101,7 @@ var serveCmd = &cobra.Command{
Use(middlewares.AccessLog).
Use(middlewares.CORSHandler)
backend.OPTIONS("/*any", utils.GetHealthz)
backend.GET("/healthz", utils.GetHealthz)
apiGroup := backend.NewGroup("/api").
@@ -136,6 +137,8 @@ var serveCmd = &cobra.Command{
func init() {
serveCmd.Flags().
String("port", "8080", "Port to listen on")
serveCmd.Flags().
Bool("https", false, "Enable https mode")
serveCmd.Flags().
String("external-url", "http://localhost:8080", "External url for login")
serveCmd.Flags().