@@ -16,7 +16,7 @@ import (
1616 "github.com/mbland/hmacauth"
1717 "github.com/pusher/oauth2_proxy/cookie"
1818 "github.com/pusher/oauth2_proxy/logger"
19− "github.com/pusher/oauth2_proxy/pkg/apis/sessions"
19+ sessionsapi "github.com/pusher/oauth2_proxy/pkg/apis/sessions"
2020 "github.com/pusher/oauth2_proxy/providers"
2121 "github.com/yhat/wsutil"
2222)
@@ -75,6 +75,7 @@ type OAuthProxy struct {
7575 redirectURL *url.URL // the url to receive requests at
7676 whitelistDomains []string
7777 provider providers.Provider
78+ sessionStore sessionsapi.SessionStore
7879 ProxyPrefix string
7980 SignInMessage string
8081 HtpasswdFile *HtpasswdFile
@@ -249,6 +250,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
249250
250251 ProxyPrefix: opts.ProxyPrefix,
251252 provider: opts.provider,
253+ sessionStore: opts.sessionStore,
252254 serveMux: serveMux,
253255 redirectURL: redirectURL,
254256 whitelistDomains: opts.WhitelistDomains,
@@ -293,7 +295,7 @@ func (p *OAuthProxy) displayCustomLoginForm() bool {
293295 return p.HtpasswdFile != nil && p.DisplayHtpasswdForm
294296}
295297
296−func (p *OAuthProxy) redeemCode(host, code string) (s *sessions.SessionState, err error) {
298+func (p *OAuthProxy) redeemCode(host, code string) (s *sessionsapi.SessionState, err error) {
297299 if code == "" {
298300 return nil, errors.New("missing code")
299301 }
@@ -485,7 +487,7 @@ func (p *OAuthProxy) SetSessionCookie(rw http.ResponseWriter, req *http.Request,
485487}
486488
487489// LoadCookiedSession reads the user's authentication details from the request
488−func (p *OAuthProxy) LoadCookiedSession(req *http.Request) (*sessions.SessionState, time.Duration, error) {
490+func (p *OAuthProxy) LoadCookiedSession(req *http.Request) (*sessionsapi.SessionState, time.Duration, error) {
489491 var age time.Duration
490492 c, err := loadCookie(req, p.CookieName)
491493 if err != nil {
@@ -507,7 +509,7 @@ func (p *OAuthProxy) LoadCookiedSession(req *http.Request) (*sessions.SessionSta
507509}
508510
509511// SaveSession creates a new session cookie value and sets this on the response
510−func (p *OAuthProxy) SaveSession(rw http.ResponseWriter, req *http.Request, s *sessions.SessionState) error {
512+func (p *OAuthProxy) SaveSession(rw http.ResponseWriter, req *http.Request, s *sessionsapi.SessionState) error {
511513 value, err := p.provider.CookieForSession(s, p.CookieCipher)
512514 if err != nil {
513515 return err
@@ -694,7 +696,7 @@ func (p *OAuthProxy) SignIn(rw http.ResponseWriter, req *http.Request) {
694696
695697 user, ok := p.ManualSignIn(rw, req)
696698 if ok {
697− session := &sessions.SessionState{User: user}
699+ session := &sessionsapi.SessionState{User: user}
698700 p.SaveSession(rw, req, session)
699701 http.Redirect(rw, req, redirect, 302)
700702 } else {
@@ -945,7 +947,7 @@ func (p *OAuthProxy) Authenticate(rw http.ResponseWriter, req *http.Request) int
945947
946948// CheckBasicAuth checks the requests Authorization header for basic auth
947949// credentials and authenticates these against the proxies HtpasswdFile
948−func (p *OAuthProxy) CheckBasicAuth(req *http.Request) (*sessions.SessionState, error) {
950+func (p *OAuthProxy) CheckBasicAuth(req *http.Request) (*sessionsapi.SessionState, error) {
949951 if p.HtpasswdFile == nil {
950952 return nil, nil
951953 }
@@ -967,7 +969,7 @@ func (p *OAuthProxy) CheckBasicAuth(req *http.Request) (*sessions.SessionState,
967969 }
968970 if p.HtpasswdFile.Validate(pair[0], pair[1]) {
969971 logger.PrintAuthf(pair[0], req, logger.AuthSuccess, "Authenticated via basic auth and HTpasswd File")
970− return &sessions.SessionState{User: pair[0]}, nil
972+ return &sessionsapi.SessionState{User: pair[0]}, nil
971973 }
972974 logger.PrintAuthf(pair[0], req, logger.AuthFailure, "Invalid authentication via basic auth: not in Htpasswd File")
973975 return nil, nil