Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the Settings page to actually save OIDC flows #1492

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/api/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def service_params
end

def proxy_params
oidc_params = %i[oidc_issuer_type oidc_issuer_endpoint jwt_claim_with_client_id jwt_claim_with_client_id_type] + OIDCConfiguration::Config::FLOWS
oidc_params = [:oidc_issuer_type, :oidc_issuer_endpoint, :jwt_claim_with_client_id, :jwt_claim_with_client_id_type, oidc_configuration_attributes: OIDCConfiguration::Config::FLOWS]
permitted_params = oidc_params + %i[
auth_user_key auth_app_id auth_app_key credentials_location hostname_rewrite secret_token
error_status_auth_failed error_headers_auth_failed error_auth_failed
Expand Down
26 changes: 26 additions & 0 deletions test/integration/api/services_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,32 @@ class SettingsTest < Api::ServicesControllerTest
assert_equal 'https://new.backend:443', proxy.reload.api_backend
end

test 'updates oidc settings' do
Account.any_instance.stubs(:provider_can_use?).returns(true)
rolling_update(:api_as_product, enabled: true)

oidc_params = {
oidc_issuer_type: 'keycloak',
oidc_issuer_endpoint: 'http://u:p@localhost:8080/auth/realms/my-realm',
oidc_configuration_attributes: {
standard_flow_enabled: '1',
implicit_flow_enabled: '1',
service_accounts_enabled: '0',
direct_access_grants_enabled: '0'
}
}

put admin_service_path(service), update_params.deep_merge(service: { proxy_attributes: oidc_params })

proxy = service.proxy.reload

assert_equal 'keycloak', proxy.oidc_issuer_type
assert_equal 'http://u:p@localhost:8080/auth/realms/my-realm', proxy.oidc_issuer_endpoint

oidc_expected_flows = oidc_params[:oidc_configuration_attributes].transform_values { |value| ActiveRecord::Type::Boolean.new.type_cast_from_user(value) }
assert_equal oidc_expected_flows, proxy.oidc_configuration.config.attributes.symbolize_keys
end

private

def update_params
Expand Down