fix: check get origins and projectID only for tokens with clientID (#2378)

This commit is contained in:
Livio Amstutz 2021-09-16 10:07:48 +02:00 committed by GitHub
parent db3526df48
commit f39ff13acb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,10 +73,14 @@ func VerifyTokenAndCreateCtxData(ctx context.Context, token, orgID string, t *To
if err != nil { if err != nil {
return CtxData{}, err return CtxData{}, err
} }
projectID, origins, err := t.ProjectIDAndOriginsByClientID(ctx, clientID) var projectID string
var origins []string
if clientID != "" {
projectID, origins, err = t.ProjectIDAndOriginsByClientID(ctx, clientID)
if err != nil { if err != nil {
return CtxData{}, errors.ThrowPermissionDenied(err, "AUTH-GHpw2", "could not read projectid by clientid") return CtxData{}, errors.ThrowPermissionDenied(err, "AUTH-GHpw2", "could not read projectid by clientid")
} }
}
if err := checkOrigin(ctx, origins); err != nil { if err := checkOrigin(ctx, origins); err != nil {
return CtxData{}, err return CtxData{}, err
} }