Token service handling invalid resource (#12790)

This commit updates the way token service handles invalid resource, for
example a resource without projectname.
It will clear the requested access instead of returning 500 error.

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
Daniel Jiang 2020-08-18 10:37:20 +08:00 committed by GitHub
parent 89b597a811
commit 77281ca68b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,7 +94,9 @@ func filterAccess(access []*token.ResourceActions, ctx security.Context,
err = f.filter(ctx, pm, a) err = f.filter(ctx, pm, a)
log.Debugf("user: %s, access: %v", ctx.GetUsername(), a) log.Debugf("user: %s, access: %v", ctx.GetUsername(), a)
if err != nil { if err != nil {
return err log.Errorf("Failed to handle the resource %s:%s, due to error %v, returning empty access for it.",
a.Type, a.Name, err)
a.Actions = []string{}
} }
} }
return nil return nil