mirror of
https://github.com/glauth/glauth.git
synced 2026-10-24 21:23:11 +00:00
2eb2215ae4
This commit actually covers a few items. In future commits, I will keep features distinct. This is only happening this time around due to how long it took to merge this branch. Covered: - Database plugins (at this time: SQLite, MySQL, Postgres) - Backends acting as middleware: added the [[Backends]] configuration directive while retaining backward compatibility with [Backend] - Schema introspection (root DSE query with base scope) - When proxying, insert queried attribute back in upstream response, if absent, so that the LDAP library does not filter out all entries - When chaining backends, any backend can be used to inject OTP value in password, before reaching a non-OTP-aware backend (currently guarded by a True statement in case we find an issue (I did thoroughly test but you never know)) - Handling of special "1.1" attributes filter meaning "I do not want attributes" (RFC 4511, 4.5.1.8) - Support for "want types only" queries, even when proxying
95 lines
1.8 KiB
Go
95 lines
1.8 KiB
Go
package handler
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/GeertJohan/yubigo"
|
|
"github.com/glauth/glauth/pkg/config"
|
|
"github.com/go-logr/logr"
|
|
)
|
|
|
|
// Option defines a single option function.
|
|
type Option func(o *Options)
|
|
|
|
// Options defines the available options for this package.
|
|
type Options struct {
|
|
Backend config.Backend
|
|
Handlers HandlerWrapper
|
|
Logger logr.Logger
|
|
Config *config.Config
|
|
Context *context.Context
|
|
YubiAuth *yubigo.YubiAuth
|
|
Helper Handler
|
|
}
|
|
|
|
// newOptions initializes the available default options.
|
|
func newOptions(opts ...Option) Options {
|
|
opt := Options{}
|
|
|
|
for _, o := range opts {
|
|
o(&opt)
|
|
}
|
|
|
|
return opt
|
|
}
|
|
|
|
// newOptions initializes the available default options.
|
|
func NewOptions(opts ...Option) Options {
|
|
opt := Options{}
|
|
|
|
for _, o := range opts {
|
|
o(&opt)
|
|
}
|
|
|
|
return opt
|
|
}
|
|
|
|
// Backend is our current backend
|
|
func Backend(val config.Backend) Option {
|
|
return func(o *Options) {
|
|
o.Backend = val
|
|
}
|
|
}
|
|
|
|
// Our friendly handlers for all backends
|
|
func Handlers(val HandlerWrapper) Option {
|
|
return func(o *Options) {
|
|
o.Handlers = val
|
|
}
|
|
}
|
|
|
|
// Logger provides a function to set the logger option.
|
|
func Logger(val logr.Logger) Option {
|
|
return func(o *Options) {
|
|
o.Logger = val
|
|
}
|
|
}
|
|
|
|
// Config provides a function to set the config option.
|
|
func Config(val *config.Config) Option {
|
|
return func(o *Options) {
|
|
o.Config = val
|
|
}
|
|
}
|
|
|
|
// Context provides a function to set the context option.
|
|
func Context(val *context.Context) Option {
|
|
return func(o *Options) {
|
|
o.Context = val
|
|
}
|
|
}
|
|
|
|
// YubiAuth provides a function to set the yubiauth option.
|
|
func YubiAuth(val *yubigo.YubiAuth) Option {
|
|
return func(o *Options) {
|
|
o.YubiAuth = val
|
|
}
|
|
}
|
|
|
|
// If we specified a helper, for instance for OTP injection
|
|
func Helper(val Handler) Option {
|
|
return func(o *Options) {
|
|
o.Helper = val
|
|
}
|
|
}
|