Documentation
¶
Index ¶
Constants ¶
const (
SessionKey = sessionKeyType("session")
)
Variables ¶
var ErrNotEncoded = errors.New("token is not encoded with suffix")
ErrNotEncoded acts similarly to EOF - it does indicate there is no suffix in the token, but that does not have to be treated as the error in some cases. If token is not base64-encoded, the token is returned as a key alongside with the error.
Functions ¶
func AuthPack ¶ added in v0.17.0
func AuthPack(prefix AuthPrefix, id, key string) string
Types ¶
type AuthNMiddleware ¶ added in v0.18.1
type AuthNMiddleware interface {
Authentication
WithOptions(options ...MiddlewareOption) AuthNMiddleware
Middleware() func(http.Handler) http.Handler
}
AuthNMiddleware defines the interface for authenticated services with middleware.
func NewAuthNMiddleware ¶ added in v0.18.1
func NewAuthNMiddleware(authnSvc Authentication, options ...MiddlewareOption) AuthNMiddleware
NewAuthNMiddleware creates a new authenticated service with middleware support. The order of precedence for options is as follows, with later options overriding earlier ones: 1. Default options (lowest precedence). 2. Options from environment variables (e.g., SMQ_ALLOW_UNVERIFIED_USER). 3. Options passed as arguments to this function (highest precedence).
For example, consider the 'allowUnverifiedUser' option:
- By default, it is 'false'.
- If the SMQ_ALLOW_UNVERIFIED_USER environment variable is set to "true", it becomes 'true'.
- If NewAuthNMiddleware is called with WithAllowUnverifiedUser(false), it will be 'false', regardless of the environment variable, as function arguments have the highest precedence.
type AuthPrefix ¶ added in v0.17.0
type AuthPrefix int
const ( Unknown AuthPrefix = iota BasicAuth DomainAuth )
func AuthUnpack ¶ added in v0.17.0
func AuthUnpack(token string) (AuthPrefix, string, string, error)
func (AuthPrefix) String ¶ added in v0.17.0
func (a AuthPrefix) String() string
String returns the string representation (e.g., "Basic") of the AuthPrefix.
type Authentication ¶
Authn is supermq authentication library.
type MiddlewareOption ¶ added in v0.18.1
type MiddlewareOption func(*middlewareOptions)
MiddlewareOption is a function that modifies middleware options.
func WithAllowUnverifiedUser ¶ added in v0.18.1
func WithAllowUnverifiedUser(allowed bool) MiddlewareOption
WithAllowUnverifiedUser sets whether unverified users are allowed.
func WithDefaultMiddlewareOptions ¶ added in v0.18.1
func WithDefaultMiddlewareOptions() MiddlewareOption
WithDefaultMiddlewareOptions resets options to default values.
func WithDomainCheck ¶ added in v0.18.1
func WithDomainCheck(enabled bool) MiddlewareOption
WithDomainCheck sets whether domain checking is enabled.