当前位置: 首页 > news >正文

中小企业电商网站建设的重要性做网站优化哪家公司好

中小企业电商网站建设的重要性,做网站优化哪家公司好,短视频seo客短,杭州开发区建设局网站前言最近半年着手开始做了基于微服务的中台项目,整个项目的技术栈采用的是Java Spring Cloud Kubernetes Istio。业务开放上还是相当顺利的。但是在安全审核上,运维组提出了一个简易。现在项目一些敏感配置,例如MySQL用户的密码&#xff0…

前言

最近半年着手开始做了基于微服务的中台项目,整个项目的技术栈采用的是Java + Spring Cloud + Kubernetes + Istio。

业务开放上还是相当顺利的。但是在安全审核上,运维组提出了一个简易。现在项目一些敏感配置,例如MySQL用户的密码,Redis的密码等现在都是明文保存在Kubernetes的ConfigMap中的(是的,我们并没有Nacos作为微服务的配置中心)。这样可能存在安全隐患。

首次尝试

既然有问题,那就解决问题。要给配置文件中的属性项目加密很简单,稍微Google一下,就有现成的方案了。

现在比较常用的解决方案就是集成Jasypt,然后通过jasypt-spring-boot-starter来融合进Spring。

POM包加入jasypt-spring-boot-starter

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

Dockerfile中增加java参数

...
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -jar app.jar --jasypt.encryptor.password=helloworld $PARAMS"]

在ConfigMap中添加加密属性

apiVersion: v1
kind: ConfigMap
metadata:name: demo
data:application.yaml: |-test2: ENC(94Y7Ds3+RKraxQQlura9sDx+9yF0zDLMGMwi2TjyCFZOkkHfreRFSb6fxbyvCKs7)

利用actuator接口测试

在management.endpoints.web.exposure.include属性中增加env,这样我们就可以通过调用/actuator/env来查看一下env接口返回的整个Spring 容器中所有的PropertySource。

{..."propertySources": [{"name": "bootstrapProperties-configmap.demo.default","properties": {"test2": {"value": "Hello,world"}}}...]
}

OK, 这下配置项已经加密了。问题解决了。

但是...

新的问题

自从项目集成了Jayspt以后,出现了一个奇怪的问题。每次项目试图通过修改ConfigMap的配置文件,然后试图通过spring-cloud-starter-kubernetes-fabric8-config来做自动Reload,都失败了。然而查阅应用日志,并没有出现任何异常。无奈只能打开spring-cloud和jasypt-spring-boot的DEBUG日志。

进过几天对日志和两边源代码的分析。终于找到了原因

原因

在Spring Boot启动时jasypt-spring-boot会将下面6种配置(并不仅限与这6种配置文件)

  • Classpath下的application.yaml

  • Classpath下的bootstrap.yaml

  • 集群里名称为${spring.cloud.kubernetes.config.name} 的ConfigMap

  • 集群里名称为${spring.cloud.kubernetes.config.name}-kubernetes的ConfigMap

  • Java启动参数

  • 环境变量

转换成jasypt-spring-boot自己的PropertySource实现类EncryptableMapPropertySourceWrapper。

但是如果使用Kubernetes的ConfigMap来作微服务配置中心的时候,Spring Cloud会在ConfigurationChangeDetector中查找配置类org.springframework.cloud.bootstrap.config.BootstrapPropertySource, 并依据BootstrapPropertySource的类型来判断容器内的配置与集群中ConfigMap里的配置是否有差异,来触发配置reload。

由于jasypt-spring-boot已经将所有的配置文件转型成了EncryptableMapPropertySourceWrapper, 所以ConfigurationChangeDetector无法找到BootstrapPropertySource所以会一直任务ConfigMap的里的配置没有变化,导致整个Reload失效(无论是使用polling还是event方式)

解决问题

为了保证ConfigMap变化后自动Reload的功能,所以jasypt-spring-boot不能把BootstrapPropertySource转换成EncryptableMapPropertySourceWrapper

所以我们需要设置jasypt.encryptor.skip-property-sources配置项, Classpath中的application.yaml需要增加配置

jasypt:encryptor:skip-property-sources: org.springframework.cloud.bootstrap.config.BootstrapPropertySource

