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

lsat header: change to new name/value #19

Merged
merged 2 commits into from
Aug 23, 2022
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
11 changes: 6 additions & 5 deletions ginlsat/ginlsat.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ const (
)

const (
LSAT_TYPE_FREE = "FREE"
LSAT_TYPE_PAID = "PAID"
LSAT_TYPE_ERROR = "ERROR"
LSAT_HEADER = "application/vnd.lsat.v1.full"
LSAT_TYPE_FREE = "FREE"
LSAT_TYPE_PAID = "PAID"
LSAT_TYPE_ERROR = "ERROR"
LSAT_HEADER = "LSAT"
LSAT_HEADER_NAME = "Accept-Authenticate"
)

const (
Expand Down Expand Up @@ -86,7 +87,7 @@ func (lsatmiddleware *GinLsatMiddleware) Handler(c *gin.Context) {
mac, preimage, err := utils.ParseLsatHeader(authField)
if err != nil {
// No Authorization present, check if client supports LSAT
acceptLsatField := c.Request.Header.Get("Accept")
acceptLsatField := c.Request.Header.Get(LSAT_HEADER_NAME)
if strings.Contains(acceptLsatField, LSAT_HEADER) {
lsatmiddleware.SetLSATHeader(c)
return
Expand Down
4 changes: 2 additions & 2 deletions ginlsat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestLsatWithLNURLConfig(t *testing.T) {

router.GET("/protected").
SetHeader(gofight.H{
"Accept": "application/vnd.lsat.v1.full+json",
ginlsat.LSAT_HEADER_NAME: ginlsat.LSAT_HEADER,
}).
Run(handler, func(res gofight.HTTPResponse, req gofight.HTTPRequest) {
message := fmt.Sprint(gjson.Get(res.Body.String(), "message"))
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestLsatWithLNDConfig(t *testing.T) {

router.GET("/protected").
SetHeader(gofight.H{
"Accept": "application/vnd.lsat.v1.full+json",
ginlsat.LSAT_HEADER_NAME: ginlsat.LSAT_HEADER,
}).
Run(handler, func(res gofight.HTTPResponse, req gofight.HTTPRequest) {
message := fmt.Sprint(gjson.Get(res.Body.String(), "message"))
Expand Down