Skip to content

Commit

Permalink
use correct 'sub' value for JWT
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeUrban committed Jan 24, 2023
1 parent d8ce2a5 commit 8ccbe3d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion exp/services/webauth/internal/serve/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package serve

import (
"net/http"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -148,10 +149,21 @@ func (h tokenHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

var sub string
if muxedAccount == (xdr.MuxedAccount{}) {
sub = clientAccountID
if memo != nil {
xdrMemo, _ := memo.ToXDR()
sub += ":" + strconv.FormatUint(uint64(xdrMemo.MustId()), 10)
}
} else {
sub = muxedAccount.Address()
}

issuedAt := time.Unix(tx.Timebounds().MinTime, 0)
claims := jwt.Claims{
Issuer: h.JWTIssuer,
Subject: muxedAccount.Address(),
Subject: sub,
IssuedAt: jwt.NewNumericDate(issuedAt),
Expiry: jwt.NewNumericDate(issuedAt.Add(h.JWTExpiresIn)),
}
Expand Down

0 comments on commit 8ccbe3d

Please sign in to comment.