default policy only authorization

unit tests for manifest integrity when updating

Signed-off-by: laurentiuNiculae <themelopeus@gmail.com>
This commit is contained in:
laurentiuNiculae
2022-03-10 14:25:15 +02:00
committed by Ramkumar Chinchani
parent e1a1bdff1a
commit bb95af5b4d
7 changed files with 417 additions and 12 deletions
+9 -2
View File
@@ -180,7 +180,14 @@ func AuthzHandler(ctlr *Controller) mux.MiddlewareFunc {
}
acCtrlr := NewAccessController(ctlr.Config)
username := getUsername(request)
// allow anonymous authz if no authn present and only default policies are present
username := ""
if isAuthnEnabled(ctlr.Config) {
username = getUsername(request)
}
ctx := acCtrlr.getContext(username, request)
// will return only repos on which client is authorized to read
@@ -202,7 +209,7 @@ func AuthzHandler(ctlr *Controller) mux.MiddlewareFunc {
if ok {
is := ctlr.StoreController.GetImageStore(resource)
tags, err := is.GetImageTags(resource)
// if repo exists and request's tag doesn't exist yet then action is UPDATE
// if repo exists and request's tag exists then action is UPDATE
if err == nil && common.Contains(tags, reference) && reference != "latest" {
action = UPDATE
}