config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizedHttpRequest

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

AuthorizedHttpRequest is an object combining a HttpMatcher and a HttpPolicy.

An AuthorizedHttpRequest is constructed from an AuthorizedHttpRequestConfigurer which

func (*AuthorizedHttpRequest) Matcher

func (this *AuthorizedHttpRequest) Matcher() *HttpMatcher

Matcher() returns the configured HttpMatcher

func (*AuthorizedHttpRequest) Policy

func (this *AuthorizedHttpRequest) Policy() *HttpPolicy

Policy() returns the configured [httpPolicy]

type AuthorizedHttpRequestConfigurer

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

AuthorizedHttpRequestConfigurer is a builder for AuthorizedHttpRequest used by HttpSecurityBuilder.

func (*AuthorizedHttpRequestConfigurer) And

And() returns to HttpSecurityBuilder.

func (*AuthorizedHttpRequestConfigurer) Method

Method() add a matchig rule for this particular HttpMethod.

func (*AuthorizedHttpRequestConfigurer) MethodAndPaths

func (this *AuthorizedHttpRequestConfigurer) MethodAndPaths(method HttpMethod, path string, paths ...string) *HttpPolicyConfigurer[*AuthorizedHttpRequestConfigurer]

MethodAndPaths() add a matching rule for this particular HttpMethod and the provided paths.

func (*AuthorizedHttpRequestConfigurer) Paths

Paths() add a matching rule for the provided paths.

type CsrfConfigurer

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

CsrfConfigurer is an object used to disable CSRF.

func (*CsrfConfigurer) Disable

func (this *CsrfConfigurer) Disable() *HttpSecurityBuilder

Disable() will disable the CSRF and return to HttpSecurityBuilder

type CsrfEnabler

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

CsrfEnabler is an object noting if CSRF should be disabled.

func (*CsrfEnabler) Disabled

func (this *CsrfEnabler) Disabled() bool

type FormLogin

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

func (*FormLogin) DefaultSuccessURL

func (this *FormLogin) DefaultSuccessURL() string

DefaultSuccessURL() returns the defaults URL to redirect to if no alternative can be found upon successful login.

NOTE: the last visited URL requiring an authentication and redirected to the login form, will be save in the session, and be used if found.

Defaults to "/".

func (*FormLogin) LoginPath

func (this *FormLogin) LoginPath() string

LoginPath() returns the login path this FormLogin will register the login hook.

Defaults to "/login".

func (*FormLogin) LogoutPath

func (this *FormLogin) LogoutPath() string

LogoutPath() returns the logout path this FormLogin will register the logout hook.

Defaults to "/logout".

func (*FormLogin) Password

func (this *FormLogin) Password() string

Password() returns the HTML form field name or this FormLogin that provide the user's password.

Defaults to "password".

func (*FormLogin) Username

func (this *FormLogin) Username() string

Username() returns the HTML form field name for this FormLogin that provide the user's username.

Defaults to "username".

func (*FormLogin) ViewName

func (this *FormLogin) ViewName() string

ViewName() returns the configured view name that will be rendered to provide the login form.

Defaults to "login".

type FormLoginConfigurer

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

FormLoginConfigurer lets you configure a FormLogin object in a HttpSecurityBuilder.

func (*FormLoginConfigurer) And

And() lets you return to HttpSecurityBuilder.

func (*FormLoginConfigurer) DefaultSuccessUrl

func (this *FormLoginConfigurer) DefaultSuccessUrl(defaultSuccessUrl string) *FormLoginConfigurer

DefaultSuccessUrl() lets you configure [FormLogin.DefaultSuccessUrl].

func (*FormLoginConfigurer) LoginPath

func (this *FormLoginConfigurer) LoginPath(loginPath string) *FormLoginConfigurer

LoginPath() lets you configure FormLogin.LoginPath.

func (*FormLoginConfigurer) LogoutPath

func (this *FormLoginConfigurer) LogoutPath(logoutPath string) *FormLoginConfigurer

LogoutPath() lets you configure FormLogin.LogoutPath.

func (*FormLoginConfigurer) Password

func (this *FormLoginConfigurer) Password(password string) *FormLoginConfigurer

Password() lets you configure FormLogin.Password.

func (*FormLoginConfigurer) Username

func (this *FormLoginConfigurer) Username(username string) *FormLoginConfigurer

Username() lets you configure FormLogin.Username.

func (*FormLoginConfigurer) ViewName

func (this *FormLoginConfigurer) ViewName(viewName string) *FormLoginConfigurer

ViewName() lets you configure FormLogin.ViewName.

type HttpMatcher

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

HttpMatcher provides additional function around a HttpMatcherEnum

func (*HttpMatcher) Match

func (this *HttpMatcher) Match(method, path string) bool

Match will return true if this HttpMatcher match the provided method and path.

