2019-05-06 15:33:33 +02:00
|
|
|
package sessions
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-09-29 18:44:42 +02:00
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
|
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/sessions"
|
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/sessions/cookie"
|
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/sessions/redis"
|
2019-05-06 15:33:33 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewSessionStore creates a SessionStore from the provided configuration
|
2020-05-25 13:43:24 +02:00
|
|
|
func NewSessionStore(opts *options.SessionOptions, cookieOpts *options.Cookie) (sessions.SessionStore, error) {
|
2019-05-06 15:33:33 +02:00
|
|
|
switch opts.Type {
|
|
|
|
case options.CookieSessionStoreType:
|
2019-05-15 17:56:05 +02:00
|
|
|
return cookie.NewCookieSessionStore(opts, cookieOpts)
|
2019-05-10 01:09:22 +02:00
|
|
|
case options.RedisSessionStoreType:
|
2019-05-15 18:06:05 +02:00
|
|
|
return redis.NewRedisSessionStore(opts, cookieOpts)
|
2019-05-06 15:33:33 +02:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unknown session store type '%s'", opts.Type)
|
|
|
|
}
|
|
|
|
}
|