models

package
v1.117.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathRegex = "(?i)^((/[^/\\*]*)*)(/((\\*){1,2}))?$"
)

Variables

This section is empty.

Functions

func GenerateCodeChallenge added in v1.111.0

func GenerateCodeChallenge(verifier string) string

func GenerateCodeVerifier added in v1.111.0

func GenerateCodeVerifier() string

func GenerateState added in v1.111.0

func GenerateState() string

Types

type AggregateEndpoint

type AggregateEndpoint struct {
	Url        string `json:"url" yaml:"url" cloud:"url"`
	Identifier string `json:"identifier" yaml:"identifier" cloud:"identifier"`
}

type AggregateEndpoints

type AggregateEndpoints []AggregateEndpoint

type AggregateRoute

type AggregateRoute struct {
	// Name of your aggregate
	Name string `json:"name" yaml:"name" cloud:"name"`
	// Includes path for making aggregation
	// You can use globs:
	//   - appending /* will only make requests available in first level to aggregate
	//   - appending /** will mark everything to aggregate
	// e.g.: /app/**
	Includes PathMatchers `json:"includes" yaml:"includes" cloud:"includes"`
	// Excludes Same pattern has Includes but for excludes this time
	Excludes PathMatchers `json:"excludes" yaml:"excludes" cloud:"excludes"`
	// AllowedMethods Allowed method for aggregating, by default only GET is accepted
	AllowedMethods []string
	// Upstream URL where all request will be redirected
	// Query parameters can be passed, e.g.: http://localhost?param=1
	// User and password are given as basic auth too (this is not recommended to use it), e.g.: http://user:password@localhost
	Upstream *Upstream `json:"upstream" yaml:"upstream" cloud:"upstream"`
	// NoBuffer By default, response from upstream are buffered, it can be issue when sending big files
	// Set to true to stream response
	NoBuffer bool `json:"no_buffer" yaml:"no_buffer" cloud:"no_buffer"`
	// InsecureSkipVerify Set to true to not check SSL certificates from upstream (not really recommended)
	InsecureSkipVerify bool `json:"insecure_skip_verify" yaml:"insecure_skip_verify" cloud:"insecure_skip_verify"`
	// OptionsPassthrough Will forward directly to proxied route OPTIONS method without using middlewares
	OptionsPassthrough bool `json:"options_passthrough" yaml:"options_passthrough" cloud:"options_passthrough"`
	// Hosts Must match host
	Hosts HostMatchers `json:"hosts" yaml:"hosts" cloud:"hosts"`
	// Auth
	Auth Auth `json:"auth" yaml:"auth" cloud:"auth"`
	// Path
	Path string `json:"path" yaml:"path" cloud:"path"`
	// AggregateEndpoints endpoints
	AggregateEndpoints AggregateEndpoints `json:"aggregate_endpoints" yaml:"aggregate_endpoints" cloud:"aggregate_endpoints"`
	Identifier         string             `json:"identifier" yaml:"identifier" cloud:"identifier"`
}

func NewAggregateRoute

func NewAggregateRoute(
	name string,
	identifier string,
	upstream *Upstream,
	aggrEndpoints AggregateEndpoints,
	auth Auth,
	includes, excludes PathMatchers,
) (*AggregateRoute, error)

func NewAggregateRouteWithHandler

func NewAggregateRouteWithHandler(
	name string,
	identifier string,
	handler http.Handler,
	aggrEndpoints AggregateEndpoints,
	auth Auth,
	includes, excludes PathMatchers,
) (*AggregateRoute, error)

func (*AggregateRoute) Check

func (r *AggregateRoute) Check() error

func (*AggregateRoute) InjectByEndpoint

func (r *AggregateRoute) InjectByEndpoint(req *http.Request, endpoint AggregateEndpoint)

func (*AggregateRoute) InjectForwardUrl

func (r *AggregateRoute) InjectForwardUrl(req *http.Request)

func (*AggregateRoute) IsMethodAllowedMethod added in v1.1.0

func (r *AggregateRoute) IsMethodAllowedMethod(req *http.Request) bool

func (*AggregateRoute) Load

func (r *AggregateRoute) Load() error

func (*AggregateRoute) MatchAuth

func (r *AggregateRoute) MatchAuth(req *http.Request) bool

func (*AggregateRoute) MatchInclude

func (r *AggregateRoute) MatchInclude(req *http.Request) bool

func (*AggregateRoute) UnmarshalYAML

func (r *AggregateRoute) UnmarshalYAML(unmarshal func(interface{}) error) error

type Auth

type Auth struct {
	// Includes Where to do Auth
	Includes PathMatchers `json:"includes" yaml:"includes" cloud:"includes"`
	// Excludes Where not to do Auth
	Excludes PathMatchers `json:"excludes" yaml:"excludes" cloud:"excludes"`
	// Oauth2 auth
	Oauth2Auth            *Oauth2Auth `json:"oauth2" yaml:"oauth2" cloud:"oauth2"`
	OIDCAuth              *OIDCAuth   `json:"oidc" yaml:"oidc" cloud:"oidc"`
	BasicAuth             *BasicAuth  `json:"basic_auth" yaml:"basic" cloud:"basic_auth"`
	JWTCheck              JWTChecks   `json:"jwt_checks" yaml:"jwt_checks" cloud:"jwt_checks"`
	LoginPageTemplate     string      `json:"login_page_template" yaml:"login_page_template" cloud:"login_page_template"`
	LoginPageTemplatePath string      `json:"login_page_template_path" yaml:"login_page_template_path" cloud:"login_page_template_path"`
}

func NewAuthWithOauth2

func NewAuthWithOauth2(
	oauth2Auth *Oauth2Auth,
	oidcAuth *OIDCAuth,
	jwtChecks JWTChecks,
	includes, excludes PathMatchers,
) Auth

func (Auth) MakeLoginPageTemplate

func (a Auth) MakeLoginPageTemplate(defaultTemplate string) (string, error)

func (Auth) Match

func (a Auth) Match(path string) bool

type BasicAuth

type BasicAuth struct {
	Username string   `json:"username" yaml:"username" cloud:"username"`
	Password string   `json:"password" yaml:"password" cloud:"password"`
	Scopes   []string `json:"scope" yaml:"scope" cloud:"scope"`
}

type CtxUpstream

type CtxUpstream int
const (
	IsHandlerContextUpstream CtxUpstream = iota
)

type HostMatcher

type HostMatcher struct {
	glob.Glob
	// contains filtered or unexported fields
}

func NewHostMatcher

func NewHostMatcher(hostOrWildcard string) *HostMatcher

func (*HostMatcher) Load

func (re *HostMatcher) Load(s string) error

func (HostMatcher) String

func (re HostMatcher) String() string

func (*HostMatcher) UnmarshalCloud

func (re *HostMatcher) UnmarshalCloud(data interface{}) error

func (*HostMatcher) UnmarshalJSON

func (re *HostMatcher) UnmarshalJSON(b []byte) error

func (*HostMatcher) UnmarshalYAML

func (re *HostMatcher) UnmarshalYAML(unmarshal func(interface{}) error) error

type HostMatchers

type HostMatchers []*HostMatcher

func (HostMatchers) Match

func (m HostMatchers) Match(s string) bool

type JWTCheck

type JWTCheck struct {
	// Alg Algorithm to use to validate the token
	// This is mandatory due to a security issue (see: https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries)
	Alg string `json:"alg" yaml:"alg" cloud:"alg"`
	// Secret or private key to verify the jwt
	// This is required
	Secret string `json:"secret" yaml:"secret" cloud:"secret"`
	// Issuer It will validate that the jwt contains this issuer
	Issuer string `json:"issuer" yaml:"issuer" cloud:"issuer"`
	// NotVerifyIssuedAt Set to true to not verify issued at of token (Useful when you have different time between user and server)
	NotVerifyIssuedAt bool `json:"not_verify_issued_at" yaml:"not_verify_expire" cloud:"not_verify_issued_at"`
}

type JWTChecks

type JWTChecks []JWTCheck

func (JWTChecks) FindJWTCheckByIssuer

func (es JWTChecks) FindJWTCheckByIssuer(issuer string) (JWTCheck, error)

type OIDCAuth added in v1.111.0

