Skip to content

Commit

Permalink
internal: fix typo in session name constant
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
  • Loading branch information
BeryJu committed May 20, 2022
1 parent 5bc893b commit a52638d
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions internal/outpost/proxyv2/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore
}
a.sessions = a.getStore(p, externalHost)
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 {
return l
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func (a *Application) ServeHTTP(rw http.ResponseWriter, r *http.Request) {

func (a *Application) handleSignOut(rw http.ResponseWriter, r *http.Request) {
//TODO: Token revocation
s, err := a.sessions.Get(r, constants.SeesionName)
s, err := a.sessions.Get(r, constants.SessionName)
if err != nil {
http.Redirect(rw, r, a.endpint.EndSessionEndpoint, http.StatusFound)
return
Expand Down
4 changes: 2 additions & 2 deletions internal/outpost/proxyv2/application/mode_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (a *Application) forwardHandleTraefik(rw http.ResponseWriter, r *http.Reque
return
}
host := ""
s, _ := a.sessions.Get(r, constants.SeesionName)
s, _ := a.sessions.Get(r, constants.SessionName)
// Optional suffix, which is appended to the URL
if *a.proxyConfig.Mode == api.PROXYMODE_FORWARD_SINGLE {
host = web.GetHost(r)
Expand Down Expand Up @@ -111,7 +111,7 @@ func (a *Application) forwardHandleNginx(rw http.ResponseWriter, r *http.Request
return
}

s, _ := a.sessions.Get(r, constants.SeesionName)
s, _ := a.sessions.Get(r, constants.SessionName)
s.Values[constants.SessionRedirect] = fwd.String()
err = s.Save(r, rw)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestForwardHandleNginx_Single_Headers(t *testing.T) {

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])
}

Expand All @@ -55,7 +55,7 @@ func TestForwardHandleNginx_Single_URI(t *testing.T) {

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])
}

Expand All @@ -67,7 +67,7 @@ func TestForwardHandleNginx_Single_Claims(t *testing.T) {
rr := httptest.NewRecorder()
a.forwardHandleNginx(rr, req)

s, _ := a.sessions.Get(req, constants.SeesionName)
s, _ := a.sessions.Get(req, constants.SessionName)
s.Values[constants.SessionClaims] = Claims{
Sub: "foo",
Proxy: &ProxyClaims{
Expand Down Expand Up @@ -129,6 +129,6 @@ func TestForwardHandleNginx_Domain_Header(t *testing.T) {

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])
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestForwardHandleTraefik_Single_Headers(t *testing.T) {
loc, _ := rr.Result().Location()
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])
}

Expand All @@ -61,7 +61,7 @@ func TestForwardHandleTraefik_Single_Claims(t *testing.T) {
rr := httptest.NewRecorder()
a.forwardHandleTraefik(rr, req)

s, _ := a.sessions.Get(req, constants.SeesionName)
s, _ := a.sessions.Get(req, constants.SessionName)
s.Values[constants.SessionClaims] = Claims{
Sub: "foo",
Proxy: &ProxyClaims{
Expand Down Expand Up @@ -127,6 +127,6 @@ func TestForwardHandleTraefik_Domain_Header(t *testing.T) {
loc, _ := rr.Result().Location()
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])
}
4 changes: 2 additions & 2 deletions internal/outpost/proxyv2/application/mode_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestProxy_ModifyRequest_Claims(t *testing.T) {
}
rr := httptest.NewRecorder()

s, _ := a.sessions.Get(req, constants.SeesionName)
s, _ := a.sessions.Get(req, constants.SessionName)
s.Values[constants.SessionClaims] = Claims{
Sub: "foo",
Proxy: &ProxyClaims{
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestProxy_ModifyRequest_Claims_Invalid(t *testing.T) {
}
rr := httptest.NewRecorder()

s, _ := a.sessions.Get(req, constants.SeesionName)
s, _ := a.sessions.Get(req, constants.SessionName)
s.Values[constants.SessionClaims] = Claims{
Sub: "foo",
Proxy: &ProxyClaims{
Expand Down
4 changes: 2 additions & 2 deletions internal/outpost/proxyv2/application/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (a *Application) checkRedirectParam(r *http.Request) (string, bool) {

func (a *Application) handleRedirect(rw http.ResponseWriter, r *http.Request) {
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 {
s.Values[constants.SessionOAuthState] = []string{}
}
Expand All @@ -66,7 +66,7 @@ func (a *Application) handleRedirect(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 {
a.log.WithError(err).Trace("failed to get session")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/outpost/proxyv2/application/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func urlJoin(originalUrl string, newPath string) string {
}

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 {
a.log.WithError(err).Warning("failed to decode session")
}
Expand Down Expand Up @@ -52,7 +52,7 @@ func (a *Application) redirectToStart(rw http.ResponseWriter, r *http.Request) {
// 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
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 {
// err == user has no session/session is not valid, reject
return nil, fmt.Errorf("invalid session")
Expand Down
8 changes: 4 additions & 4 deletions internal/outpost/proxyv2/application/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestRedirectToStart_Proxy(t *testing.T) {
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())

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])
}

Expand All @@ -40,7 +40,7 @@ func TestRedirectToStart_Forward(t *testing.T) {
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())

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])
}

Expand All @@ -58,7 +58,7 @@ func TestRedirectToStart_Forward_Domain_Invalid(t *testing.T) {
loc, _ := rr.Result().Location()
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])
}

Expand All @@ -76,6 +76,6 @@ func TestRedirectToStart_Forward_Domain(t *testing.T) {
loc, _ := rr.Result().Location()
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])
}
2 changes: 1 addition & 1 deletion internal/outpost/proxyv2/constants/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package constants

const SeesionName = "authentik_proxy"
const SessionName = "authentik_proxy"

const SessionOAuthState = "oauth_state"
const SessionClaims = "claims"
Expand Down

0 comments on commit a52638d

Please sign in to comment.