2019-05-06 15:33:33 +02:00
|
|
|
package sessions
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/pusher/oauth2_proxy/pkg/apis/options"
|
|
|
|
"github.com/pusher/oauth2_proxy/pkg/apis/sessions"
|
|
|
|
"github.com/pusher/oauth2_proxy/pkg/sessions/cookie"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewSessionStore creates a SessionStore from the provided configuration
|
|
|
|
func NewSessionStore(opts *options.SessionOptions, cookieOpts *options.CookieOptions) (sessions.SessionStore, error) {
|
|
|
|
switch opts.Type {
|
|
|
|
case options.CookieSessionStoreType:
|
2019-05-07 15:27:09 +02:00
|
|
|
// Ensure EnableCipher is propogated from the parent option
|
|
|
|
opts.CookieStoreOptions.EnableCipher = opts.EnableCipher
|
2019-05-06 15:33:33 +02:00
|
|
|
return cookie.NewCookieSessionStore(opts.CookieStoreOptions, cookieOpts)
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unknown session store type '%s'", opts.Type)
|
|
|
|
}
|
|
|
|
}
|