diff --git a/cmd/authlibskin/config.yaml.template b/cmd/authlibskin/config.yaml.template index 7ef46d2..24c3ab2 100644 --- a/cmd/authlibskin/config.yaml.template +++ b/cmd/authlibskin/config.yaml.template @@ -50,7 +50,7 @@ textureBaseUrl: "" webBaseUrl: "" # 皮肤站名字,用于在多个地方展示 -serverName: "" +serverName: "没有设置名字" captcha: # 验证码类型,目前只支持 cloudflare turnstile diff --git a/cmd/authlibskin/main.go b/cmd/authlibskin/main.go index 6c5397f..7bf4e82 100644 --- a/cmd/authlibskin/main.go +++ b/cmd/authlibskin/main.go @@ -2,6 +2,8 @@ package main import ( "context" + "crypto/rand" + "crypto/rsa" "errors" "flag" "fmt" @@ -12,6 +14,7 @@ import ( "github.com/samber/lo" "github.com/xmdhs/authlib-skin/config" "github.com/xmdhs/authlib-skin/server" + "github.com/xmdhs/authlib-skin/utils/sign" ) var configPath string @@ -29,7 +32,7 @@ func main() { b, err := os.ReadFile(configPath) if err != nil { if errors.Is(err, os.ErrNotExist) { - lo.Must0(os.WriteFile("config.yaml", configTempLate, 0600)) + lo.Must0(os.WriteFile(configPath, configTempLate, 0600)) fmt.Println("未找到配置文件,已写入模板配置文件") return } @@ -37,6 +40,13 @@ func main() { } config := lo.Must(config.YamlDeCode(b)) + if config.RsaPriKey == "" { + rsa2048 := lo.Must(rsa.GenerateKey(rand.Reader, 4096)) + as := sign.NewAuthlibSignWithKey(rsa2048) + config.RsaPriKey = lo.Must(as.GetPriKey()) + lo.Must0(os.WriteFile(configPath, []byte(config.RsaPriKey), 0600)) + } + s, cancel := lo.Must2(server.InitializeRoute(ctx, config)) defer cancel() panic(s.ListenAndServe()) diff --git a/frontend/src/components/CaptchaWidget.tsx b/frontend/src/components/CaptchaWidget.tsx index d670767..c24cfcc 100644 --- a/frontend/src/components/CaptchaWidget.tsx +++ b/frontend/src/components/CaptchaWidget.tsx @@ -48,6 +48,10 @@ const CaptchaWidget = forwardRef(({ onSuccess }, ref) => { return } + if (data?.captcha.type == "") { + return <> + } + return ( <>