Skip to content

Commit

Permalink
chore(backend): extend access token expiry (#1031)
Browse files Browse the repository at this point in the history
- extend access token expiry duration when in debug mode fo an easier
development experience
  • Loading branch information
detj authored Aug 14, 2024
1 parent 421ecd4 commit c0fce3f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions measure-backend/measure-go/authsession/authsession.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"measure-backend/measure-go/server"
"time"

"github.com/gin-gonic/gin"
"github.com/golang-jwt/jwt/v5"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
Expand Down Expand Up @@ -80,6 +81,12 @@ func NewAuthSession(userId, teamId uuid.UUID, provider string, meta json.RawMess
now := time.Now()
atSecret := server.Server.Config.AccessTokenSecret
atExpiryAt := now.Add(accessTokenExpiryDuration)

// use extended expiry when in debug mode
if gin.IsDebugging() {
atExpiryAt = now.Add(24 * time.Hour)
}

accessToken, err := createAccessToken(userId, teamId, atSecret, atExpiryAt)
if err != nil {
return
Expand Down

0 comments on commit c0fce3f

Please sign in to comment.