@@ -16,7 +16,7 @@ import (
16 "github.com/mbland/hmacauth"
16 "github.com/mbland/hmacauth"
17 "github.com/pusher/oauth2_proxy/cookie"
17 "github.com/pusher/oauth2_proxy/cookie"
18 "github.com/pusher/oauth2_proxy/logger"
18 "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"
20 "github.com/pusher/oauth2_proxy/providers"
20 "github.com/pusher/oauth2_proxy/providers"
21 "github.com/yhat/wsutil"
21 "github.com/yhat/wsutil"
@@ -75,6 +75,7 @@ type OAuthProxy struct {
75 redirectURL *url.URL // the url to receive requests at
75 redirectURL *url.URL // the url to receive requests at
76 whitelistDomains []string
76 whitelistDomains []string
77 provider providers.Provider
77 provider providers.Provider
78+ sessionStore sessionsapi.SessionStore
78 ProxyPrefix string
79 ProxyPrefix string
79 SignInMessage string
80 SignInMessage string
80 HtpasswdFile *HtpasswdFile
81 HtpasswdFile *HtpasswdFile
@@ -249,6 +250,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
250 ProxyPrefix: opts.ProxyPrefix,
251 ProxyPrefix: opts.ProxyPrefix,
251 provider: opts.provider,
252 provider: opts.provider,
253+ sessionStore: opts.sessionStore,
252 serveMux: serveMux,
254 serveMux: serveMux,
253 redirectURL: redirectURL,
255 redirectURL: redirectURL,
254 whitelistDomains: opts.WhitelistDomains,
256 whitelistDomains: opts.WhitelistDomains,
@@ -293,7 +295,7 @@ func (p *OAuthProxy) displayCustomLoginForm() bool {
293 return p.HtpasswdFile != nil && p.DisplayHtpasswdForm
295 return p.HtpasswdFile != nil && p.DisplayHtpasswdForm
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) {
297 if code == "" {
299 if code == "" {
298 return nil, errors.New("missing code")
300 return nil, errors.New("missing code")
@@ -485,7 +487,7 @@ func (p *OAuthProxy) SetSessionCookie(rw http.ResponseWriter, req *http.Request,
487// LoadCookiedSession reads the user's authentication details from the request
489// 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) {
489 var age time.Duration
491 var age time.Duration
490 c, err := loadCookie(req, p.CookieName)
492 c, err := loadCookie(req, p.CookieName)
491 if err != nil {
493 if err != nil {
@@ -507,7 +509,7 @@ func (p *OAuthProxy) LoadCookiedSession(req *http.Request) (*sessions.SessionSta
509// SaveSession creates a new session cookie value and sets this on the response
511// 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 {
511 value, err := p.provider.CookieForSession(s, p.CookieCipher)
513 value, err := p.provider.CookieForSession(s, p.CookieCipher)
512 if err != nil {
514 if err != nil {
513 return err
515 return err
@@ -694,7 +696,7 @@ func (p *OAuthProxy) SignIn(rw http.ResponseWriter, req *http.Request) {
695 user, ok := p.ManualSignIn(rw, req)
697 user, ok := p.ManualSignIn(rw, req)
697− session := &sessions.SessionState{User: user}
699+ session := &sessionsapi.SessionState{User: user}
698 p.SaveSession(rw, req, session)
700 p.SaveSession(rw, req, session)
699 http.Redirect(rw, req, redirect, 302)
701 http.Redirect(rw, req, redirect, 302)
@@ -945,7 +947,7 @@ func (p *OAuthProxy) Authenticate(rw http.ResponseWriter, req *http.Request) int
946// CheckBasicAuth checks the requests Authorization header for basic auth
948// CheckBasicAuth checks the requests Authorization header for basic auth
947// credentials and authenticates these against the proxies HtpasswdFile
949// 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) {
949 if p.HtpasswdFile == nil {
951 if p.HtpasswdFile == nil {
950 return nil, nil
952 return nil, nil
@@ -967,7 +969,7 @@ func (p *OAuthProxy) CheckBasicAuth(req *http.Request) (*sessions.SessionState,
968 if p.HtpasswdFile.Validate(pair[0], pair[1]) {
970 if p.HtpasswdFile.Validate(pair[0], pair[1]) {
969 logger.PrintAuthf(pair[0], req, logger.AuthSuccess, "Authenticated via basic auth and HTpasswd File")
971 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
972 logger.PrintAuthf(pair[0], req, logger.AuthFailure, "Invalid authentication via basic auth: not in Htpasswd File")
974 logger.PrintAuthf(pair[0], req, logger.AuthFailure, "Invalid authentication via basic auth: not in Htpasswd File")
973 return nil, nil
975 return nil, nil