give the username to anonymous when to pull public resource without authN (#11306)

For pull a public resource, there is no need to login, give the access name to anonymous in the audit logs

Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
Wang Yan 2020-03-27 10:24:59 +08:00 committed by GitHub
parent 48df949c30
commit a5c1eae81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,6 +168,13 @@ func (p *PullArtifactEvent) ResolveToAuditLog() (*model.AuditLog, error) {
p.Artifact.RepositoryName, p.Tags[0])
}
// for pull public resource
if p.Operator == "" {
auditLog.Username = "anonymous"
} else {
auditLog.Username = p.Operator
}
return auditLog, nil
}