Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVEREST-1771 remove unused cookie #1031

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions api-tests/tests/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ test('auth header fails with invalid token', async ({ request }) => {
expect(version.status()).toEqual(401);
});

test('auth header is preferred over cookie', async ({ browser }) => {
const ctx = await browser.newContext();

await ctx.addCookies([{
name: 'everest_token', value: '123', url: 'http://127.0.0.1:8080',
}]);

const request = ctx.request;

const version = await request.get('/v1/version');

await checkError(version);
});

test.describe('no authorization header', () => {
test.use({
extraHTTPHeaders: {
Expand All @@ -52,34 +38,4 @@ test.describe('no authorization header', () => {

expect(version.status()).toEqual(401);
});

test('auth cookie fails with invalid token', async ({ browser }) => {
const ctx = await browser.newContext();

await ctx.addCookies([{
name: 'everest_token', value: '123', url: 'http://127.0.0.1:8080',
}]);

const request = ctx.request;

const version = await request.get('/v1/version');

expect(version.status()).toEqual(401);
});

test('auth cookie works with a valid token', async ({ page }) => {
const ctx = page.context();

await ctx.addCookies([{
name: 'everest_token',
value: process.env.API_TOKEN,
url: 'http://127.0.0.1:8080',
}]);

const request = ctx.request;

const version = await request.get('/v1/version');

await checkError(version);
});
});
1 change: 0 additions & 1 deletion internal/server/everest.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ func (e *EverestServer) jwtMiddleWare(ctx context.Context) (echo.MiddlewareFunc,
}

tokenLookup := "header:Authorization:Bearer "
tokenLookup = tokenLookup + ",cookie:" + common.EverestTokenCookie
return echojwt.WithConfig(echojwt.Config{
Skipper: skipper,
TokenLookup: tokenLookup,
Expand Down
5 changes: 0 additions & 5 deletions internal/server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

"github.com/percona/everest/api"
"github.com/percona/everest/pkg/accounts"
"github.com/percona/everest/pkg/common"
)

const (
Expand Down Expand Up @@ -62,10 +61,6 @@ func (e *EverestServer) CreateSession(ctx echo.Context) error {
return err
}

ctx.SetCookie(&http.Cookie{
Name: common.EverestTokenCookie,
Value: jwtToken,
})
e.attemptsStore.CleanupVisitor(ctx.RealIP())

return ctx.JSON(http.StatusOK, map[string]string{"token": jwtToken})
Expand Down
2 changes: 0 additions & 2 deletions pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ const (

// EverestSettingsConfigMapName is the name of the Everest settings ConfigMap.
EverestSettingsConfigMapName = "everest-settings"
// EverestTokenCookie is the name of the cookie that holds the token.
EverestTokenCookie = "everest_token"
// EverestRBACConfigMapName is the name of the Everest RBAC ConfigMap.
EverestRBACConfigMapName = "everest-rbac"
// KubernetesManagedByLabel is the label used to identify resources managed by Everest.
Expand Down
Loading