Skip to content

Commit 69c891e

Browse files
committed
fix token handling
1 parent efa68f5 commit 69c891e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

callback.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (t *Tmpauth) authCallback(w http.ResponseWriter, r *http.Request) (int, err
7979
})
8080
}
8181

82-
token, err := t.ParseAuthJWT(tokenStr, backgroundWorker.MinValidationTime())
82+
token, err := t.ParseAuthJWT(tokenStr, "", backgroundWorker.MinValidationTime())
8383
if err != nil {
8484
t.DebugLog(fmt.Sprintf("failed to verify callback token: %v", err))
8585
return t.failRedirect(w, r, ErrInvalidCallbackToken)
@@ -111,6 +111,7 @@ func (t *Tmpauth) authCallback(w http.ResponseWriter, r *http.Request) (int, err
111111

112112
// token validated, can cache now
113113
tokenID := sha256.Sum256([]byte(wToken))
114+
token.RawToken = wToken
114115
t.tokenCacheMutex.Lock()
115116
t.TokenCache[tokenID] = token
116117
t.tokenCacheMutex.Unlock()

token.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (t *Tmpauth) ParseWrappedAuthJWT(tokenStr string) (*CachedToken, error) {
147147

148148
wToken := wTokenRaw.Claims.(*wrappedToken)
149149

150-
cachedToken, err = t.ParseAuthJWT(wToken.Token, minValidationTime)
150+
cachedToken, err = t.ParseAuthJWT(wToken.Token, tokenStr, minValidationTime)
151151
if err != nil {
152152
return nil, err
153153
}
@@ -159,7 +159,7 @@ func (t *Tmpauth) ParseWrappedAuthJWT(tokenStr string) (*CachedToken, error) {
159159
return cachedToken, nil
160160
}
161161

162-
func (t *Tmpauth) ParseAuthJWT(tokenStr string, minValidationTime time.Time) (*CachedToken, error) {
162+
func (t *Tmpauth) ParseAuthJWT(tokenStr string, wrappedToken string, minValidationTime time.Time) (*CachedToken, error) {
163163
if t.miniServerHost != "" {
164164
return nil, errors.New("tmpauth: mini server endpoint is set, cannot parse auth JWTs")
165165
}
@@ -258,7 +258,7 @@ func (t *Tmpauth) ParseAuthJWT(tokenStr string, minValidationTime time.Time) (*C
258258
IssuedAt: iat,
259259
StateID: stateID,
260260
ValidatedAt: minValidationTime,
261-
RawToken: tokenStr,
261+
RawToken: wrappedToken,
262262
headersMutex: new(sync.RWMutex),
263263
}
264264

0 commit comments

Comments
 (0)