func (*HttpMatcher) String

func (this *HttpMatcher) String() string

String() returns a visual representation of this HttpMatcher rule.

type HttpMatcherEnum

type HttpMatcherEnum struct {
	PATHS,
	METHOD,
	METHOD_AND_PATHS Enum[HttpMatcherEnum]
}

HttpMatcherEnum is an Enum type to match path request.

type HttpPolicy

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

func (*HttpPolicy) Allow

func (this *HttpPolicy) Allow(authentication Authentication) bool

func (*HttpPolicy) String

func (this *HttpPolicy) String() string

type HttpPolicyConfigurer

type HttpPolicyConfigurer[S any] struct {
	// contains filtered or unexported fields
}

HttpPolicyConfigurer is a generic type used to set the HttpPolicy on another object of type S.

func (*HttpPolicyConfigurer[S]) Anonymous

func (this *HttpPolicyConfigurer[S]) Anonymous() S

Anonymous() configure the HttpPolicy to permit access only to anonymous users.

func (*HttpPolicyConfigurer[S]) Authenticated

func (this *HttpPolicyConfigurer[S]) Authenticated() S

Authenticated() configure the HttpPolicy to permit access only to authenticated users.

func (*HttpPolicyConfigurer[S]) DenyAll

func (this *HttpPolicyConfigurer[S]) DenyAll() S

DenyAll() configure the HttpPolicy to deny all access.

func (*HttpPolicyConfigurer[S]) HasAnyAuthority

func (this *HttpPolicyConfigurer[S]) HasAnyAuthority(authorities []string) S

HasAnyAuthority() configure the HttpPolicy to permit access only to the provided authorities.

NOTE: An authority is for example "ROLE_USER".

func (*HttpPolicyConfigurer[S]) HasAnyRole

func (this *HttpPolicyConfigurer[S]) HasAnyRole(roles []string) S

HasAnyRole() configure the HttpPolicy to permit access only to the provided roles.

WARNING: A role is for example "USER". Internally it will be converted to an authority of "ROLE_USER".

func (*HttpPolicyConfigurer[S]) HasAuthority

func (this *HttpPolicyConfigurer[S]) HasAuthority(authority string) S

HasAuthority() configure the HttpPolicy to permit access only to te provided authority.

An authority is for example "ROLE_USER".

func (*HttpPolicyConfigurer[S]) HasRole

func (this *HttpPolicyConfigurer[S]) HasRole(role string) S

HasRole() configure the HttpPolicy to permit access only to the provided role.

WARNING: A role is for example "USER". Internally it will be converted to an authority of "ROLE_USER".

func (*HttpPolicyConfigurer[S]) PermitAll

func (this *HttpPolicyConfigurer[S]) PermitAll() S

PermitAll() configure the HttpPolicy to permit all access.

type HttpPolicyEnum

type HttpPolicyEnum struct {
	PERMIT_ALL,
	DENY_ALL,
	HAS_AUTHORITY,
	HAS_ANY_AUTHORITY,
	ANONYMOUS,
	AUTHENTICATED Enum[HttpPolicyEnum]
}

type HttpSecurity

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

HttpSecurity is the main object configuration to create in order to activate Web Security.

It has to be created using HttpSecurityBuilder, and be registered as a Beam through a github.com/BeamFoundry/rays-web-security/pkg/core.Configuration.

NOTE: More than one HttpSecurity object may be registered for the same [Server], with at most one without any path AntMatchers.

func (*HttpSecurity) AuthorizedHTTPRequests

func (this *HttpSecurity) AuthorizedHTTPRequests() []*AuthorizedHttpRequest

AuthorizedHTTPRequests() returns a slice of configured AuthorizedHttpRequest.

func (*HttpSecurity) Basic

func (this *HttpSecurity) Basic() bool

Basic() returns whether BasicAuth has been activated.

func (*HttpSecurity) Csrf

func (this *HttpSecurity) Csrf() *CsrfEnabler

Csrf() rerturns the CsrfEnabler object, if configured.

func (*HttpSecurity) DefaultHTTPPolicy

func (this *HttpSecurity) DefaultHTTPPolicy() *HttpPolicy

DefaultHTTPPolicy() return the default HttpPolicy

func (*HttpSecurity) Filters

func (this *HttpSecurity) Filters() []SecurityFilter

Filters() returns the configured [SecurityFilter].

This includes first the ones configured via HttpSecurityBuilder, and globol ones for FormLogin or BasicAuth which will be included automatically.

func (*HttpSecurity) FormLogin

func (this *HttpSecurity) FormLogin() *FormLogin

FormLogin() return the FormLogin object, if configured.

func (*HttpSecurity) Matchers

func (this *HttpSecurity) Matchers() []*AntMatcher

Matchers() returns a slice of AntMatcher, corresponding

func (*HttpSecurity) PostConstruct

