Add Gitea Oauth

With fallback to basic auth if Gitea server does not support oauth
This commit is contained in:
Matti Ranta 2019-03-08 12:22:20 -05:00
parent dd2cc872c2
commit 665398fb4f
No known key found for this signature in database
GPG key ID: D9B5613BEB813F99
2 changed files with 14 additions and 3 deletions

View file

@ -293,9 +293,11 @@ type (
// Gitea provides the gitea client configuration.
Gitea struct {
Server string `envconfig:"DRONE_GITEA_SERVER"`
SkipVerify bool `envconfig:"DRONE_GITEA_SKIP_VERIFY"`
Debug bool `envconfig:"DRONE_GITEA_DEBUG"`
ClientID string `envconfig:"DRONE_GITEA_CLIENT_ID"`
ClientSecret string `envconfig:"DRONE_GITEA_CLIENT_SECRET"`
Server string `envconfig:"DRONE_GITEA_SERVER"`
SkipVerify bool `envconfig:"DRONE_GITEA_SKIP_VERIFY"`
Debug bool `envconfig:"DRONE_GITEA_DEBUG"`
}
// Github provides the github client configuration.

View file

@ -91,6 +91,15 @@ func provideGiteaLogin(config config.Config) login.Middleware {
if config.Gitea.Server == "" {
return nil
}
if config.Gitea.ClientID != "" {
return &gitea.Config {
ClientID: config.Gitea.ClientID,
ClientSecret: config.Gitea.ClientSecret,
Server: config.Gitea.Server,
Client: defaultClient(config.Gitea.SkipVerify),
Logger: logrus.StandardLogger(),
}
}
return &gogs.Config{
Label: "drone",
Login: "/login/form",