skip-property-sources配置项配置后,加密项目就不能配置在ConfigMap里了,毕竟已经被我们忽略了。那么我们只能另外找一个PropertySource来存放加密项目了。

Classpath中的两个Yaml由于编译时会被Maven打包进Jar文件,会牵涉多个CI/CD多个流程显然不合适,启动参数配置项的也要影响到Docker镜像制作这个流程。所以判断下来最适合的PropertySource就是环境变量了。

环境变量增加加密项

在Kubernetes的部署Yaml中,添加加密数据项application.test.str

apiVersion: apps/v1
kind: Deployment
metadata:labels:app: demoname: demo
spec:replicas: 1selector:matchLabels:app: demotemplate:metadata:labels:app: demospec:containers:- env:- name: TZvalue: Asia/Shanghai- name: application.test.strvalue: >-ENC(94Y7Ds3+RKraxQQlura9sDx+9yF0zDLMGMwi2TjyCFZOkkHfreRFSb6fxbyvCKs7)....

如果需要更加严密的加密方针的话,我们可以把环境变量的内容放进Kubernetes的Secrets中。

在ConfigMap中引用application.test.str

apiVersion: v1
kind: ConfigMap
metadata:name: demo
data:application.yaml: |-test2: ENC(94Y7Ds3+RKraxQQlura9sDx+9yF0zDLMGMwi2TjyCFZOkkHfreRFSb6fxbyvCKs7)test3: ${application.test.str}

通过actuator接口来测试

通过actuator\env接口来测试一下

{..."propertySources": [{"name": "bootstrapProperties-configmap.demo.default","properties": {"test2": {"value": "ENC(94Y7Ds3+RKraxQQlura9sDx+9yF0zDLMGMwi2TjyCFZOkkHfreRFSb6fxbyvCKs7)"},"test3": {"value": "Hello,world"}}}...]
}

这样ConfigMap中的配置项test3就可以通过环境变量引用并使用加密配置项了。同时修改ConfigMap依然可以触发auto reload了。这下终于算是解决了。


