mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-11-04 07:53:59 +00:00
fix(security): classify audience failures by sentinel error
The lenient-audience path chose itself when the verify error text contained the word audience. The key lookup error embeds the kid from the unverified token header. A kid of audience made a failed signature look like an audience-only failure. verifyAudience now returns a sentinel and the caller uses errors.Is.
This commit is contained in:
@@ -15,6 +15,7 @@ package traefikoidc
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -266,8 +267,7 @@ func (t *TraefikOidc) validateStandardTokensRS(rs *requestState) (bool, bool, bo
|
||||
var accessVerifyErr error
|
||||
if err := t.verifyToken(rs.accessToken); err != nil {
|
||||
accessVerifyErr = err
|
||||
errMsg := err.Error()
|
||||
if strings.Contains(errMsg, "invalid audience") || strings.Contains(errMsg, "audience") {
|
||||
if errors.Is(err, errInvalidAudience) {
|
||||
if t.strictAudienceValidation {
|
||||
if rs.refreshToken != "" {
|
||||
return false, true, false
|
||||
|
||||
Reference in New Issue
Block a user