Spring Boot 配置 - 配置信息加密

Spring Boot配置文件敏感信息加密 springboot配置敏感信息加密 阅读详情

img

▶ Spring Boot 依赖与配置

Maven 依赖

   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>com.github.ulisesbocchio</groupId>
            <artifactId>jasypt-spring-boot-starter</artifactId>
            <version>2.1.1</version>
        </dependency>

▶ 使用说明

假设有配置项 com.anoyi.custom.name=anoyi 不能明文显示,则可以使用 jasypt 的 PBEWithMD5AndDES 算法加密算法进行如下配置:

com.anoyi.custom.name=ENC(TqrnYZn55aFVwnSo2TrbFA==)
jasypt.encryptor.password=anoyi

  • jasypt.encryptor.password 为自定义值,用此密码加密的明文,需要用此密码解密密文
  • ENC(...) 为 jasypt 提供的加密标识,Spring Boot 服务启动时,加载各种 properties 时会依据此标识判断是否解密赋值,可自定义
  • TqrnYZn55aFVwnSo2TrbFA== 为明文字符串 anoyi 通过密码 anoyi 加密后得到的值,此值不唯一,即同一明文通过同一密码加密会得到不同的值

▶ 配置说明

基于 Password 的加密配置

参数
必填
默认值
jasypt.encryptor.password
True
-
jasypt.encryptor.algorithm
FalsePBEWithMD5AndDES
jasypt.encryptor.keyObtentionIterationsFalse1000
jasypt.encryptor.poolSize
False1
jasypt.encryptor.providerName
FalseSunJCE
jasypt.encryptor.providerClassName
Falsenull
jasypt.encryptor.saltGeneratorClassnameFalseorg.jasypt.salt.RandomSaltGenerator
jasypt.encryptor.ivGeneratorClassname
Falseorg.jasypt.salt.NoOpIVGenerator
jasypt.encryptor.stringOutputType
Falsebase64
jasypt.encryptor.proxyPropertySources
Falsefalse

最新版的 jasypt 还支持非对称加密、自定义加密器等等功能,更多信息:

MORE :https://github.com/ulisesbocchio/jasypt-spring-boot

▶ 配置参数加解密

添加依赖

    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

示例加解密字符串 anoyi

@RunWith(SpringRunner.class)
@SpringBootTest
public class EncryptTest {

    @Autowired
    private StringEncryptor jasyptStringEncryptor;

    @Test
    public void encrypt() {
        String encryptStr = jasyptStringEncryptor.encrypt("anoyi");
        System.out.println(encryptStr);
    }

    @Test
    public void decrypt() {
        String encryptStr = jasyptStringEncryptor.decrypt("TqrnYZn55aFVwnSo2TrbFA==");
        System.out.println(encryptStr);
    }

}

▶ Github Demo URL

  • https://github.com/ChinaSilence/spring-boot-demos/tree/master/05 - config encrypt

© 著作权归作者所有,转载或内容合作请联系作者

img

● 拒绝黑盒应用-Spring Boot 应用可视化监控

● 并发Bug之源有三,请睁大眼睛看清它们

● 史上最轻松入门之Spring Batch - 轻量级批处理框架实践

● Spring Cloud Gateway - 快速开始

● APM工具寻找了一圈,发现SkyWalking才是我的真爱

● Spring Boot 注入外部配置到应用内部的静态变量

● 将 HTML 转化为 PDF新姿势

● Java 使用 UnixSocket 调用 Docker API

● Fastjson致命缺陷

● Service Mesh - gRPC 本地联调远程服务

● 使用 Thymeleaf 动态渲染 HTML

原文链接:

本文由博客一文多发平台 OpenWrite 发布!

基于账号密码对Spring Boot Actuator认证授权 Spring Boot 提供了一个内置的健康检查机制,可以方便地检查应用程序的状态。Spring Boot 提供了一个名为 Actuator 的插件,它包括了许多有用的功能,包括健康检查。Actuator 可以通过 HTTP 端点公开应用程序的状态和管理信息,包括健康检查信息。除了以上这些功能外,Spring Boot Actuator 还提供了许多其他有用的监控工具,可以帮助我们监视应用程序的状态和性能。/actuator/metrics:显示应用程序的度量信息,如请求速率、响应时间等。 阅读详情

