mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-22 23:51:27 +01:00
Reduce warning logs in OIDC middleware
If the request does not have bearer token in the header, do not decode the empty string. Fixes #12261 Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
parent
9574f8c3c6
commit
2dd499bacf
@ -40,6 +40,9 @@ func (i *idToken) Generate(req *http.Request) security.Context {
|
||||
return nil
|
||||
}
|
||||
token := bearerToken(req)
|
||||
if len(token) == 0 {
|
||||
return nil
|
||||
}
|
||||
claims, err := oidc.VerifyToken(ctx, token)
|
||||
if err != nil {
|
||||
log.Warningf("failed to verify token: %v", err)
|
||||
|
@ -15,12 +15,13 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/lib"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIDToken(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user