update for version 1.1.0 [ci skip]
This commit is contained in:
commit
416f94afcd
2 changed files with 27 additions and 4 deletions
|
@ -117,6 +117,7 @@ func provideGiteaClient(config config.Config) *scm.Client {
|
|||
if config.Gitea.Debug {
|
||||
client.DumpResponse = httputil.DumpResponse
|
||||
}
|
||||
if config.Gitea.ClientID == "" {
|
||||
client.Client = &http.Client{
|
||||
Transport: &oauth2.Transport{
|
||||
Scheme: oauth2.SchemeToken,
|
||||
|
@ -126,6 +127,20 @@ func provideGiteaClient(config config.Config) *scm.Client {
|
|||
}
|
||||
return client
|
||||
}
|
||||
client.Client = &http.Client{
|
||||
Transport: &oauth2.Transport{
|
||||
Scheme: oauth2.SchemeBearer,
|
||||
Source: &oauth2.Refresher{
|
||||
ClientID: config.Gitea.ClientID,
|
||||
ClientSecret: config.Gitea.ClientSecret,
|
||||
Endpoint: config.Gitea.Server + "/login/oauth/access_token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
},
|
||||
Base: defaultTransport(config.Gitea.SkipVerify),
|
||||
},
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// provideGitlabClient is a Wire provider function that returns
|
||||
// a GitLab client based on the environment configuration.
|
||||
|
|
|
@ -162,15 +162,23 @@ func provideStashLogin(config config.Config) login.Middleware {
|
|||
}
|
||||
|
||||
// provideRefresher is a Wire provider function that returns
|
||||
// an oauth token refresher for Bitbucket.
|
||||
// an oauth token refresher for Bitbucket and Gitea
|
||||
func provideRefresher(config config.Config) *oauth2.Refresher {
|
||||
if config.Bitbucket.ClientID != "" {
|
||||
switch {
|
||||
case config.Bitbucket.ClientID != "":
|
||||
return &oauth2.Refresher{
|
||||
ClientID: config.Bitbucket.ClientID,
|
||||
ClientSecret: config.Bitbucket.ClientSecret,
|
||||
Endpoint: "https://bitbucket.org/site/oauth2/access_token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
}
|
||||
case config.Gitea.ClientID != "":
|
||||
return &oauth2.Refresher{
|
||||
ClientID: config.Gitea.ClientID,
|
||||
ClientSecret: config.Gitea.ClientSecret,
|
||||
Endpoint: config.Gitea.Server + "/login/oauth/access_token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue