Skip to content

Commit 58a254b

Browse files
committed
[CR] Limit loginRequestToken length; extract X-Lakefs-Mailbox header
1 parent 3977706 commit 58a254b

File tree

7 files changed

+17
-13
lines changed

7 files changed

+17
-13
lines changed

api/swagger.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,12 +3286,13 @@ paths:
32863286
/auth/get-token/release-token/{loginRequestToken}:
32873287
parameters:
32883288
- in: path
3289-
# The mailbox is secret. It is identified by the loginRequestToken
3290-
# - a JWT which is _not_ secret. So it can safely go in the header.
3289+
# The mailbox is secret. It is identified by the loginRequestToken - a JWT which is
3290+
# _not_ secret. So this JWT can safely go in a header.
32913291
name: loginRequestToken
32923292
required: true
32933293
schema:
32943294
type: string
3295+
maxLength: 1024
32953296
description: login request token returned by getTokenRedirect.
32963297
get: # Called by opening a URL on the browser!
32973298
tags:

clients/java/api/openapi.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/python/lakefs_sdk/api/auth_api.py

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/python/lakefs_sdk/api/experimental_api.py

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/lakectl/cmd/login.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/skratchdot/open-golang/open"
1212
"github.com/spf13/cobra"
1313
"github.com/treeverse/lakefs/pkg/api/apigen"
14+
"github.com/treeverse/lakefs/pkg/httputil"
1415
)
1516

1617
const (
@@ -58,7 +59,7 @@ var loginCmd = &cobra.Command{
5859
if err != nil {
5960
DieErr(fmt.Errorf("parse relative redirect URL %s: %w", header.Get("location"), err))
6061
}
61-
mailbox := header.Get("x-lakefs-mailbox")
62+
mailbox := header.Get(httputil.LoginMailboxHeaderName)
6263

6364
redirectURL := serverURL.ResolveReference(relativeLocation)
6465

pkg/api/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ func (c *Controller) GetTokenRedirect(w http.ResponseWriter, r *http.Request) {
884884
}
885885

886886
w.Header().Set("Location", redirect.RedirectURL)
887-
w.Header().Set("X-LakeFS-Mailbox", redirect.Mailbox)
887+
w.Header().Set(httputil.LoginMailboxHeaderName, redirect.Mailbox)
888888

889889
writeResponse(w, r, http.StatusOK, nil)
890890
}

pkg/httputil/headers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package httputil
22

33
const (
4-
RequestIDHeaderName = "X-Request-ID"
4+
RequestIDHeaderName = "X-Request-ID"
5+
LoginMailboxHeaderName = "X-LakeFS-Mailbox"
56
)

0 commit comments

Comments
 (0)