Merge pull request #14116 from reasonerjt/reduce-oidc-warning

Reduce warning logs in OIDC middleware
This commit is contained in:
Wenkai Yin(尹文开) 2021-02-01 09:55:41 +08:00 committed by GitHub
commit 120d88a0dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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) {