Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions central/auth/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/stackrox/rox/central/auth/datastore"
v1 "github.com/stackrox/rox/generated/api/v1"
"github.com/stackrox/rox/pkg/features"
"github.com/stackrox/rox/pkg/grpc"
"github.com/stackrox/rox/pkg/sync"
)
Expand All @@ -27,11 +26,7 @@ type Service interface {
// Singleton returns a new auth service instance.
func Singleton() Service {
once.Do(func() {
svc := &serviceImpl{}
if features.AuthMachineToMachine.Enabled() {
svc.authDataStore = datastore.Singleton()
}
s = svc
s = &serviceImpl{authDataStore: datastore.Singleton()}
})
return s
}
26 changes: 0 additions & 26 deletions central/auth/service/service_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/stackrox/rox/pkg/auth/permissions"
userPkg "github.com/stackrox/rox/pkg/auth/user"
"github.com/stackrox/rox/pkg/errox"
"github.com/stackrox/rox/pkg/features"
"github.com/stackrox/rox/pkg/grpc/authn"
"github.com/stackrox/rox/pkg/grpc/authz"
"github.com/stackrox/rox/pkg/grpc/authz/allow"
Expand Down Expand Up @@ -136,10 +135,6 @@ func authStatusForID(id authn.Identity) (*v1.AuthStatus, error) {
}

func (s *serviceImpl) ListAuthMachineToMachineConfigs(ctx context.Context, _ *v1.Empty) (*v1.ListAuthMachineToMachineConfigResponse, error) {
if !features.AuthMachineToMachine.Enabled() {
return nil, m2mFeatureDisabledError()
}

var storageConfigs []*storage.AuthMachineToMachineConfig
err := s.authDataStore.ForEachAuthM2MConfig(ctx, func(c *storage.AuthMachineToMachineConfig) error {
storageConfigs = append(storageConfigs, c)
Expand All @@ -153,9 +148,6 @@ func (s *serviceImpl) ListAuthMachineToMachineConfigs(ctx context.Context, _ *v1
}

func (s *serviceImpl) GetAuthMachineToMachineConfig(ctx context.Context, id *v1.ResourceByID) (*v1.GetAuthMachineToMachineConfigResponse, error) {
if !features.AuthMachineToMachine.Enabled() {
return nil, m2mFeatureDisabledError()
}
config, exists, err := s.authDataStore.GetAuthM2MConfig(ctx, id.GetId())
if err != nil {
return nil, err
Expand All @@ -167,9 +159,6 @@ func (s *serviceImpl) GetAuthMachineToMachineConfig(ctx context.Context, id *v1.
}

func (s *serviceImpl) AddAuthMachineToMachineConfig(ctx context.Context, request *v1.AddAuthMachineToMachineConfigRequest) (*v1.AddAuthMachineToMachineConfigResponse, error) {
if !features.AuthMachineToMachine.Enabled() {
return nil, m2mFeatureDisabledError()
}
config := request.GetConfig()
resolveGitHubActionsIssuer(config)
if err := s.validateAuthMachineToMachineConfig(config, true); err != nil {
Expand All @@ -185,9 +174,6 @@ func (s *serviceImpl) AddAuthMachineToMachineConfig(ctx context.Context, request
}

func (s *serviceImpl) UpdateAuthMachineToMachineConfig(ctx context.Context, request *v1.UpdateAuthMachineToMachineConfigRequest) (*v1.Empty, error) {
if !features.AuthMachineToMachine.Enabled() {
return nil, m2mFeatureDisabledError()
}
config := request.GetConfig()
resolveGitHubActionsIssuer(config)
if err := s.validateAuthMachineToMachineConfig(config, false); err != nil {
Expand All @@ -202,9 +188,6 @@ func (s *serviceImpl) UpdateAuthMachineToMachineConfig(ctx context.Context, requ
}

func (s *serviceImpl) DeleteAuthMachineToMachineConfig(ctx context.Context, id *v1.ResourceByID) (*v1.Empty, error) {
if !features.AuthMachineToMachine.Enabled() {
return nil, m2mFeatureDisabledError()
}
if err := s.authDataStore.RemoveAuthM2MConfig(ctx, id.GetId()); err != nil {
return nil, errox.InvalidArgs.
Newf("could not delete auth machine to machine config with id %q", id.GetId()).CausedBy(err)
Expand All @@ -214,10 +197,6 @@ func (s *serviceImpl) DeleteAuthMachineToMachineConfig(ctx context.Context, id *

func (s *serviceImpl) ExchangeAuthMachineToMachineToken(ctx context.Context,
req *v1.ExchangeAuthMachineToMachineTokenRequest) (*v1.ExchangeAuthMachineToMachineTokenResponse, error) {
if !features.AuthMachineToMachine.Enabled() {
return nil, m2mFeatureDisabledError()
}

rawIDToken := req.GetIdToken()

issuer, err := m2m.IssuerFromRawIDToken(rawIDToken)
Expand Down Expand Up @@ -312,8 +291,3 @@ func resolveGitHubActionsIssuer(config *v1.AuthMachineToMachineConfig) {
config.Issuer = githubActionsIssuer
}
}

func m2mFeatureDisabledError() error {
return errox.InvariantViolation.New("auth machine to machine feature is not currently not " +
"enabled, set ROX_AUTH_MACHINE_TO_MACHINE=true to enable it")
}
3 changes: 0 additions & 3 deletions central/auth/service/service_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
tokensMocks "github.com/stackrox/rox/pkg/auth/tokens/mocks"
"github.com/stackrox/rox/pkg/defaults/accesscontrol"
"github.com/stackrox/rox/pkg/errox"
"github.com/stackrox/rox/pkg/features"
"github.com/stackrox/rox/pkg/grpc/authn/basic"
"github.com/stackrox/rox/pkg/postgres/pgtest"
"github.com/stackrox/rox/pkg/protoassert"
Expand Down Expand Up @@ -75,8 +74,6 @@ type authServiceAccessControlTestSuite struct {
}

func (s *authServiceAccessControlTestSuite) SetupSuite() {
s.T().Setenv(features.AuthMachineToMachine.EnvVar(), "true")

authProvider, err := authproviders.NewProvider(
authproviders.WithEnabled(true),
authproviders.WithID(uuid.NewDummy().String()),
Expand Down
3 changes: 0 additions & 3 deletions pkg/features/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ var (
// SensorReconciliationOnReconnect enables sensors to support reconciliation when reconnecting
SensorReconciliationOnReconnect = registerFeature("Enable Sensors to support reconciliation on reconnect", "ROX_SENSOR_RECONCILIATION", enabled)

// AuthMachineToMachine allows to exchange ID tokens for Central tokens without requiring user interaction.
AuthMachineToMachine = registerFeature("Enable Auth Machine to Machine functionalities", "ROX_AUTH_MACHINE_TO_MACHINE", enabled)

// PolicyCriteriaModal enables a modal for selecting policy criteria when editing a policy
PolicyCriteriaModal = registerFeature("Enable modal to select policy criteria when editing a policy", "ROX_POLICY_CRITERIA_MODAL")

Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export_test_environment() {
ci_export ROX_COMPLIANCE_ENHANCEMENTS "${ROX_COMPLIANCE_ENHANCEMENTS:-true}"
ci_export ROX_POLICY_CRITERIA_MODAL "${ROX_POLICY_CRITERIA_MODAL:-true}"
ci_export ROX_TELEMETRY_STORAGE_KEY_V1 "DISABLED"
ci_export ROX_AUTH_MACHINE_TO_MACHINE "${ROX_AUTH_MACHINE_TO_MACHINE:-true}"
ci_export ROX_COMPLIANCE_REPORTING "${ROX_COMPLIANCE_REPORTING:-true}"
ci_export ROX_REGISTRY_RESPONSE_TIMEOUT "${ROX_REGISTRY_RESPONSE_TIMEOUT:-90s}"
ci_export ROX_REGISTRY_CLIENT_TIMEOUT "${ROX_REGISTRY_CLIENT_TIMEOUT:-120s}"
Expand Down Expand Up @@ -307,8 +306,6 @@ deploy_central_via_operator() {
customize_envVars+=$'\n value: "15s"'
customize_envVars+=$'\n - name: ROX_COMPLIANCE_ENHANCEMENTS'
customize_envVars+=$'\n value: "true"'
customize_envVars+=$'\n - name: ROX_AUTH_MACHINE_TO_MACHINE'
customize_envVars+=$'\n value: "true"'
customize_envVars+=$'\n - name: ROX_COMPLIANCE_REPORTING'
customize_envVars+=$'\n value: "true"'
customize_envVars+=$'\n - name: ROX_REGISTRY_RESPONSE_TIMEOUT'
Expand Down
Loading