Giter Club home page Giter Club logo

Comments (10)

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

Let me take a look and I'll get back to you.
Thanks,
Uli

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

I believe this is what you're looking for: spring-projects/spring-boot@055ace3

Basically, Spring added Logback support for doing this in your logback configuration:

<configuration>
        ...
        <springProperty name="destination" source="my.loggger.extradest"/>
        <appender name="FILE" class="ch.qos.logback.core.FileAppender">
            <file>${destination}</file>
                ...
            </file>
        </appender>
        ...
    </configuration>

from jasypt-spring-boot.

kbjp2 avatar kbjp2 commented on May 12, 2024

Hi Ulises,
Thank you very much for coming back to me.
The setting that you mentionned above is indeed what I'm using in my logback file.
The problem is that the encrypted spring properties don't seem to be decrypted on-the-fly (in my personal case, I just have jasypt-spring-boot jar as a maven dependency, a "@SpringBootApplication" annotation and an application.yml resource file with encrypted properties).
Does on-the-fly property-decryption work for you inside a logback-spring config file ?
Thank you very much in advance for your expertise.
Best Regards

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

Hmm... That's interesting, I was betting on it working, but let me do some debugging with logback configuration. I haven't really tried your scenario. Do you happen to have some sort of demo app where the issue manifests that I can checkout from GitHub?
Best,
Uli

from jasypt-spring-boot.

kbjp2 avatar kbjp2 commented on May 12, 2024

In order to reproduce the issue, you can use for example Spring demo project " Serving Web Content with Spring MVC" under https://spring.io/guides then the 3 following steps:

  1. add jasypt-spring-boot-starter jar to your dependencies

  2. add a "application.yml" file like:

jasypt.encryptor.password: your_encryption_key_here
encryptedproperty: ENC(your_encrypted_value_here)
  1. a logback-spring.xml file like:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <springProperty scope="context" name="encryptedproperty" source="encryptedproperty"/>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%property{encryptedproperty} %msg%n</pattern>
    </encoder>
  </appender>
  <root level="info">
    <appender-ref ref="STDOUT" />
  </root>
</configuration>

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

You'll have to use another type of setup. Spring is loading Logging configuration very early on the bootstrap process, way before this plugin decorates properties using a bean post processor. I just released a new version of the plugin (1.7) that will allow you to define a custom Environment in your application this way:

new SpringApplicationBuilder()
                .environment(new EncryptableEnvironment(new StandardServletEnvironment()))
                .sources(YourApplicationClass.class).run(args);

The new environment basically decorates the StandardServletEnvironment, or any other ConfigurableEnvironment implementation. With this setup, you do not need to use the starter jar, just jasypt-string-boot, but it has it's limitations. For configuration, You'd have to pass the encryption password as a system property and any other configuration for the StringEncryptor that's available as a property. Or, you can populate the properties in the decorated environment, by either directly adding a property source to the decorated environment, or by setting the properties in the SpringApplicationBuilder.
Otherwise, if you want to provide your own StringEncryptor, you could use the other constructor:

StringEncryptor encryptor = ...;
new SpringApplicationBuilder()
                .environment(new EncryptableEnvironment(new StandardServletEnvironment(), encryptor))
                .sources(YourApplicationClass.class).run(args);

But it'd be up to you how you initialize the string encryptor.

from jasypt-spring-boot.

kbjp2 avatar kbjp2 commented on May 12, 2024

Perfect ! :-)
Thanks a lot for your expertise and your time, Ulises !

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 12, 2024

No worries, thanks for using the library!

from jasypt-spring-boot.

kbjp2 avatar kbjp2 commented on May 12, 2024

In case you find time to answer:
how long will it take for the new binaries to be available (and visible) in maven central ?

from jasypt-spring-boot.

kbjp2 avatar kbjp2 commented on May 12, 2024

I can see it now in Maven central ! :-)

from jasypt-spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.