mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-16 02:09:18 +08:00
0058453fd9
Backport #25030 by @HesterG Close #24808 Co-Authour @wxiaoguang @silverwind 1. Most svgs are found from https://worldvectorlogo.com/ , and some are from conversion of png to svg. (facebook and nextcloud). And also changed `templates/user/settings/security/accountlinks.tmpl`. 2. Fixed display name and iconurl related logic # After <img width="1436" alt="Screen Shot 2023-06-05 at 14 09 05" src="https://github.com/go-gitea/gitea/assets/17645053/a5db39d8-1ab0-4676-82a4-fba60a1d1f84"> On mobile <img width="378" alt="Screen Shot 2023-06-05 at 14 09 46" src="https://github.com/go-gitea/gitea/assets/17645053/71d0f51b-baac-4f48-8ca2-ae0e013bd62e"> user/settings/security/accountlinks (The dropdown might be improved later) <img width="973" alt="Screen Shot 2023-06-01 at 10 01 44" src="https://github.com/go-gitea/gitea/assets/17645053/27010e7e-2785-4fc5-8c49-b06621898f37"> Co-authored-by: HesterG <hestergong@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package oauth2
|
|
|
|
import (
|
|
"code.gitea.io/gitea/modules/log"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
"github.com/markbates/goth"
|
|
"github.com/markbates/goth/providers/openidConnect"
|
|
)
|
|
|
|
// OpenIDProvider is a GothProvider for OpenID
|
|
type OpenIDProvider struct{}
|
|
|
|
// Name provides the technical name for this provider
|
|
func (o *OpenIDProvider) Name() string {
|
|
return "openidConnect"
|
|
}
|
|
|
|
// DisplayName returns the friendly name for this provider
|
|
func (o *OpenIDProvider) DisplayName() string {
|
|
return "OpenID Connect"
|
|
}
|
|
|
|
// IconURL returns an icon path for this provider
|
|
func (o *OpenIDProvider) IconURL() string {
|
|
return setting.AppSubURL + "/assets/img/svg/gitea-openid.svg"
|
|
}
|
|
|
|
// CreateGothProvider creates a GothProvider from this Provider
|
|
func (o *OpenIDProvider) CreateGothProvider(providerName, callbackURL string, source *Source) (goth.Provider, error) {
|
|
scopes := setting.OAuth2Client.OpenIDConnectScopes
|
|
if len(scopes) == 0 {
|
|
scopes = append(scopes, source.Scopes...)
|
|
}
|
|
|
|
provider, err := openidConnect.New(source.ClientID, source.ClientSecret, callbackURL, source.OpenIDConnectAutoDiscoveryURL, scopes...)
|
|
if err != nil {
|
|
log.Warn("Failed to create OpenID Connect Provider with name '%s' with url '%s': %v", providerName, source.OpenIDConnectAutoDiscoveryURL, err)
|
|
}
|
|
return provider, err
|
|
}
|
|
|
|
// CustomURLSettings returns the custom url settings for this provider
|
|
func (o *OpenIDProvider) CustomURLSettings() *CustomURLSettings {
|
|
return nil
|
|
}
|
|
|
|
var _ GothProvider = &OpenIDProvider{}
|
|
|
|
func init() {
|
|
RegisterGothProvider(&OpenIDProvider{})
|
|
}
|