Skip to content
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
2 changes: 1 addition & 1 deletion api/handler/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/labstack/echo/v4"
"github.com/pkg/errors"

service "github.com/String-xyz/string-api/pkg/service"
"github.com/String-xyz/string-api/pkg/service"
)

type Card interface {
Expand Down
15 changes: 7 additions & 8 deletions api/handler/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/String-xyz/go-lib/v2/common"
libcommon "github.com/String-xyz/go-lib/v2/common"
"github.com/String-xyz/go-lib/v2/httperror"
serror "github.com/String-xyz/go-lib/v2/stringerror"
"github.com/String-xyz/string-api/pkg/model"
Expand All @@ -23,8 +22,8 @@ func SetJWTCookie(c echo.Context, jwt model.JWT) error {
cookie.HttpOnly = true
cookie.Expires = jwt.ExpAt // we want the cookie to expire at the same time as the token
cookie.SameSite = getCookieSameSiteMode()
cookie.Path = "/" // Send cookie in every sub path request
cookie.Secure = !libcommon.IsLocalEnv() // in production allow https only
cookie.Path = "/" // Send cookie in every sub path request
cookie.Secure = !common.IsLocalEnv() // in production allow https only
c.SetCookie(cookie)

return nil
Expand All @@ -37,8 +36,8 @@ func SetRefreshTokenCookie(c echo.Context, refresh model.RefreshTokenResponse) e
cookie.HttpOnly = true
cookie.Expires = refresh.ExpAt // we want the cookie to expire at the same time as the token
cookie.SameSite = getCookieSameSiteMode()
cookie.Path = "/login/" // Send cookie only in /login path request
cookie.Secure = !libcommon.IsLocalEnv() // in production allow https only
cookie.Path = "/login/" // Send cookie only in /login path request
cookie.Secure = !common.IsLocalEnv() // in production allow https only
c.SetCookie(cookie)

return nil
Expand Down Expand Up @@ -67,7 +66,7 @@ func DeleteAuthCookies(c echo.Context) error {
cookie.Expires = time.Now()
cookie.SameSite = getCookieSameSiteMode()
cookie.Path = "/" // Send cookie in every sub path request
cookie.Secure = !libcommon.IsLocalEnv()
cookie.Secure = !common.IsLocalEnv()
c.SetCookie(cookie)

cookie = new(http.Cookie)
Expand All @@ -77,7 +76,7 @@ func DeleteAuthCookies(c echo.Context) error {
cookie.Expires = time.Now()
cookie.SameSite = getCookieSameSiteMode()
cookie.Path = "/login/" // Send cookie only in refresh path request
cookie.Secure = !libcommon.IsLocalEnv()
cookie.Secure = !common.IsLocalEnv()
c.SetCookie(cookie)

return nil
Expand All @@ -90,7 +89,7 @@ func validAddress(addr string) bool {

func getCookieSameSiteMode() http.SameSite {
sameSiteMode := http.SameSiteNoneMode // allow cors
if libcommon.IsLocalEnv() {
if common.IsLocalEnv() {
sameSiteMode = http.SameSiteLaxMode // because SameSiteNoneMode is not allowed in localhost we use lax mode
}
return sameSiteMode
Expand Down
6 changes: 2 additions & 4 deletions pkg/internal/persona/persona_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ package persona

import (
"fmt"
"testing"

env "github.com/String-xyz/go-lib/v2/config"
"github.com/stretchr/testify/assert"

"github.com/String-xyz/string-api/config"
"github.com/stretchr/testify/assert"
"testing"
)

func init() {
Expand Down