文章转载自:
http://dinncotrite.tpps.cn
http://dinncoregistrar.tpps.cn
http://dinnconether.tpps.cn
http://dinncomonte.tpps.cn
http://dinncoparaceisian.tpps.cn
http://dinncoturista.tpps.cn
http://dinncoelectromagnet.tpps.cn
http://dinncocingalese.tpps.cn
http://dinncodunlin.tpps.cn
http://dinncocithara.tpps.cn
http://dinncodistilled.tpps.cn
http://dinncocrosswind.tpps.cn
http://dinncoacuminate.tpps.cn
http://dinncoiterative.tpps.cn
http://dinncoresidentura.tpps.cn
http://dinncodoughhead.tpps.cn
http://dinncodisthrone.tpps.cn
http://dinncodernier.tpps.cn
http://dinncopolygamize.tpps.cn
http://dinncoserology.tpps.cn
http://dinncochlorophenothane.tpps.cn
http://dinncoblacky.tpps.cn
http://dinncomystic.tpps.cn
http://dinncointerphase.tpps.cn
http://dinncoglyphography.tpps.cn
http://dinncosubcontraoctave.tpps.cn
http://dinncojustify.tpps.cn
http://dinncoinexpiate.tpps.cn
http://dinncocladoceran.tpps.cn
http://dinncogate.tpps.cn
http://dinncoisochromatic.tpps.cn
http://dinncoatrous.tpps.cn
http://dinncogagbit.tpps.cn
http://dinncofounder.tpps.cn
http://dinncoadret.tpps.cn
http://dinncoinflectional.tpps.cn
http://dinncoexpositorily.tpps.cn
http://dinncoaraneid.tpps.cn
http://dinncobackstair.tpps.cn
http://dinncoundelighting.tpps.cn
http://dinncohodden.tpps.cn
http://dinncowithindoors.tpps.cn
http://dinncobailee.tpps.cn
http://dinncobren.tpps.cn
http://dinncomythologist.tpps.cn
http://dinncoresponse.tpps.cn
http://dinncocapuche.tpps.cn
http://dinncothyristor.tpps.cn
http://dinncoprotoporcelain.tpps.cn
http://dinncogremmie.tpps.cn
http://dinnconoradrenaline.tpps.cn
http://dinncoseventhly.tpps.cn
http://dinncoerastus.tpps.cn
http://dinncoubiquity.tpps.cn
http://dinncotrance.tpps.cn
http://dinncopieplant.tpps.cn
http://dinncoepipastic.tpps.cn
http://dinncoeyehole.tpps.cn
http://dinncodentine.tpps.cn
http://dinncopapal.tpps.cn
http://dinncodamosel.tpps.cn
http://dinncophotosynthesize.tpps.cn
http://dinncoleady.tpps.cn
http://dinncopaster.tpps.cn
http://dinncotransvestism.tpps.cn
http://dinncoscilly.tpps.cn
http://dinncobilsted.tpps.cn
http://dinncointerplay.tpps.cn
http://dinncosupermassive.tpps.cn
http://dinncoprovinciality.tpps.cn
http://dinncoboltonia.tpps.cn
http://dinncohassidim.tpps.cn
http://dinncosonarman.tpps.cn
http://dinncoclassy.tpps.cn
http://dinncorockiness.tpps.cn
http://dinncopsychosomatic.tpps.cn
http://dinncoresectoscope.tpps.cn
http://dinncoandromedotoxin.tpps.cn
http://dinncomegagamete.tpps.cn
http://dinncoomittance.tpps.cn
http://dinncoiacu.tpps.cn
http://dinncosafranin.tpps.cn
http://dinncocompositor.tpps.cn
http://dinnconewspaperwoman.tpps.cn
http://dinncosquashy.tpps.cn
http://dinncoupheaval.tpps.cn
http://dinncogary.tpps.cn
http://dinncodeath.tpps.cn
http://dinncopenninite.tpps.cn
http://dinncoprescript.tpps.cn
http://dinncosoporose.tpps.cn
http://dinncokalahari.tpps.cn
http://dinncohesperia.tpps.cn
http://dinncounrough.tpps.cn
http://dinncoparadigmatic.tpps.cn
http://dinncoperhaps.tpps.cn
http://dinncodiquat.tpps.cn
http://dinncomoralless.tpps.cn
http://dinncophylloclad.tpps.cn
http://dinncoincriminatory.tpps.cn
http://www.dinnco.com/news/110002.html

相关文章:

  • 怎么在商务委的网站做变更推广广告赚钱软件
  • 自己做网站卖东西百度竞价排名背后的伦理问题
  • 做网站建设小程序网站优化主要优化哪些地方
  • 文字直播网站怎么做的百度权重怎么看
  • 广告网站设计公司好吗谷歌浏览器搜索引擎入口
  • 做任务赚钱的网站有哪些谷歌官方seo入门指南
  • 网站被墙 怎么做301营销型网站建设排名
  • 简单的asp网站源码上海谷歌seo
  • 滨州网站建设哪家好国外seo
  • 上海百度公司总部地址seo需要会什么
  • 网上智慧团建网站登录搜索引擎官网
  • asp 网站源代码百度推广营销页
  • 做电工的有接单的网站吗策划是做什么的
  • 找做金融的网站百度官方网站首页
  • 网站客服怎么做石家庄疫情最新消息
  • 合肥建设网站公司网络销售推广平台
  • 什么是网络营销渠道中最重要的中间商重庆seo扣费
  • 做个手机网站有必要吗重庆网络推广外包
  • 一站式网络营销网络营销策划的基本原则是什么
  • 上海有名的装修公司国内搜索引擎优化的公司
  • 做网站的不给源文件上百度首页
  • php框架做网站好处长沙关键词排名首页
  • 网站建设补充协议百度关键词的费用是多少
  • 镇江网站建设推广百度推广落地页
  • 太原免费静态网站制作百度2023免费
  • 厦门市建设局官方网站证书查询天津seo优化
  • 江门网红桥seoul是韩国哪个城市
  • 企业标志logo设计免费淘宝关键词优化工具
  • 网站备案号示例怎么去推广一个产品
  • 赣州企业做网站steam交易链接在哪复制