2019-05-06 13:33:33 +00: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"
|
2019-05-09 23:09:22 +00:00
|
|
|
"github.com/pusher/oauth2_proxy/pkg/sessions/redis"
|
2019-05-06 13:33:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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-15 15:56:05 +00:00
|
|
|
return cookie.NewCookieSessionStore(opts, cookieOpts)
|
2019-05-09 23:09:22 +00:00
|
|
|
case options.RedisSessionStoreType:
|
2019-05-15 16:06:05 +00:00
|
|
|
return redis.NewRedisSessionStore(opts, cookieOpts)
|
2019-05-06 13:33:33 +00:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unknown session store type '%s'", opts.Type)
|
|
|
|
}
|
|
|
|
}
|