url

package
v0.0.0-...-ab483ee Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RedirectQueryParameter = "redirect"
)

Variables

View Source
var ErrNoMatchingIngress = errors.New("request host does not match any configured ingresses")

Functions

func Login

func Login(target *url.URL, redirect string) string

Login constructs a URL string that points to the login path for the given target URL. The given redirect string should point to the location to be redirected to after login.

func LoginCallback

func LoginCallback(r *http.Request) (string, error)

func LoginRelative

func LoginRelative(prefix, redirect string) string

LoginRelative constructs the relative URL with an absolute path that points to the application's login path, given an optional path prefix. The given redirect string should point to the location to be redirected to after login.

func Logout

func Logout(target *url.URL, redirect string) string

Logout constructs a URL string that points to the logout path for the given target URL. The given redirect string should point to the location to be redirected to after logout.

func LogoutCallback

func LogoutCallback(r *http.Request) (string, error)

func MatchingIngress

func MatchingIngress(r *http.Request) (*url.URL, error)

func MatchingPath

func MatchingPath(r *http.Request) *url.URL

Types

type AbsoluteValidator

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

func NewAbsoluteValidator

func NewAbsoluteValidator(allowedDomains []string) *AbsoluteValidator

func (*AbsoluteValidator) IsValidRedirect

func (v *AbsoluteValidator) IsValidRedirect(r *http.Request, redirect string) bool

IsValidRedirect validates that the given redirect string is a valid absolute URL. It must use the 'http' or 'https' scheme. It must point to a host that matches the configured list of allowed domains.

type Redirect

type Redirect interface {
	Validator
	// Canonical constructs a redirect URL that points back to the application.
	Canonical(r *http.Request) string
	// Clean parses and cleans a target URL according to implementation-specific validations. It should always return a fallback URL string, regardless of validation errors.
	Clean(r *http.Request, target string) string
}

type RelativeValidator

type RelativeValidator struct{}

func NewRelativeValidator

func NewRelativeValidator() *RelativeValidator

func (*RelativeValidator) IsValidRedirect

func (v *RelativeValidator) IsValidRedirect(r *http.Request, redirect string) bool

IsValidRedirect validates that the given redirect string is a valid relative URL. It must be an absolute path (i.e. has a leading '/').

type SSOProxyRedirect

type SSOProxyRedirect struct {
	Validator
	// contains filtered or unexported fields
}

func NewSSOProxyRedirect

func NewSSOProxyRedirect(ingresses *ingress.Ingresses) *SSOProxyRedirect

func (*SSOProxyRedirect) Canonical

func (h *SSOProxyRedirect) Canonical(r *http.Request) string

func (*SSOProxyRedirect) Clean

func (h *SSOProxyRedirect) Clean(r *http.Request, target string) string

type SSOServerRedirect

type SSOServerRedirect struct {
	Validator
	// contains filtered or unexported fields
}

func NewSSOServerRedirect

func NewSSOServerRedirect(config *config.Config) (*SSOServerRedirect, error)

func (*SSOServerRedirect) Canonical

func (h *SSOServerRedirect) Canonical(r *http.Request) string

func (*SSOServerRedirect) Clean

func (h *SSOServerRedirect) Clean(r *http.Request, target string) string

type StandaloneRedirect

type StandaloneRedirect struct {
	Validator
}

func NewStandaloneRedirect

func NewStandaloneRedirect() *StandaloneRedirect

func (*StandaloneRedirect) Canonical

func (h *StandaloneRedirect) Canonical(r *http.Request) string

func (*StandaloneRedirect) Clean

func (h *StandaloneRedirect) Clean(r *http.Request, target string) string

type Validator

type Validator interface {
	IsValidRedirect(r *http.Request, redirect string) bool
}

Jump to

Keyboard shortcuts

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