From 8ccbe3de7a63278f92b86f44a4029dc308ff57a8 Mon Sep 17 00:00:00 2001 From: Jake Urban Date: Tue, 24 Jan 2023 13:40:00 -0800 Subject: [PATCH] use correct 'sub' value for JWT --- exp/services/webauth/internal/serve/token.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/exp/services/webauth/internal/serve/token.go b/exp/services/webauth/internal/serve/token.go index c69ce6586a..ba9df83bef 100644 --- a/exp/services/webauth/internal/serve/token.go +++ b/exp/services/webauth/internal/serve/token.go @@ -2,6 +2,7 @@ package serve import ( "net/http" + "strconv" "strings" "time" @@ -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)), }