feat: initial commit
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/markbates/goth"
|
||||
"github.com/markbates/goth/gothic"
|
||||
"github.com/markbates/goth/providers/gitea"
|
||||
"github.com/markbates/goth/providers/github"
|
||||
"github.com/markbates/goth/providers/google"
|
||||
"github.com/markbates/goth/providers/openidConnect"
|
||||
@ -79,6 +80,26 @@ func NewAuthHandlerFromConfig(ctx context.Context, conf *config.Config) (*auth.H
|
||||
})
|
||||
}
|
||||
|
||||
if conf.Auth.Providers.Gitea.Key != "" && conf.Auth.Providers.Gitea.Secret != "" {
|
||||
giteaProvider := gitea.NewCustomisedURL(
|
||||
conf.Auth.Providers.Gitea.Key,
|
||||
conf.Auth.Providers.Gitea.Secret,
|
||||
fmt.Sprintf("%s/auth/providers/gitea/callback", conf.HTTP.BaseURL),
|
||||
conf.Auth.Providers.Gitea.AuthURL,
|
||||
conf.Auth.Providers.Gitea.TokenURL,
|
||||
conf.Auth.Providers.Gitea.ProfileURL,
|
||||
conf.Auth.Providers.Gitea.Scopes...,
|
||||
)
|
||||
|
||||
gothProviders = append(gothProviders, giteaProvider)
|
||||
|
||||
providers = append(providers, auth.Provider{
|
||||
ID: giteaProvider.Name(),
|
||||
Label: conf.Auth.Providers.Gitea.Label,
|
||||
Icon: "fa-git-alt",
|
||||
})
|
||||
}
|
||||
|
||||
if conf.Auth.Providers.OIDC.Key != "" && conf.Auth.Providers.OIDC.Secret != "" {
|
||||
oidcProvider, err := openidConnect.New(
|
||||
conf.Auth.Providers.OIDC.Key,
|
||||
@ -107,13 +128,6 @@ func NewAuthHandlerFromConfig(ctx context.Context, conf *config.Config) (*auth.H
|
||||
auth.WithProviders(providers...),
|
||||
}
|
||||
|
||||
if conf.Auth.DefaultAdmin.Email != "" && conf.Auth.DefaultAdmin.Provider != "" {
|
||||
opts = append(opts, auth.WithDefaultAdmin(auth.DefaultAdmin{
|
||||
Provider: conf.Auth.DefaultAdmin.Provider,
|
||||
Email: conf.Auth.DefaultAdmin.Email,
|
||||
}))
|
||||
}
|
||||
|
||||
auth := auth.NewHandler(
|
||||
sessionStore,
|
||||
opts...,
|
||||
|
Reference in New Issue
Block a user