Skip to content

Commit

Permalink
Backport of Allow service identity tokens the ability to read jwt-pro…
Browse files Browse the repository at this point in the history
…viders into release/1.16.x (#17896)

* backport of commit 72308dd

* backport of commit bf5d1ec

* backport of commit 4ca2e4b

---------

Co-authored-by: Ronald Ekambi <ronekambi@gmail.com>
  • Loading branch information
1 parent 02e895e commit c689713
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions agent/structs/config_entry_jwt_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ func (e *JWTProviderConfigEntry) GetRaftIndex() *RaftIndex { retur
func (e *JWTProviderConfigEntry) CanRead(authz acl.Authorizer) error {
var authzContext acl.AuthorizerContext
e.FillAuthzContext(&authzContext)

// allow service-identity tokens the ability to read jwt-providers
// this is a workaround to allow sidecar proxies to read the jwt-providers
// see issue: https://github.com/hashicorp/consul/issues/17886 for more details
err := authz.ToAllowAuthorizer().ServiceWriteAnyAllowed(&authzContext)
if err == nil {
return err
}

return authz.ToAllowAuthorizer().MeshReadAllowed(&authzContext)
}

Expand Down
18 changes: 18 additions & 0 deletions agent/structs/config_entry_jwt_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,24 @@ func TestJWTProviderConfigEntry_ACLs(t *testing.T) {
canRead: false,
canWrite: false,
},
{
name: "jwt-provider: any service write",
authorizer: newTestAuthz(t, `service "" { policy = "write" }`),
canRead: true,
canWrite: false,
},
{
name: "jwt-provider: specific service write",
authorizer: newTestAuthz(t, `service "web" { policy = "write" }`),
canRead: true,
canWrite: false,
},
{
name: "jwt-provider: any service prefix write",
authorizer: newTestAuthz(t, `service_prefix "" { policy = "write" }`),
canRead: true,
canWrite: false,
},
{
name: "jwt-provider: mesh read",
authorizer: newTestAuthz(t, `mesh = "read"`),
Expand Down

0 comments on commit c689713

Please sign in to comment.