Captain-P-Goldfish/scim-for-keycloak

SCIM Proxy settings in GUI is not being persisted

Opened this issue · 2 comments

image

then reload the page
it gets back to
image

and if you forget about it and click save (if you change something) then it stops working with errors in the log:

2024-11-10 01:22:36,442 WARN  [de.captaingoldfish.scim.sdk.keycloak.scim_client.ScimClientSynchronizer] (executor-thread-24) The synchronization task to the remote-provider for user 'test-user-test1' has failed.
2024-11-10 01:22:36,442 ERROR [de.captaingoldfish.scim.sdk.keycloak.scim_client.ScimClientSynchronizer] (executor-thread-24) communication with server failed: de.captaingoldfish.scim.sdk.client.exceptions.IORuntimeException: communication with server failed
	at de.captaingoldfish.scim.sdk.client.http.ScimHttpClient.sendRequest(ScimHttpClient.java:224)
	at de.captaingoldfish.scim.sdk.client.builder.RequestBuilder.sendRequestWithMultiHeaders(RequestBuilder.java:133)
	at de.captaingoldfish.scim.sdk.client.builder.RequestBuilder.sendRequest(RequestBuilder.java:113)
	at de.captaingoldfish.scim.sdk.client.builder.CreateBuilder.sendRequest(CreateBuilder.java:89)
	at de.captaingoldfish.scim.sdk.keycloak.scim_client.synchrotasks.users.ScimCreateUserTask.synchronize(ScimCreateUserTask.java:89)
	at de.captaingoldfish.scim.sdk.keycloak.scim_client.ScimClientSynchronizer.lambda$addUserCreateTask$4(ScimClientSynchronizer.java:710)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at de.captaingoldfish.scim.sdk.keycloak.scim_client.ScimClientSynchronizer.lambda$addUserCreateTask$5(ScimClientSynchronizer.java:704)
	at org.keycloak.models.utils.KeycloakModelUtils.lambda$runJobInTransaction$1(KeycloakModelUtils.java:274)
	at org.keycloak.models.utils.KeycloakModelUtils.runJobInTransactionWithResult(KeycloakModelUtils.java:393)
	at org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:273)
	at org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:263)
	at de.captaingoldfish.scim.sdk.keycloak.scim_client.ScimClientSynchronizer.runJobInTransaction(ScimClientSynchronizer.java:261)
	at de.captaingoldfish.scim.sdk.keycloak.scim_client.ScimClientSynchronizer.addUserCreateTask(ScimClientSynchronizer.java:719)
	at de.captaingoldfish.scim.sdk.keycloak.scim_client.hibernate.ScimPostCommitInsertEventListener.onPostInsert(ScimPostCommitInsertEventListener.java:50)
	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireLazyEventOnEachListener(EventListenerGroupImpl.java:116)
	at org.hibernate.action.internal.EntityInsertAction.postCommitInsert(EntityInsertAction.java:227)
	at org.hibernate.action.internal.EntityInsertAction.doAfterTransactionCompletion(EntityInsertAction.java:274)
	at org.hibernate.engine.spi.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:1058)
	at org.hibernate.engine.spi.ActionQueue.afterTransactionCompletion(ActionQueue.java:545)
	at org.hibernate.internal.SessionImpl.afterTransactionCompletion(SessionImpl.java:1997)
	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.afterTransactionCompletion(JdbcCoordinatorImpl.java:446)
	at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.afterCompletion(JtaTransactionCoordinatorImpl.java:361)
	at org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackCoordinatorNonTrackingImpl.doAfterCompletion(SynchronizationCallbackCoordinatorNonTrackingImpl.java:60)
	at org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackCoordinatorTrackingImpl.afterCompletion(SynchronizationCallbackCoordinatorTrackingImpl.java:72)
	at org.hibernate.resource.transaction.backend.jta.internal.synchronization.RegisteredSynchronization.afterCompletion(RegisteredSynchronization.java:44)
	at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.afterCompletion(SynchronizationImple.java:72)
	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:537)
	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:76)
	at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:135)
	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1290)
	at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:104)
	at io.quarkus.narayana.jta.runtime.NotifyingTransactionManager.commit(NotifyingTransactionManager.java:70)
	at org.keycloak.transaction.JtaTransactionWrapper.commit(JtaTransactionWrapper.java:100)
	at org.keycloak.services.DefaultKeycloakTransactionManager.commit(DefaultKeycloakTransactionManager.java:136)
	at org.keycloak.services.DefaultKeycloakSession.closeTransactionManager(DefaultKeycloakSession.java:396)
	at org.keycloak.services.DefaultKeycloakSession.close(DefaultKeycloakSession.java:361)
	at org.keycloak.models.KeycloakBeanProducer_ProducerMethod_getKeycloakSession_XoSEUTXOsE3bpqXlGMAykCiECUM_ClientProxy.close(Unknown Source)
	at org.keycloak.quarkus.runtime.transaction.TransactionalSessionHandler.close(TransactionalSessionHandler.java:60)
	at org.keycloak.quarkus.runtime.integration.jaxrs.CloseSessionFilter.closeSession(CloseSessionFilter.java:67)
	at org.keycloak.quarkus.runtime.integration.jaxrs.CloseSessionFilter.filter(CloseSessionFilter.java:63)
	at org.jboss.resteasy.reactive.server.handlers.ResourceResponseFilterHandler.handle(ResourceResponseFilterHandler.java:25)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:150)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8888 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:401)
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
	at de.captaingoldfish.scim.sdk.client.http.ScimHttpClient.sendRequest(ScimHttpClient.java:200)
	... 51 more
Caused by: java.net.ConnectException: Connection refused
	at java.base/sun.nio.ch.Net.connect0(Native Method)
	at java.base/sun.nio.ch.Net.connect(Net.java:589)
	at java.base/sun.nio.ch.Net.connect(Net.java:578)
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:583)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
	at java.base/java.net.Socket.connect(Socket.java:751)
	at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
	... 61 more

2024-11-10 01:22:36,495 TRACE [org.keycloak.models.cache.infinispan.UserCacheManager] (executor-thread-24) Removed key='40ad5fb2-7ae8-492b-9c91-7a663c01c13e.consents', value='null' from cache
2024-11-10 01:22:36,496 TRACE [org.keycloak.models.cache.infinispan.UserCacheManager] (executor-thread-24) Removed key='7372d9ce-dcef-4239-9cbd-7ef228b9eae2.username.test-user-test1', value='null' from cache

so for now I stick with default 8888 to avoid potential issue and change my underlying mitmproxy implementation.

Hi Dmitry, this problem is only UI related. I just verified the port is correctly persisted in the database and also correctly respected by the used HTTP-client to establish a connection.
The UI is simply displaying always port 8888 due to a reference error within the UI.

Thanks for reporting this.

it's persisted for the 1st time
then GUI drops it to 8888 (regardless of the actual DB state) and next save with persist the 8888 value, which will cause errors, if the used proxy listens on a different port.