2021-08-06 03:11:08 +02:00
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
2022-11-27 19:20:29 +01:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-08-06 03:11:08 +02:00
|
|
|
|
|
|
|
package oauth2
|
|
|
|
|
2023-06-13 14:04:40 +02:00
|
|
|
import (
|
|
|
|
"html/template"
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/log"
|
|
|
|
"code.gitea.io/gitea/modules/svg"
|
|
|
|
)
|
2023-06-09 12:59:18 +02:00
|
|
|
|
2021-08-06 03:11:08 +02:00
|
|
|
// BaseProvider represents a common base for Provider
|
|
|
|
type BaseProvider struct {
|
|
|
|
name string
|
|
|
|
displayName string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Name provides the technical name for this provider
|
|
|
|
func (b *BaseProvider) Name() string {
|
|
|
|
return b.name
|
|
|
|
}
|
|
|
|
|
|
|
|
// DisplayName returns the friendly name for this provider
|
|
|
|
func (b *BaseProvider) DisplayName() string {
|
|
|
|
return b.displayName
|
|
|
|
}
|
|
|
|
|
2023-06-13 14:04:40 +02:00
|
|
|
// IconHTML returns icon HTML for this provider
|
|
|
|
func (b *BaseProvider) IconHTML() template.HTML {
|
|
|
|
svgName := "gitea-" + b.name
|
|
|
|
switch b.name {
|
|
|
|
case "gplus":
|
|
|
|
svgName = "gitea-google"
|
|
|
|
case "github":
|
|
|
|
svgName = "octicon-mark-github"
|
|
|
|
}
|
|
|
|
svgHTML := svg.RenderHTML(svgName, 20, "gt-mr-3")
|
|
|
|
if svgHTML == "" {
|
|
|
|
log.Error("No SVG icon for oauth2 provider %q", b.name)
|
|
|
|
svgHTML = svg.RenderHTML("gitea-openid", 20, "gt-mr-3")
|
2023-06-09 12:59:18 +02:00
|
|
|
}
|
2023-06-13 14:04:40 +02:00
|
|
|
return svgHTML
|
2021-08-06 03:11:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CustomURLSettings returns the custom url settings for this provider
|
|
|
|
func (b *BaseProvider) CustomURLSettings() *CustomURLSettings {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-06-09 12:59:18 +02:00
|
|
|
var _ Provider = &BaseProvider{}
|