feat: new openid connect authentication layer
Some checks are pending
Cadoles/bouncer/pipeline/pr-develop Build started...
Some checks are pending
Cadoles/bouncer/pipeline/pr-develop Build started...
This commit is contained in:
47
internal/session/options.go
Normal file
47
internal/session/options.go
Normal file
@ -0,0 +1,47 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Session sessions.Options
|
||||
KeyPrefix string
|
||||
}
|
||||
|
||||
type OptionFunc func(opts *Options)
|
||||
|
||||
func NewOptions(funcs ...OptionFunc) *Options {
|
||||
opts := &Options{
|
||||
Session: sessions.Options{
|
||||
Path: "/",
|
||||
Domain: "",
|
||||
MaxAge: int(time.Hour.Seconds()),
|
||||
HttpOnly: true,
|
||||
Secure: false,
|
||||
SameSite: http.SameSiteDefaultMode,
|
||||
},
|
||||
KeyPrefix: "session:",
|
||||
}
|
||||
|
||||
for _, fn := range funcs {
|
||||
fn(opts)
|
||||
}
|
||||
|
||||
return opts
|
||||
}
|
||||
|
||||
func WithSessionOptions(options sessions.Options) OptionFunc {
|
||||
return func(opts *Options) {
|
||||
opts.Session = options
|
||||
}
|
||||
}
|
||||
|
||||
func WithKeyPrefix(prefix string) OptionFunc {
|
||||
return func(opts *Options) {
|
||||
opts.KeyPrefix = prefix
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user