auth

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: AGPL-3.0, AGPL-3.0-or-later Imports: 12 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: AGPL-3.0-or-later

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BaseURL       string
	ClientID      string
	ClientSecret  string
	AuthURL       string
	TokenURL      string
	UserInfoURL   string
	LogoutURL     string
	Scopes        []string
	AllowedDomain string
	CookieSecret  []byte
	SecureCookies bool
}

type OauthService

type OauthService struct {
	// contains filtered or unexported fields
}

func NewOAuthService

func NewOAuthService(config Config) *OauthService

func (*OauthService) CreateAuthURL

func (s *OauthService) CreateAuthURL(w http.ResponseWriter, r *http.Request, nextURL string) string

CreateAuthURL Persist a CSRF state token server-side to prevent forged OAuth callbacks; encode nextURL to preserve intended redirect.

func (*OauthService) GetAuthURL

func (s *OauthService) GetAuthURL(nextURL string) string

func (*OauthService) GetLogoutURL added in v1.1.2

func (s *OauthService) GetLogoutURL() string

GetLogoutURL returns the SSO logout URL if configured, otherwise returns empty string

func (*OauthService) GetUser

func (s *OauthService) GetUser(r *http.Request) (*models.User, error)

func (*OauthService) HandleCallback

func (s *OauthService) HandleCallback(ctx context.Context, code, state string) (*models.User, string, error)

func (*OauthService) IsAllowedDomain

func (s *OauthService) IsAllowedDomain(email string) bool

func (*OauthService) Logout

func (s *OauthService) Logout(w http.ResponseWriter, r *http.Request)

func (*OauthService) SetUser

func (s *OauthService) SetUser(w http.ResponseWriter, r *http.Request, user *models.User) error

func (*OauthService) VerifyState

func (s *OauthService) VerifyState(w http.ResponseWriter, r *http.Request, stateToken string) bool

VerifyState Clear single-use state on success to prevent replay; compare in constant time to avoid timing leaks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL