Sha256: 5ab0773b99e7281ee9a755e82304b3e5a94e83df1106cc386aa495c95c554e9c

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ImportCommand
      module OpenAPI
        class UpdateServiceOidcConfStep
          include Step

          ##
          # Updates OIDC config
          def call
            # setting required attrs, operation is idempotent
            oidc_settings = {}

            add_flow_settings(oidc_settings)

            return unless oidc_settings.size.positive?

            res = service.update_oidc oidc_settings
            if (errors = res['errors'])
              raise ThreeScaleToolbox::Error, "Service oidc has not been updated. #{errors}"
            end

            puts 'Service oidc updated'
          end

          private

          def add_flow_settings(settings)
            # only applies to oauth2 sec type
            return if api_spec.security.nil? || api_spec.security[:type] != 'oauth2'

            oidc_configuration = {
              standard_flow_enabled: false,
              implicit_flow_enabled: false,
              service_accounts_enabled: false,
              direct_access_grants_enabled: false
            }.merge(api_spec.security[:flow] => true)
            settings.merge!(oidc_configuration)
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
3scale_toolbox-0.19.3 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
3scale_toolbox-0.15.0 lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb