mirror of
https://github.com/harness/drone.git
synced 2022-03-12 19:30:52 +03:00
fixbug gitee provide refresher (#3168)
This commit is contained in:
@@ -123,8 +123,14 @@ func provideGiteeClient(config config.Config) *scm.Client {
|
||||
}
|
||||
client.Client = &http.Client{
|
||||
Transport: &oauth2.Transport{
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
Base: defaultTransport(config.Gitee.SkipVerify),
|
||||
Scheme: oauth2.SchemeBearer,
|
||||
Source: &oauth2.Refresher{
|
||||
ClientID: config.Gitee.ClientID,
|
||||
ClientSecret: config.Gitee.ClientSecret,
|
||||
Endpoint: strings.TrimSuffix(config.Gitee.Server, "/") + "/oauth/token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
},
|
||||
Base: defaultTransport(config.Gitee.SkipVerify),
|
||||
},
|
||||
}
|
||||
return client
|
||||
|
||||
@@ -116,7 +116,7 @@ func provideGiteaLogin(config config.Config) login.Middleware {
|
||||
if config.Gitea.Server == "" {
|
||||
return nil
|
||||
}
|
||||
return &gitea.Config {
|
||||
return &gitea.Config{
|
||||
ClientID: config.Gitea.ClientID,
|
||||
ClientSecret: config.Gitea.ClientSecret,
|
||||
Server: config.Gitea.Server,
|
||||
@@ -197,6 +197,15 @@ func provideRefresher(config config.Config) *oauth2.Refresher {
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
Client: defaultClient(config.Gitea.SkipVerify),
|
||||
}
|
||||
case config.Gitee.ClientID != "":
|
||||
return &oauth2.Refresher{
|
||||
ClientID: config.Gitee.ClientID,
|
||||
ClientSecret: config.Gitee.ClientSecret,
|
||||
Endpoint: strings.TrimSuffix(config.Gitee.Server, "/") + "/oauth/token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
Client: defaultClient(config.Gitee.SkipVerify),
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user