添加 OIDC 和 OAuth2 服务器的基础结构,包括配置、数据库模型、服务、处理器和路由。新增登录页面模板,支持用户认证和授权流程。

This commit is contained in:
2025-04-17 01:08:15 +08:00
commit 0368547137
17 changed files with 1049 additions and 0 deletions

46
config/config.go Normal file
View File

@@ -0,0 +1,46 @@
package config
import (
"os"
"gopkg.in/yaml.v3"
)
type Config struct {
Server struct {
Port int `yaml:"port"`
Host string `yaml:"host"`
} `yaml:"server"`
Database struct {
Type string `yaml:"type"`
Path string `yaml:"path"`
} `yaml:"database"`
OAuth struct {
IssuerURL string `yaml:"issuer_url"`
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
RedirectURL string `yaml:"redirect_url"`
} `yaml:"oauth"`
JWT struct {
SigningKey string `yaml:"signing_key"`
} `yaml:"jwt"`
}
var GlobalConfig Config
func Init() error {
configFile, err := os.ReadFile("config/config.yaml")
if err != nil {
return err
}
err = yaml.Unmarshal(configFile, &GlobalConfig)
if err != nil {
return err
}
return nil
}