相关推荐

spring boot 中使用jasypt 对配置文件里信息进行加密

博客参考:springboot集成jasypt实现配置文件敏感信息加密,详细! Spring Boot使用jasypt处理加密问题   ​​​​​1、pom.xml 引入jar包,我这里使用的spring boot  1.5.10.RELEASE &lt;dependency&gt; &lt;groupId&gt;com.github.ulisesbocchio&lt;/groupId...

dreaming_open的博客 5440

springBoot指标监控 - Actuator

如何有其他的软件应用也实现了健康指标,在这里也会显示,比如redis。

Adda_Chen的博客 2552

Spring Boot 数据库敏感配置信息加密方案

的原生加密功能旨在确保数据库连接配置中的关键信息(尤其是数据库密码)不以明文形式存在于配置文件中,从而增强系统的安全性。上述提到的配置属性是启动加密解密流程的关键配置项,其中明确告知要对相关配置进行解密,而则指定了解密所依赖的密钥,这里的通常会在运行时通过合适的方式(如环境变量、系统属性)被替换为真实的密钥内容。插件为项目提供了一种便捷且通用的配置加密方式。它允许开发者对配置文件中的各类敏感信息进行加密,不仅仅局限于数据库连接配置。通过自定义加密密钥,并将需要加密的配置值以特定格式(如ENC(加密内容)

weixin_43833540的博客 2299

SpringBoot - 集成Actuator(应用信息显示、修改系统日志、增加账号密码登录)

SpringBoot - 集成Actuator(应用信息显示、修改系统日志、增加账号密码登录)

weixin_39651356的博客 2487

Spring Boot Actuator 2.2.5 基本使用

4.访问actuator,很多可以访问的路径,这些都是可被健康检查的指标。2.application.properties 文件中添加以下配置。3.启动springboot项目,会看到如下输出,1. pom文件 ,添加 Actuator 依赖。

u013558123的博客 1457

【Stata双重差分模型】双重差分DID的具体操作步骤

本案例将详细阐述如何使用双重差分法进行实证分析,并展示具体的STATA操作代码。

a519573917的博客 2万+

SpringBoot 2.0配置Atuator

1.pom.xml <!--springBoot Actuator --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator...

Lei_Da_Gou的博客 325

zabbix系列:内存VM.MEMORY.SIZE监控之total、free、pused、available 参数说明

free -m buffer是即将要被写入磁盘的,而cache是被从磁盘中读出来的. zabbix Web total:1046/1024=1.02G Available:216/1046=20.65% zabbix参数 total- 总物理内存. free- 可用内存. active- 内存当前使用或最近使用,所以它在RAM中。 inactive- 未使用内存. wired- 被标记为始终驻留在RAM中的内...

NIO4444 5670

Spring Boot 应用中,如何对配置文件的敏感信息进行加密

在 Spring Boot 应用中,对配置文件中的敏感信息(如数据库密码、API 密钥等)进行加密是保障应用安全的重要措施。以下介绍使用 Jasypt 对 Spring Boot 配置文件敏感信息进行加密的详细步骤,并附上完整代码示例。

m0_57836225的博客 1286

诊断数据库ODX标准协议ISO22901定义组成部分

综上所述,简略描述了ODX数据库中UML/XML/Text/Check rules具体功能以及详细内容。

Soly_kun的博客 907

IgH EtherCAT 从入门到精通:第 2 章 环境搭建与编译安装

环境搭建与编译安装指南 本章详细介绍了搭建IgH EtherCAT Master开发环境的完整流程。内容包括: 硬件要求:支持多种Intel和Realtek网卡的原生驱动,以及通用网卡的generic驱动选项 软件依赖:列出Linux系统下所需的工具链和开发包 源码获取:通过Git克隆官方仓库并切换稳定版本的方法 配置选项:详细解析bootstrap脚本和configure的核心参数,包括路径设置、功能开关和实时框架选项 编译流程:从生成构建系统到最终编译安装的完整步骤 通过本章指导,读者可以完成一个可运行

从事嵌入式linux android驱动开发,拥有全栈能力 481

在Spring Boot中应用Jasypt以加密配置信息。

在Spring Boot应用中,对配置信息进行加密是一项加强应用安全性的重要措施。Jasypt(Java Simplified Encryption)提供了一系列工具和类库,用于在Java应用中对属性文件、配置文件中的敏感信息进行加密。以下是将Jasypt应用于Spring Boot项目以加密配置信息的步骤。

高性价比服务器就选:蓝易云 781

软考高级-系统架构设计师 知识点整理 (一篇就够了 建议收藏)

软考高级-系统架构设计师知识点整理---十万字总结,助你通过高级

片言可决讼,半纸能缚龙 7356

蓝易云 - 在Spring Boot中应用Jasypt以加密配置信息。

在Spring Boot应用中,对配置信息进行加密是一项加强应用安全性的重要措施。Jasypt(Java Simplified Encryption)提供了一系列工具和类库,用于在Java应用中对属性文件、配置文件中的敏感信息进行加密。以下是将Jasypt应用于Spring Boot项目以加密配置信息的步骤。

高性价比服务器就选:蓝易云 687

YOLO11 改进 - C2PSA | C2PSA融合HEWL(高频增强小波层):小波逆变换+双通道注意力增强+高频显式增强 | TGRS 2026

本文介绍了高频增强小波层(HEWL),一种专为解决红外小目标检测中边缘退化与语义模糊问题设计的上采样模块。该方法结合小波逆变换与交替通道注意力(ALCA),通过显式增强高频细节并优化特征融合,实现精准的边缘重建与语义对齐。我们将 HEWL 融入 PSABlock 结构构建了 C2PSA_HEWL 模块,并成功集成进 YOLO11 的骨干网络,替代原有的 C2PSA 模块。实验证明,结合 HEWL 的 YOLO11 在检测任务中表现优异,有效提升了模型对细节特征的捕捉能力。

魔改工程师的博客 103

CAN轴控制流【6041,6040】

【代码】CAN轴控制流【6041,6040】

cfqq1989的博客 1783

在Spring Boot中应用Jasypt以加密配置信息

在Spring Boot应用中,对配置信息进行加密是一项加强应用安全性的重要措施。Jasypt(Java Simplified Encryption)提供了一系列工具和类库,用于在Java应用中对属性文件、配置文件中的敏感信息进行加密。以下是将Jasypt应用于Spring Boot项目以加密配置信息的步骤。

jghhh01的博客 459

【智能车Code review】—曲率计算、最小二乘法拟合

【1】曲率计算函数 选三个点计算曲率 float process_curvity(byte x1, byte y1, byte x2, byte y2, byte x3, byte y3) { float K; int S_of_ABC = ((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / 2; //面积的符号表示方向 byte q1 = (byte)((x2 - x1) * (x2 - x1) + (y2 - y1) *

hanhan的博客 1万+

​Spring Boot 配置文件敏感信息加密:Jasypt 实战

在SpringBoot项目中,敏感信息如数据库密码、APIKey等通常直接存储在配置文件中,存在代码泄露、运维风险和合规性要求等安全隐患。为解决这些问题,可以使用Jasypt(Java Simplified Encryption)对敏感信息进行加密,并在运行时自动解密。集成Jasypt的步骤包括添加Maven依赖、生成加密字符串、配置密钥和算法,并在启动文件中启用加密属性。为确保安全,密钥应通过环境变量或启动参数动态注入,避免直接写在配置文件中。

weixin_74120671的博客 2368

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Spring Boot 3中使用Jasypt实现配置文件信息加密

???? 作者:知识浅谈,优快云签约讲师,优快云博客专家,华为云云享专家,阿里云专家博主 ???? 擅长领域:全栈工程师、爬虫、ACM算法 ???? 公众号: 知识浅谈 ????Spring Boot 3中使用Jasypt实现配置文件信息加密????????前言????创建新的Spring Boot项目???? 添加Jasypt依赖????加密配置参数????配置...

cnzzs的博客 851

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

上一篇: Spring Boot 异常处理
下一篇: 【双11狂欢的背后】微服务注册中心如何承载大型系统的千万级访问?
SpringForAll
博客等级 码龄7年 15粉丝 79原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值