internal: fix typo in session name constant
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		| @ -98,7 +98,7 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore | |||||||
| 	} | 	} | ||||||
| 	a.sessions = a.getStore(p, externalHost) | 	a.sessions = a.getStore(p, externalHost) | ||||||
| 	mux.Use(web.NewLoggingHandler(muxLogger, func(l *log.Entry, r *http.Request) *log.Entry { | 	mux.Use(web.NewLoggingHandler(muxLogger, func(l *log.Entry, r *http.Request) *log.Entry { | ||||||
| 		s, err := a.sessions.Get(r, constants.SeesionName) | 		s, err := a.sessions.Get(r, constants.SessionName) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return l | 			return l | ||||||
| 		} | 		} | ||||||
| @ -199,7 +199,7 @@ func (a *Application) ServeHTTP(rw http.ResponseWriter, r *http.Request) { | |||||||
|  |  | ||||||
| func (a *Application) handleSignOut(rw http.ResponseWriter, r *http.Request) { | func (a *Application) handleSignOut(rw http.ResponseWriter, r *http.Request) { | ||||||
| 	//TODO: Token revocation | 	//TODO: Token revocation | ||||||
| 	s, err := a.sessions.Get(r, constants.SeesionName) | 	s, err := a.sessions.Get(r, constants.SessionName) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		http.Redirect(rw, r, a.endpint.EndSessionEndpoint, http.StatusFound) | 		http.Redirect(rw, r, a.endpint.EndSessionEndpoint, http.StatusFound) | ||||||
| 		return | 		return | ||||||
|  | |||||||
| @ -54,7 +54,7 @@ func (a *Application) forwardHandleTraefik(rw http.ResponseWriter, r *http.Reque | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	host := "" | 	host := "" | ||||||
| 	s, _ := a.sessions.Get(r, constants.SeesionName) | 	s, _ := a.sessions.Get(r, constants.SessionName) | ||||||
| 	// Optional suffix, which is appended to the URL | 	// Optional suffix, which is appended to the URL | ||||||
| 	if *a.proxyConfig.Mode == api.PROXYMODE_FORWARD_SINGLE { | 	if *a.proxyConfig.Mode == api.PROXYMODE_FORWARD_SINGLE { | ||||||
| 		host = web.GetHost(r) | 		host = web.GetHost(r) | ||||||
| @ -111,7 +111,7 @@ func (a *Application) forwardHandleNginx(rw http.ResponseWriter, r *http.Request | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(r, constants.SeesionName) | 	s, _ := a.sessions.Get(r, constants.SessionName) | ||||||
| 	s.Values[constants.SessionRedirect] = fwd.String() | 	s.Values[constants.SessionRedirect] = fwd.String() | ||||||
| 	err = s.Save(r, rw) | 	err = s.Save(r, rw) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | |||||||
| @ -41,7 +41,7 @@ func TestForwardHandleNginx_Single_Headers(t *testing.T) { | |||||||
|  |  | ||||||
| 	assert.Equal(t, rr.Code, http.StatusUnauthorized) | 	assert.Equal(t, rr.Code, http.StatusUnauthorized) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "http://test.goauthentik.io/app", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "http://test.goauthentik.io/app", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -55,7 +55,7 @@ func TestForwardHandleNginx_Single_URI(t *testing.T) { | |||||||
|  |  | ||||||
| 	assert.Equal(t, rr.Code, http.StatusUnauthorized) | 	assert.Equal(t, rr.Code, http.StatusUnauthorized) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "/app", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "/app", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -67,7 +67,7 @@ func TestForwardHandleNginx_Single_Claims(t *testing.T) { | |||||||
| 	rr := httptest.NewRecorder() | 	rr := httptest.NewRecorder() | ||||||
| 	a.forwardHandleNginx(rr, req) | 	a.forwardHandleNginx(rr, req) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	s.Values[constants.SessionClaims] = Claims{ | 	s.Values[constants.SessionClaims] = Claims{ | ||||||
| 		Sub: "foo", | 		Sub: "foo", | ||||||
| 		Proxy: &ProxyClaims{ | 		Proxy: &ProxyClaims{ | ||||||
| @ -129,6 +129,6 @@ func TestForwardHandleNginx_Domain_Header(t *testing.T) { | |||||||
|  |  | ||||||
| 	assert.Equal(t, http.StatusUnauthorized, rr.Code) | 	assert.Equal(t, http.StatusUnauthorized, rr.Code) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "http://test.goauthentik.io/app", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "http://test.goauthentik.io/app", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  | |||||||
| @ -47,7 +47,7 @@ func TestForwardHandleTraefik_Single_Headers(t *testing.T) { | |||||||
| 	loc, _ := rr.Result().Location() | 	loc, _ := rr.Result().Location() | ||||||
| 	assert.Equal(t, loc.String(), "http://test.goauthentik.io/outpost.goauthentik.io/start") | 	assert.Equal(t, loc.String(), "http://test.goauthentik.io/outpost.goauthentik.io/start") | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "http://test.goauthentik.io/app", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "http://test.goauthentik.io/app", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -61,7 +61,7 @@ func TestForwardHandleTraefik_Single_Claims(t *testing.T) { | |||||||
| 	rr := httptest.NewRecorder() | 	rr := httptest.NewRecorder() | ||||||
| 	a.forwardHandleTraefik(rr, req) | 	a.forwardHandleTraefik(rr, req) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	s.Values[constants.SessionClaims] = Claims{ | 	s.Values[constants.SessionClaims] = Claims{ | ||||||
| 		Sub: "foo", | 		Sub: "foo", | ||||||
| 		Proxy: &ProxyClaims{ | 		Proxy: &ProxyClaims{ | ||||||
| @ -127,6 +127,6 @@ func TestForwardHandleTraefik_Domain_Header(t *testing.T) { | |||||||
| 	loc, _ := rr.Result().Location() | 	loc, _ := rr.Result().Location() | ||||||
| 	assert.Equal(t, "http://auth.test.goauthentik.io/outpost.goauthentik.io/start", loc.String()) | 	assert.Equal(t, "http://auth.test.goauthentik.io/outpost.goauthentik.io/start", loc.String()) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "http://test.goauthentik.io/app", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "http://test.goauthentik.io/app", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ func TestProxy_ModifyRequest_Claims(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| 	rr := httptest.NewRecorder() | 	rr := httptest.NewRecorder() | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	s.Values[constants.SessionClaims] = Claims{ | 	s.Values[constants.SessionClaims] = Claims{ | ||||||
| 		Sub: "foo", | 		Sub: "foo", | ||||||
| 		Proxy: &ProxyClaims{ | 		Proxy: &ProxyClaims{ | ||||||
| @ -62,7 +62,7 @@ func TestProxy_ModifyRequest_Claims_Invalid(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| 	rr := httptest.NewRecorder() | 	rr := httptest.NewRecorder() | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	s.Values[constants.SessionClaims] = Claims{ | 	s.Values[constants.SessionClaims] = Claims{ | ||||||
| 		Sub: "foo", | 		Sub: "foo", | ||||||
| 		Proxy: &ProxyClaims{ | 		Proxy: &ProxyClaims{ | ||||||
|  | |||||||
| @ -43,7 +43,7 @@ func (a *Application) checkRedirectParam(r *http.Request) (string, bool) { | |||||||
|  |  | ||||||
| func (a *Application) handleRedirect(rw http.ResponseWriter, r *http.Request) { | func (a *Application) handleRedirect(rw http.ResponseWriter, r *http.Request) { | ||||||
| 	newState := base64.RawURLEncoding.EncodeToString(securecookie.GenerateRandomKey(32)) | 	newState := base64.RawURLEncoding.EncodeToString(securecookie.GenerateRandomKey(32)) | ||||||
| 	s, err := a.sessions.Get(r, constants.SeesionName) | 	s, err := a.sessions.Get(r, constants.SessionName) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		s.Values[constants.SessionOAuthState] = []string{} | 		s.Values[constants.SessionOAuthState] = []string{} | ||||||
| 	} | 	} | ||||||
| @ -66,7 +66,7 @@ func (a *Application) handleRedirect(rw http.ResponseWriter, r *http.Request) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func (a *Application) handleCallback(rw http.ResponseWriter, r *http.Request) { | func (a *Application) handleCallback(rw http.ResponseWriter, r *http.Request) { | ||||||
| 	s, err := a.sessions.Get(r, constants.SeesionName) | 	s, err := a.sessions.Get(r, constants.SessionName) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		a.log.WithError(err).Trace("failed to get session") | 		a.log.WithError(err).Trace("failed to get session") | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ func urlJoin(originalUrl string, newPath string) string { | |||||||
| } | } | ||||||
|  |  | ||||||
| func (a *Application) redirectToStart(rw http.ResponseWriter, r *http.Request) { | func (a *Application) redirectToStart(rw http.ResponseWriter, r *http.Request) { | ||||||
| 	s, err := a.sessions.Get(r, constants.SeesionName) | 	s, err := a.sessions.Get(r, constants.SessionName) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		a.log.WithError(err).Warning("failed to decode session") | 		a.log.WithError(err).Warning("failed to decode session") | ||||||
| 	} | 	} | ||||||
| @ -52,7 +52,7 @@ func (a *Application) redirectToStart(rw http.ResponseWriter, r *http.Request) { | |||||||
| // getClaims Get claims which are currently in session | // getClaims Get claims which are currently in session | ||||||
| // Returns an error if the session can't be loaded or the claims can't be parsed/type-cast | // Returns an error if the session can't be loaded or the claims can't be parsed/type-cast | ||||||
| func (a *Application) getClaims(r *http.Request) (*Claims, error) { | func (a *Application) getClaims(r *http.Request) (*Claims, error) { | ||||||
| 	s, err := a.sessions.Get(r, constants.SeesionName) | 	s, err := a.sessions.Get(r, constants.SessionName) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		// err == user has no session/session is not valid, reject | 		// err == user has no session/session is not valid, reject | ||||||
| 		return nil, fmt.Errorf("invalid session") | 		return nil, fmt.Errorf("invalid session") | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ func TestRedirectToStart_Proxy(t *testing.T) { | |||||||
| 	loc, _ := rr.Result().Location() | 	loc, _ := rr.Result().Location() | ||||||
| 	assert.Equal(t, "https://test.goauthentik.io/outpost.goauthentik.io/start?rd=https%3A%2F%2Ftest.goauthentik.io%2Ffoo%2Fbar%2Fbaz", loc.String()) | 	assert.Equal(t, "https://test.goauthentik.io/outpost.goauthentik.io/start?rd=https%3A%2F%2Ftest.goauthentik.io%2Ffoo%2Fbar%2Fbaz", loc.String()) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "https://test.goauthentik.io/foo/bar/baz", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "https://test.goauthentik.io/foo/bar/baz", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -40,7 +40,7 @@ func TestRedirectToStart_Forward(t *testing.T) { | |||||||
| 	loc, _ := rr.Result().Location() | 	loc, _ := rr.Result().Location() | ||||||
| 	assert.Equal(t, "https://test.goauthentik.io/outpost.goauthentik.io/start?rd=https%3A%2F%2Ftest.goauthentik.io%2Ffoo%2Fbar%2Fbaz", loc.String()) | 	assert.Equal(t, "https://test.goauthentik.io/outpost.goauthentik.io/start?rd=https%3A%2F%2Ftest.goauthentik.io%2Ffoo%2Fbar%2Fbaz", loc.String()) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "https://test.goauthentik.io/foo/bar/baz", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "https://test.goauthentik.io/foo/bar/baz", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -58,7 +58,7 @@ func TestRedirectToStart_Forward_Domain_Invalid(t *testing.T) { | |||||||
| 	loc, _ := rr.Result().Location() | 	loc, _ := rr.Result().Location() | ||||||
| 	assert.Equal(t, "https://test.goauthentik.io/outpost.goauthentik.io/start?rd=https%3A%2F%2Ftest.goauthentik.io", loc.String()) | 	assert.Equal(t, "https://test.goauthentik.io/outpost.goauthentik.io/start?rd=https%3A%2F%2Ftest.goauthentik.io", loc.String()) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "https://test.goauthentik.io", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "https://test.goauthentik.io", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -76,6 +76,6 @@ func TestRedirectToStart_Forward_Domain(t *testing.T) { | |||||||
| 	loc, _ := rr.Result().Location() | 	loc, _ := rr.Result().Location() | ||||||
| 	assert.Equal(t, "https://test.goauthentik.io/outpost.goauthentik.io/start?rd=https%3A%2F%2Ftest.goauthentik.io", loc.String()) | 	assert.Equal(t, "https://test.goauthentik.io/outpost.goauthentik.io/start?rd=https%3A%2F%2Ftest.goauthentik.io", loc.String()) | ||||||
|  |  | ||||||
| 	s, _ := a.sessions.Get(req, constants.SeesionName) | 	s, _ := a.sessions.Get(req, constants.SessionName) | ||||||
| 	assert.Equal(t, "https://test.goauthentik.io", s.Values[constants.SessionRedirect]) | 	assert.Equal(t, "https://test.goauthentik.io", s.Values[constants.SessionRedirect]) | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| package constants | package constants | ||||||
|  |  | ||||||
| const SeesionName = "authentik_proxy" | const SessionName = "authentik_proxy" | ||||||
|  |  | ||||||
| const SessionOAuthState = "oauth_state" | const SessionOAuthState = "oauth_state" | ||||||
| const SessionClaims = "claims" | const SessionClaims = "claims" | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer