2021-01-16 20:41:39 +00:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
2021-08-07 20:12:22 +00:00
|
|
|
"fmt"
|
2021-01-16 20:41:39 +00:00
|
|
|
"time"
|
|
|
|
|
2021-08-07 20:12:22 +00:00
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
|
2021-01-16 20:41:39 +00:00
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/pkg/apis/options"
|
2021-08-07 20:12:22 +00:00
|
|
|
"goauthentik.io/internal/config"
|
2021-01-16 20:41:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func getCommonOptions() *options.Options {
|
|
|
|
commonOpts := options.NewOptions()
|
|
|
|
commonOpts.Cookie.Name = "authentik_proxy"
|
|
|
|
commonOpts.Cookie.Expire = 24 * time.Hour
|
|
|
|
commonOpts.EmailDomains = []string{"*"}
|
|
|
|
commonOpts.ProviderType = "oidc"
|
|
|
|
commonOpts.ProxyPrefix = "/akprox"
|
|
|
|
commonOpts.Logging.SilencePing = true
|
|
|
|
commonOpts.SetAuthorization = false
|
|
|
|
commonOpts.Scope = "openid email profile ak_proxy"
|
2021-08-07 20:12:22 +00:00
|
|
|
if config.G.Redis.Host != "" {
|
|
|
|
protocol := "redis"
|
|
|
|
if config.G.Redis.TLS {
|
|
|
|
protocol = "rediss"
|
|
|
|
}
|
|
|
|
url := fmt.Sprintf("%s://@%s:%d/%d", protocol, config.G.Redis.Host, config.G.Redis.Port, config.G.Redis.OutpostSessionDB)
|
|
|
|
log.WithField("url", url).Info("Using redis session backend")
|
|
|
|
commonOpts.Session.Redis = options.RedisStoreOptions{
|
|
|
|
ConnectionURL: url,
|
|
|
|
Password: config.G.Redis.Password,
|
|
|
|
}
|
|
|
|
if config.G.Redis.TLSReqs != "" {
|
|
|
|
commonOpts.Session.Redis.InsecureSkipTLSVerify = true
|
|
|
|
}
|
|
|
|
}
|
2021-01-16 20:41:39 +00:00
|
|
|
return commonOpts
|
|
|
|
}
|