bindian0509 / microservices-complete

⭐️ A complete reference for building robust backend architecture in Java and Spring ⭐️
1 stars 0 forks source link

Issue with `Jasypt` encryption to get config in twitter kafka service #6

Open bindian0509 opened 1 year ago

bindian0509 commented 1 year ago

Getting following exception in running the twitter to kafka service application -

2023-09-11 18:49:51 INFO  [main] o.s.c.c.c.ConfigServerConfigDataLoader - Fetching config from server at : http://localhost:8888
2023-09-11 18:49:51 INFO  [main] o.s.c.c.c.ConfigServerConfigDataLoader - Exception on Url - http://localhost:8888:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/twitter-to-kafka-service,config-client/default": Server redirected too many times (20). Will be trying the next url if available
2023-09-11 18:49:51 INFO  [main] o.s.c.c.c.ConfigServerConfigDataLoader - Fetching config from server at : http://localhost:8888
2023-09-11 18:49:51 INFO  [main] o.s.c.c.c.ConfigServerConfigDataLoader - Exception on Url - http://localhost:8888:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/twitter-to-kafka-service,config-client/twitter_to_kafka": Server redirected too many times (20). Will be trying the next url if available
2023-09-11 18:49:51 ERROR [main] o.s.boot.SpringApplication - Application run failed
org.springframework.cloud.config.client.ConfigClientFailFastException: Could not locate PropertySource and the resource is not optional, failing
bindian0509 commented 1 year ago

Half of the problem seems to be solved by changing application.yml format of supplying username and password, Now with spring security, these application properties can be accessed via spring_cloud_user from the browser.

but somehow the client is not able to authenticate with the same user mentioned in twitter-to-kafka-app's application.yml

bindian0509 commented 1 year ago

Correct format

spring 
  security:
    user: // this was missing 
      name: spring_cloud_user
      password: ENC(<encrypted-value>)
bindian0509 commented 1 year ago

Figured out that it was not a problem of spring security rather a problem with jasypt not loading with twitter to kafka application, when I use plain text value of password in application.yml it works fine. Looking more to understand what is causing a problem here to not let jasypt get involved in launching the main application.