Skip to content

Commit

Permalink
[Automate-2950] Port introspection from v1 to v2 (#3032)
Browse files Browse the repository at this point in the history
* Relocate introspection protos to v2

Signed-off-by: michael sorens <[email protected]>

* Rewire proto files together

Signed-off-by: michael sorens <[email protected]>

* Change exposed endpoints to v2

Signed-off-by: michael sorens <[email protected]>

* Regenerate from protos

Signed-off-by: michael sorens <[email protected]>

* Relocate introspection endpoints to v2

Signed-off-by: michael sorens <[email protected]>

* Rewire go files together

Signed-off-by: michael sorens <[email protected]>

* Change UI calls to v2

Signed-off-by: michael sorens <[email protected]>

* Convert v1 integration test to v2

Signed-off-by: michael sorens <[email protected]>

* Resolve path changes in cli component

Starting with ` rebuild components/automate-cli/`, the error was:

build github.com/chef/automate/components/automate-gateway/api/authz:
    cannot load github.com/chef/automate/components/automate-gateway/api/authz:
    no Go source files

Traced that back to the same failure with just `make build`
in the automate-cli directory, then to the same failure with just this:

go build github.com/chef/automate/components/automate-cli/cmd/chef-automate

Searching for api/authz in the cli directory led me to the files in this commit.

Signed-off-by: michael sorens <[email protected]>

* Regenerate bldr.toml

The "repo health" task in buildkite failed saying:
```
The bldr config appears to be out of date!
To fix this, run:
   hab studio run "source .studiorc && generate_bldr_config"
```

Ran the fix:
# install_if_missing core/go go
# generate_bldr_config

Signed-off-by: michael sorens <[email protected]>

* Delete v1 auth URL in UI

Signed-off-by: michael sorens <[email protected]>

* Replace auth_v2_url with iam_url in UI

Signed-off-by: michael sorens <[email protected]>

* Apply assorted review feedback

Signed-off-by: michael sorens <[email protected]>
  • Loading branch information
msorens authored Mar 5, 2020
1 parent a782245 commit 7e5bd56
Show file tree
Hide file tree
Showing 42 changed files with 360 additions and 348 deletions.
22 changes: 22 additions & 0 deletions .bldr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ paths = [
"api/config/shared/*",
"api/interservice/pg_sidecar/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"components/pg-sidecar-service/*",
Expand Down Expand Up @@ -108,6 +109,7 @@ paths = [
"api/interservice/cereal/*",
"api/interservice/teams/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/authz/*",
Expand Down Expand Up @@ -177,6 +179,7 @@ paths = [
"api/interservice/cereal/*",
"api/interservice/event/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/authz/*",
Expand Down Expand Up @@ -262,6 +265,7 @@ paths = [
"api/interservice/authn/*",
"api/interservice/authz/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/grpc/*",
Expand Down Expand Up @@ -484,6 +488,7 @@ paths = [
"api/interservice/nodemanager/*",
"components/authz-service/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"components/event-service/*",
Expand Down Expand Up @@ -581,6 +586,7 @@ paths = [
"api/interservice/cfgmgmt/*",
"components/authz-service/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"components/ingest-service/*",
Expand Down Expand Up @@ -827,6 +833,7 @@ paths = [
"components/authz-service/*",
"components/automate-cli/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"components/config-mgmt-service/*",
Expand Down Expand Up @@ -919,6 +926,7 @@ paths = [
"components/es-sidecar-service/*",
"api/interservice/es_sidecar/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/grpc/*",
Expand Down Expand Up @@ -970,6 +978,7 @@ paths = [
"api/config/shared/*",
"api/interservice/pg_sidecar/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/db/*",
Expand Down Expand Up @@ -1038,6 +1047,7 @@ paths = [
"api/interservice/event_feed/*",
"api/interservice/ingest/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/grpc/*",
Expand Down Expand Up @@ -1108,6 +1118,7 @@ paths = [
"api/external/habitat/*",
"api/interservice/cereal/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/cereal/*",
Expand Down Expand Up @@ -1223,6 +1234,7 @@ paths = [
"api/interservice/nodemanager/*",
"components/authz-service/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"components/compliance-service/*",
Expand Down Expand Up @@ -1318,6 +1330,7 @@ paths = [
"api/interservice/ingest/*",
"api/interservice/nodemanager/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"components/event-service/*",
Expand Down Expand Up @@ -1384,6 +1397,7 @@ paths = [
"api/config/shared/*",
"api/interservice/license_control/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/db/*",
Expand Down Expand Up @@ -1444,6 +1458,7 @@ paths = [
"api/interservice/local_user/*",
"api/interservice/teams/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/grpc/*",
Expand Down Expand Up @@ -1496,6 +1511,7 @@ paths = [
"api/external/common/*",
"api/external/secrets/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/db/*",
Expand Down Expand Up @@ -1560,6 +1576,7 @@ paths = [
"api/config/platform/*",
"api/config/shared/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/db/*",
Expand Down Expand Up @@ -1631,6 +1648,7 @@ paths = [
"api/interservice/cereal/*",
"api/interservice/teams/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/authz/*",
Expand Down Expand Up @@ -1788,6 +1806,7 @@ paths = [
"api/interservice/cfgmgmt/*",
"api/interservice/compliance/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"components/config-mgmt-service/*",
Expand Down Expand Up @@ -1861,6 +1880,7 @@ paths = [
"api/interservice/event/*",
"api/interservice/event_feed/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/authz/*",
Expand Down Expand Up @@ -1914,6 +1934,7 @@ paths = [
"api/config/shared/*",
"api/interservice/cereal/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/cereal/*",
Expand Down Expand Up @@ -1972,6 +1993,7 @@ paths = [
"api/external/secrets/*",
"api/interservice/infra_proxy/*",
"components/automate-gateway/api/authz/*",
"components/automate-gateway/api/iam/*",
"components/automate-gateway/authz/policy_v2/*",
"components/automate-grpc/*",
"lib/db/*",
Expand Down
7 changes: 3 additions & 4 deletions components/automate-cli/pkg/client/apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
client_type "github.com/chef/automate/components/automate-cli/pkg/client"
"github.com/chef/automate/components/automate-cli/pkg/status"
"github.com/chef/automate/components/automate-deployment/pkg/constants"
"github.com/chef/automate/components/automate-gateway/api/authz"
iam "github.com/chef/automate/components/automate-gateway/api/iam/v2"
"github.com/chef/automate/lib/grpc/secureconn"
"github.com/chef/automate/lib/tls/certs"
Expand All @@ -19,7 +18,7 @@ import (
type client struct {
apiClientConn *grpc.ClientConn
// TODO (tc): Add other service clients here as needed.
authzClient authz.AuthorizationClient
authzClient iam.AuthorizationClient
teamsClient iam.TeamsClient
tokensClient iam.TokensClient
usersClient iam.UsersClient
Expand Down Expand Up @@ -51,7 +50,7 @@ func OpenConnection(ctx context.Context) (client_type.APIClient, error) {
return client{
apiClientConn: apiClientConn,
// TODO (tc): Add other service clients here as needed.
authzClient: authz.NewAuthorizationClient(apiClientConn),
authzClient: iam.NewAuthorizationClient(apiClientConn),
teamsClient: iam.NewTeamsClient(apiClientConn),
tokensClient: iam.NewTokensClient(apiClientConn),
usersClient: iam.NewUsersClient(apiClientConn),
Expand All @@ -61,7 +60,7 @@ func OpenConnection(ctx context.Context) (client_type.APIClient, error) {
}, nil
}

func (c client) AuthzClient() authz.AuthorizationClient {
func (c client) AuthzClient() iam.AuthorizationClient {
return c.authzClient
}

Expand Down
13 changes: 6 additions & 7 deletions components/automate-cli/pkg/client/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/chef/automate/api/external/applications"
"github.com/chef/automate/api/external/compliance/reporting"
"github.com/chef/automate/components/automate-cli/pkg/client"
"github.com/chef/automate/components/automate-gateway/api/authz"
iam "github.com/chef/automate/components/automate-gateway/api/iam/v2"
"github.com/chef/automate/lib/grpc/grpctest"
"github.com/chef/automate/lib/grpc/secureconn"
Expand All @@ -17,7 +16,7 @@ import (

// Mock is a mocked out APIClient.
type Mock struct {
authzClient authz.AuthorizationClient
authzClient iam.AuthorizationClient
teamsClient iam.TeamsClient
tokensClient iam.TokensClient
usersClient iam.UsersClient
Expand All @@ -29,7 +28,7 @@ type Mock struct {

// ServerMocks are mocked out API servers
type ServerMocks struct {
AuthzMock *authz.AuthorizationServerMock
AuthzMock *iam.AuthorizationServerMock
PoliciesMock *iam.PoliciesServerMock
TeamsMock *iam.TeamsServerMock
TokensMock *iam.TokensServerMock
Expand All @@ -44,8 +43,8 @@ func CreateMockConn(t *testing.T) (client.APIClient, ServerMocks, error) {
connFactory := secureconn.NewFactory(*deployCerts)
grpcGateway := connFactory.NewServer()

mockAuthz := authz.NewAuthorizationServerMock()
authz.RegisterAuthorizationServer(grpcGateway, mockAuthz)
mockAuthz := iam.NewAuthorizationServerMock()
iam.RegisterAuthorizationServer(grpcGateway, mockAuthz)

mockTokens := iam.NewTokensServerMock()
iam.RegisterTokensServer(grpcGateway, mockTokens)
Expand All @@ -64,7 +63,7 @@ func CreateMockConn(t *testing.T) (client.APIClient, ServerMocks, error) {
require.NoError(t, err)

return Mock{
authzClient: authz.NewAuthorizationClient(gatewayConn),
authzClient: iam.NewAuthorizationClient(gatewayConn),
teamsClient: iam.NewTeamsClient(gatewayConn),
tokensClient: iam.NewTokensClient(gatewayConn),
usersClient: iam.NewUsersClient(gatewayConn),
Expand All @@ -84,7 +83,7 @@ func CreateMockConn(t *testing.T) (client.APIClient, ServerMocks, error) {
}

// AuthzClient returns mock AuthzClient
func (c Mock) AuthzClient() authz.AuthorizationClient {
func (c Mock) AuthzClient() iam.AuthorizationClient {
return c.authzClient
}

Expand Down
3 changes: 1 addition & 2 deletions components/automate-cli/pkg/client/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package client
import (
"github.com/chef/automate/api/external/applications"
"github.com/chef/automate/api/external/compliance/reporting"
"github.com/chef/automate/components/automate-gateway/api/authz"
iam "github.com/chef/automate/components/automate-gateway/api/iam/v2"
)

// APIClient is an API client ready for making requests against our public API.
// The client will auth via the deployment-service cert, which has a system level
// policy granting it universal access to our API.
type APIClient interface {
AuthzClient() authz.AuthorizationClient
AuthzClient() iam.AuthorizationClient
TeamsClient() iam.TeamsClient
TokensClient() iam.TokensClient
UsersClient() iam.UsersClient
Expand Down
9 changes: 4 additions & 5 deletions components/automate-gateway/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import (
_ "github.com/chef/automate/api/external/cfgmgmt"
_ "github.com/chef/automate/api/external/common/query"
_ "github.com/chef/automate/api/external/common/version"
_ "github.com/chef/automate/api/external/nodes"
_ "github.com/chef/automate/api/external/nodes/manager"
_ "github.com/chef/automate/api/external/secrets"
_ "github.com/chef/automate/components/automate-gateway/api/auth/teams"
_ "github.com/chef/automate/components/automate-gateway/api/authz"
_ "github.com/chef/automate/api/external/compliance/profiles"
_ "github.com/chef/automate/api/external/compliance/reporting"
_ "github.com/chef/automate/api/external/compliance/reporting/stats"
_ "github.com/chef/automate/api/external/compliance/scanner/jobs"
_ "github.com/chef/automate/api/external/nodes"
_ "github.com/chef/automate/api/external/nodes/manager"
_ "github.com/chef/automate/api/external/secrets"
_ "github.com/chef/automate/components/automate-gateway/api/auth/teams"
_ "github.com/chef/automate/components/automate-gateway/api/deployment"
_ "github.com/chef/automate/components/automate-gateway/api/event_feed"
_ "github.com/chef/automate/components/automate-gateway/api/gateway"
Expand Down
31 changes: 0 additions & 31 deletions components/automate-gateway/api/authz/authz.pb.policy-v1.go

This file was deleted.

31 changes: 0 additions & 31 deletions components/automate-gateway/api/authz/authz.pb.policy-v2.go

This file was deleted.

2 changes: 1 addition & 1 deletion components/automate-gateway/api/authz/pairs/pairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

gwAuthzRes "github.com/chef/automate/components/automate-gateway/api/authz/response"
gwAuthzRes "github.com/chef/automate/components/automate-gateway/api/iam/v2/response"
)

// FindStringSubmatch returns an array.
Expand Down
Loading

0 comments on commit 7e5bd56

Please sign in to comment.