func (this *HttpSecurity) PostConstruct() Error

PostConstruct() implements [BeamPostConstruct]

func (*HttpSecurity) RememberMeService

func (this *HttpSecurity) RememberMeService() Optional[RememberMeService]

RememberMeService() returns an optionally configured [RememberMeService].

WARNING: [RememberMeService] should always be first registered as beams, before being added in the HttpSecurityBuilder.

func (*HttpSecurity) SessionCreationPolicy

func (this *HttpSecurity) SessionCreationPolicy() SessionCreationPolicy

SessionCreationPolicy() returns the SessionCreationPolicy configured.

type HttpSecurityBuilder

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

HttpSecurityBuilder is a builder for [httpSecurity]

func (*HttpSecurityBuilder) AddCustomFilter

func (this *HttpSecurityBuilder) AddCustomFilter(filter SecurityFilter) *HttpSecurityBuilder

AddCustomFilter() lets you add a custom [SecurityFilter] that will be evaluated by the [SecurityFilterChain]. They will be evaluated before global ones like for BasicAuth or FormLogin.

func (*HttpSecurityBuilder) AnyRequest

AnyRequest() lets you configure the default HttpPolicy if no [AuthorizedHTTPRequests] match?

func (*HttpSecurityBuilder) AuthorizedHTTPRequests

func (this *HttpSecurityBuilder) AuthorizedHTTPRequests() *AuthorizedHttpRequestConfigurer

AuthorizedHTTPRequests() let you access the AuthorizedHttpRequestConfigurer, to add rules of access authorization.

func (*HttpSecurityBuilder) Basic

Basic() enabled BasicAuth.

WARNING: This needs a [UserDetailsService] to be defined.

func (*HttpSecurityBuilder) Build

func (this *HttpSecurityBuilder) Build() *HttpSecurity

Build() builds and return a new httpSecurity.

func (*HttpSecurityBuilder) Csrf

func (this *HttpSecurityBuilder) Csrf() *CsrfConfigurer

Csrf() lets yoy disable the CSRF.

func (*HttpSecurityBuilder) FormLogin

func (this *HttpSecurityBuilder) FormLogin() *FormLoginConfigurer

FormLogin() enable and lets you configure the FormLogin process.

WARNING: This needs a [UserDetailsService] to be defined.

func (*HttpSecurityBuilder) Match

func (this *HttpSecurityBuilder) Match(path string, paths ...string) *HttpSecurityBuilder

Match() lets you restrict this HttpSecurity to certains paths.

NOTE: More than one HttpSecurity object may be registered for the same [Server], with at most one without any path AntMatchers.

func (*HttpSecurityBuilder) RememberMe

func (this *HttpSecurityBuilder) RememberMe(rememberme RememberMeService) *HttpSecurityBuilder

WARNING: [RememberMeService] should always be first registered as beams, before being added in the HttpSecurityBuilder.

func (*HttpSecurityBuilder) SessionCreationPolicy

func (this *HttpSecurityBuilder) SessionCreationPolicy() *SessionCreationPolicyConfigurer

SessionCreationPolicy() lets you change the Session creation policy.

type SessionCreationPolicy

type SessionCreationPolicy = Enum[SessionCreationPolicyEnum]

SessionCreationPolicy is an Enum alias for SessionCreationPolicyEnum.

type SessionCreationPolicyConfigurer

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

SessionCreationPolicyConfigurer lets you configure the SessionCreationPolicy in an HttpSecurityBuilder.

func (*SessionCreationPolicyConfigurer) Always

Always() configure the HttpSecurityBuilder with the SessionCreationPolicyEnum.ALWAYS.

In this mode Rays will always create a Session.

func (*SessionCreationPolicyConfigurer) Default

Default() configure the HttpSecurityBuilder with the default SessionCreationPolicy

Default : SessionCreationPolicyEnum.IF_REQUIRED.

func (*SessionCreationPolicyConfigurer) IfRequired

IfRequired() configure the HttpSecurityBuilder with the SessionCreationPolicyEnum.IF_REQUIRED.

In this mode Rays will create a Session only if required.

func (*SessionCreationPolicyConfigurer) Never

Never() configure the HttpSecurityBuilder with the SessionCreationPolicyEnum.NEVER.

In this mode Rays will never create a Session but will use one if it already exists.

func (*SessionCreationPolicyConfigurer) Stateless

Stateless() configure the HttpSecurityBuilder with the SessionCreationPolicyEnum.STATELESS.

In this mode Rays will not configure a Session.

type SessionCreationPolicyEnum

type SessionCreationPolicyEnum struct {
	IF_REQUIRED,
	ALWAYS,
	NEVER,
	STATELESS SessionCreationPolicy
}

SessionCreationPolicyEnum is an Enum type representing a SessionCreationPolicy.

Jump to

Keyboard shortcuts

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