Update keycloak from config file - spring-boot

I am using keycloak embedded into spring application explained in this tutorial https://www.baeldung.com/keycloak-embedded-in-spring-boot-app
There is a configuration file for keycloak that is contained within that application, but the configuration is imported into keycloak and into database only the first time that application is started.
Is there a way to make updates on that config file reflect on the state of the keycloak?
Developers should be able to change configurations and push changes to version control. When somebody pulls the new configuration it should reflect on his local instance of keycloak.

Related

How to configure database connection runtime in Spring Boot?

I made a new Spring Boot project using the Spring Initializr. I'm building an On-premise backend so what I'm trying to achieve is that when the user opens the jar executable and the server starts, he should be able to configure the database connection by going to localhost:8080/ in his web browser. Basically the index.html will have a form with 4 fields for IP Address, Database Name, UserName and Password. When the form is submitted spring will try to connect to the database with the provided information.
I have all my entities, repositories and controllers but currently the only way i can connect to a database is with the application.properties file, but since the user wont have access to the source, there should be a way for him to configure his database.
Thanks for your time!
I would suggest to use the Spring cloud Config server to store database related properties which is capable of picking up configuration at run time. Although it is typically configured with a Git repository, you can store them locally as pointed out in this thread.

Spring Cloud Config Server on Pivotal Cloud Foundry

I have two microservices. A Spring Cloud Config Server and another module that implements Spring Cloud Config Client. When I use the default configuration for the Spring Cloud Config Server service (localhost:8888) I can start it locally without any issues, after which I can start my other module as well, using a bootstrap.yml, it clearly finds the Config Server, fetches its properties and starts properly. All good. Now I'd like to push both of these services to Pivotal Cloud Foundry.
The Config Server service works just fine, service is up and running in my Space, and using the browser I can verify that it can still fetch the property files from the specific GitHub repository.
The problem is the other module, the client. I've replaced the default localhost:8888 in its bootstrap.yml file (spring.cloud.config.url parameter) to the now active service in the cloud using the Route bound to it and tried to start it locally. Unfortunately now it simply timeouts during startup. At this point I tried to specify longer timeouts but nothing helps.
Interesting thing is that if I directly copy the URL from the logs that timeouts I see it works properly in the browser locally. So why not in IntelliJ when I try to package the client with the changed parameter?
Sorry, I can't include much details here, but I hope maybe there is a straightforward solution that I've missed. Thanks!

spring cloud config client set config url at property file

I have a spring cloud project. There are config server (config-srv), eureka server (eureka-srv) and some other service with business logic, let's call it main service (main-srv).
I'm packaging them into jars and run one by one. My apps get their properties from a file in the same directory with jars.
So, I'm setting properties to config-srv through "application-native.properties".
But if i want to change config-srv url (for example, i want http://localhost:9999), how can i share this url for all micro-services before they will boot ? I'm trying to share this url in "application-default.properties" but it makes no effect.
You can put the Spring Cloud Config server details in bootstrap.properties file in each microservices.
spring.application.name=microserviceName
spring.profiles.active=dev
spring.cloud.config.uri=http://localhost:9999
spring.cloud.config.username=your_username
spring.cloud.config.password=your_password
Go through the link to have more detail about spring cloud config
https://howtodoinjava.com/spring-cloud/spring-cloud-config-server-git/

Using Spring cloud config in multi application architecture

I am currently using Spring external configuration by creating a config server, config client and a Git repository with property files. Is there any way to use this config server for multiple applications?
My Current Architecture:
Created a Git repository with config files.
Created a Config Server which connects to the above Git repository for property files.
Created a Client (Spring boot application) which connects to the config server to load the properties.
When there is a change in any of the property files, I am invoking the refresh method of config client to refresh the properties. If there are multiple applications using the same config server and git repository for property files, what should be the approach to refresh all the properties without invoking the /refresh method of all the applications?
I tried /refresh of the config server but it doesn't refresh the properties as they are loaded during the application startup.

Modify ldap provider url without restarting the spring security application

we are providing facility to customer to configure ldap server runtime. But when i modify provider server url used in constructor of context source, the application crashes. Is there any way to change ldap server url at runtime? for LdapAuthenticationProvider.
If this is a case where you are changing the provider because one may be down for some reason, you should set up multiple authentication providers (security:authentication-provider) in your spring-security config file. Spring-security will start at the top of the list & keep trying until it finds one that works. That way you can leave this setup & not have a need to redeploy your code.

Resources