type OIDCAuth struct {
	ClientID     string   `json:"client_id" yaml:"client_id" cloud:"client_id"`
	ClientSecret string   `json:"client_secret" yaml:"client_secret" cloud:"client_secret"`
	Issuer       string   `json:"issuer" yaml:"issuer" cloud:"issuer"`
	Scopes       []string `json:"scopes" yaml:"scopes" cloud:"scopes"`
	RedirectURI  string   `json:"redirect_uri" yaml:"redirect_uri" cloud:"redirect_uri"`
	Endpoint     string   `json:"endpoint" yaml:"endpoint" cloud:"endpoint"`
	AuthPath     string   `json:"auth_path" yaml:"auth_path" cloud:"auth_path"`
	CallbackPath string   `json:"callback_path" yaml:"callback_path" cloud:"callback_path"`
}

type OIDCIdToken added in v1.111.0

type OIDCIdToken struct {
	Email         string `json:"email"`
	FamilyName    string `json:"family_name"`
	GivenName     string `json:"given_name"`
	PreferredName string `json:"preferred_username"`
	Name          string `json:"name"`
	EmailVerified bool   `json:"email_verified"`
	Sub           string `json:"sub"`
	Type          string `json:"typ"`
}

type Oauth2Auth

type Oauth2Auth struct {
	TokenURL     string   `json:"token_url" yaml:"token_url" cloud:"token_url"`
	ClientID     string   `json:"client_id" yaml:"client_id" cloud:"client_id"`
	ClientSecret string   `json:"client_secret" yaml:"client_secret" cloud:"client_secret"`
	ParamsAsJson bool     `json:"params_as_json" yaml:"params_as_json" cloud:"params_as_json"`
	TokenFormat  string   `json:"token_format" yaml:"token_format" cloud:"token_format"`
	Scopes       []string `json:"scopes" yaml:"scopes" cloud:"scopes"`
}

func NewOauth2Auth

func NewOauth2Auth(
	tokenURL string,
	clientID string,
	clientSecret string,
	scopes []string,
) *Oauth2Auth

func (*Oauth2Auth) Load

func (c *Oauth2Auth) Load() error

func (*Oauth2Auth) UnmarshalJSON

func (c *Oauth2Auth) UnmarshalJSON(b []byte) error

func (*Oauth2Auth) UnmarshalYAML

func (c *Oauth2Auth) UnmarshalYAML(unmarshal func(interface{}) error) error

type PathMatcher

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

func NewPathMatcher

func NewPathMatcher(path string) *PathMatcher

func (PathMatcher) AppPath

func (re PathMatcher) AppPath() string

func (PathMatcher) CreateRoutePath

func (re PathMatcher) CreateRoutePath(finalPath string) string

func (*PathMatcher) Load

func (re *PathMatcher) Load(s string) error

func (PathMatcher) Match

func (re PathMatcher) Match(path string) bool

func (PathMatcher) String

func (re PathMatcher) String() string

func (*PathMatcher) UnmarshalCloud

func (re *PathMatcher) UnmarshalCloud(data interface{}) error

func (*PathMatcher) UnmarshalJSON

func (re *PathMatcher) UnmarshalJSON(b []byte) error

func (*PathMatcher) UnmarshalYAML

func (re *PathMatcher) UnmarshalYAML(unmarshal func(interface{}) error) error

type PathMatchers

type PathMatchers []*PathMatcher

func (PathMatchers) Match

func (res PathMatchers) Match(path string) bool

type Upstream

type Upstream struct {
	URL     *url.URL
	Handler http.Handler
}

func NewUpstreamFromHandler

func NewUpstreamFromHandler(handler http.Handler) *Upstream

func NewUpstreamFromUrl

func NewUpstreamFromUrl(urlRaw string) *Upstream

func (*Upstream) Load

func (r *Upstream) Load(urlRaw string) error

func (*Upstream) UnmarshalCloud

func (r *Upstream) UnmarshalCloud(data interface{}) error

func (*Upstream) UnmarshalJSON

func (r *Upstream) UnmarshalJSON(b []byte) error

func (*Upstream) UnmarshalYAML

func (r *Upstream) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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