mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 21:53:51 +03:00
Merge pull request 'Revert "[TESTS] oauth2: make it possible to use an alternate http.Client"' (#1985) from earl-warren/forgejo:wip-oauth-npe into forgejo-development
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/1985 Reviewed-by: Loïc Dachary <dachary@noreply.codeberg.org>
This commit is contained in:
commit
4c9a4accf9
3 changed files with 7 additions and 30 deletions
|
@ -1,10 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright the Forgejo contributors
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
package oauth2
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
var HTTPClient *http.Client
|
|
|
@ -63,9 +63,7 @@ func init() {
|
||||||
if setting.OAuth2Client.EnableAutoRegistration {
|
if setting.OAuth2Client.EnableAutoRegistration {
|
||||||
scopes = append(scopes, "user:email")
|
scopes = append(scopes, "user:email")
|
||||||
}
|
}
|
||||||
provider := github.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, custom.TokenURL, custom.ProfileURL, custom.EmailURL, scopes...)
|
return github.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, custom.TokenURL, custom.ProfileURL, custom.EmailURL, scopes...), nil
|
||||||
provider.HTTPClient = HTTPClient
|
|
||||||
return provider, nil
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
RegisterGothProvider(NewCustomProvider(
|
RegisterGothProvider(NewCustomProvider(
|
||||||
|
@ -75,9 +73,7 @@ func init() {
|
||||||
ProfileURL: availableAttribute(gitlab.ProfileURL),
|
ProfileURL: availableAttribute(gitlab.ProfileURL),
|
||||||
}, func(clientID, secret, callbackURL string, custom *CustomURLMapping, scopes []string) (goth.Provider, error) {
|
}, func(clientID, secret, callbackURL string, custom *CustomURLMapping, scopes []string) (goth.Provider, error) {
|
||||||
scopes = append(scopes, "read_user")
|
scopes = append(scopes, "read_user")
|
||||||
provider := gitlab.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, custom.TokenURL, custom.ProfileURL, scopes...)
|
return gitlab.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, custom.TokenURL, custom.ProfileURL, scopes...), nil
|
||||||
provider.HTTPClient = HTTPClient
|
|
||||||
return provider, nil
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
RegisterGothProvider(NewCustomProvider(
|
RegisterGothProvider(NewCustomProvider(
|
||||||
|
@ -87,9 +83,7 @@ func init() {
|
||||||
ProfileURL: requiredAttribute(gitea.ProfileURL),
|
ProfileURL: requiredAttribute(gitea.ProfileURL),
|
||||||
},
|
},
|
||||||
func(clientID, secret, callbackURL string, custom *CustomURLMapping, scopes []string) (goth.Provider, error) {
|
func(clientID, secret, callbackURL string, custom *CustomURLMapping, scopes []string) (goth.Provider, error) {
|
||||||
provider := gitea.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, custom.TokenURL, custom.ProfileURL, scopes...)
|
return gitea.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, custom.TokenURL, custom.ProfileURL, scopes...), nil
|
||||||
provider.HTTPClient = HTTPClient
|
|
||||||
return provider, nil
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
RegisterGothProvider(NewCustomProvider(
|
RegisterGothProvider(NewCustomProvider(
|
||||||
|
@ -99,9 +93,7 @@ func init() {
|
||||||
ProfileURL: requiredAttribute(nextcloud.ProfileURL),
|
ProfileURL: requiredAttribute(nextcloud.ProfileURL),
|
||||||
},
|
},
|
||||||
func(clientID, secret, callbackURL string, custom *CustomURLMapping, scopes []string) (goth.Provider, error) {
|
func(clientID, secret, callbackURL string, custom *CustomURLMapping, scopes []string) (goth.Provider, error) {
|
||||||
provider := nextcloud.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, custom.TokenURL, custom.ProfileURL, scopes...)
|
return nextcloud.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, custom.TokenURL, custom.ProfileURL, scopes...), nil
|
||||||
provider.HTTPClient = HTTPClient
|
|
||||||
return provider, nil
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
RegisterGothProvider(NewCustomProvider(
|
RegisterGothProvider(NewCustomProvider(
|
||||||
|
@ -109,9 +101,7 @@ func init() {
|
||||||
AuthURL: requiredAttribute(mastodon.InstanceURL),
|
AuthURL: requiredAttribute(mastodon.InstanceURL),
|
||||||
},
|
},
|
||||||
func(clientID, secret, callbackURL string, custom *CustomURLMapping, scopes []string) (goth.Provider, error) {
|
func(clientID, secret, callbackURL string, custom *CustomURLMapping, scopes []string) (goth.Provider, error) {
|
||||||
provider := mastodon.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, scopes...)
|
return mastodon.NewCustomisedURL(clientID, secret, callbackURL, custom.AuthURL, scopes...), nil
|
||||||
provider.HTTPClient = HTTPClient
|
|
||||||
return provider, nil
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
RegisterGothProvider(NewCustomProvider(
|
RegisterGothProvider(NewCustomProvider(
|
||||||
|
@ -124,12 +114,10 @@ func init() {
|
||||||
azureScopes[i] = azureadv2.ScopeType(scope)
|
azureScopes[i] = azureadv2.ScopeType(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
provider := azureadv2.New(clientID, secret, callbackURL, azureadv2.ProviderOptions{
|
return azureadv2.New(clientID, secret, callbackURL, azureadv2.ProviderOptions{
|
||||||
Tenant: azureadv2.TenantType(custom.Tenant),
|
Tenant: azureadv2.TenantType(custom.Tenant),
|
||||||
Scopes: azureScopes,
|
Scopes: azureScopes,
|
||||||
})
|
}), nil
|
||||||
provider.HTTPClient = HTTPClient
|
|
||||||
return provider, nil
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ func (o *OpenIDProvider) CreateGothProvider(providerName, callbackURL string, so
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Failed to create OpenID Connect Provider with name '%s' with url '%s': %v", providerName, source.OpenIDConnectAutoDiscoveryURL, err)
|
log.Warn("Failed to create OpenID Connect Provider with name '%s' with url '%s': %v", providerName, source.OpenIDConnectAutoDiscoveryURL, err)
|
||||||
}
|
}
|
||||||
provider.HTTPClient = HTTPClient
|
|
||||||
return provider, err
|
return provider, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue