oauth2

package
v3.1.59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: MIT, MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderHeaderKey = "gitea-oauth2-provider"

ProviderHeaderKey is the HTTP header key

Variables

View Source
var ErrAuthSourceNotActivated = errors.New("auth source is not activated")

Functions

func ClearProviders

func ClearProviders()

ClearProviders clears all OAuth2 providers from the goth lib

func Init

func Init(ctx context.Context) error

Init initializes the oauth source

func IsErrOpenIDConnectInitialize

func IsErrOpenIDConnectInitialize(err error) bool

IsErrOpenIDConnectInitialize checks if an error is a ExternalLoginUserAlreadyExist.

func RegisterGothProvider

func RegisterGothProvider(provider GothProvider)

RegisterGothProvider registers a GothProvider

func RegisterProviderWithGothic

func RegisterProviderWithGothic(providerName string, source *Source) error

RegisterProviderWithGothic register a OAuth2 provider in goth lib

func RemoveProviderFromGothic

func RemoveProviderFromGothic(providerName string)

RemoveProviderFromGothic removes the given OAuth2 provider from the goth lib

func ResetOAuth2

func ResetOAuth2(ctx context.Context) error

ResetOAuth2 clears existing OAuth2 providers and loads them from DB

Types

type Attribute

type Attribute struct {
	Value     string
	Available bool
	Required  bool
}

Attribute describes the availability, and required status for a custom url configuration

type AuthSourceProvider

type AuthSourceProvider struct {
	GothProvider
	// contains filtered or unexported fields
}

AuthSourceProvider provides a provider for an AuthSource. Multiple auth sources could use the same registered GothProvider So each auth source should have its own DisplayName and IconHTML for display. The Name is the GothProvider's name, to help to find the GothProvider to sign in. The DisplayName is the auth source config's name, site admin set it on the admin page, the IconURL can also be set there.

func (*AuthSourceProvider) DisplayName

func (p *AuthSourceProvider) DisplayName() string

func (*AuthSourceProvider) IconHTML

func (p *AuthSourceProvider) IconHTML(size int) template.HTML

func (*AuthSourceProvider) Name