Skip to content

Commit 9104b5f

Browse files
fix(authz): assign identity to authz context in tls mutual authentication
this causes a bug in extensions by not having the identity for the authenticated user and couldn't apply his permissions, just the default ones. Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
1 parent aab1496 commit 9104b5f

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/api/authz.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ func AuthzHandler(ctlr *Controller) mux.MiddlewareFunc {
279279

280280
return
281281
}
282+
283+
// assign identity to authz context, needed for extensions
284+
acCtx.Username = identity
282285
}
283286
}
284287

pkg/api/controller_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,11 +1370,22 @@ func TestMutualTLSAuthWithUserPermissions(t *testing.T) {
13701370
So(resp, ShouldNotBeNil)
13711371
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
13721372

1373+
resp, err = resty.R().Get(secureBaseURL + "/v2/_catalog")
1374+
So(err, ShouldBeNil)
1375+
So(resp, ShouldNotBeNil)
1376+
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
1377+
13731378
// with creds, should get expected status code
13741379
resp, _ = resty.R().Get(secureBaseURL)
13751380
So(resp, ShouldNotBeNil)
13761381
So(resp.StatusCode(), ShouldEqual, http.StatusNotFound)
13771382

1383+
// reading a repo should not get 403
1384+
resp, err = resty.R().Get(secureBaseURL + "/v2/repo/tags/list")
1385+
So(err, ShouldBeNil)
1386+
So(resp, ShouldNotBeNil)
1387+
So(resp.StatusCode(), ShouldEqual, http.StatusNotFound)
1388+
13781389
// without creds, writes should fail
13791390
resp, err = resty.R().Post(secureBaseURL + "/v2/repo/blobs/uploads/")
13801391
So(err, ShouldBeNil)

0 commit comments

Comments
 (0)