SpringCloud-----SpringSecurity使用出现Reason:坏的凭证

Spring Boot安全配置详解
本文详细解析了Spring Boot中安全配置的常见问题及解决方法,针对application.properties配置不当导致的安全访问问题,提供了具体修改方案,并指出不同Spring Boot版本配置差异。

1、现象

2、原因:配置文件application.properties中的配置不正确

#安全访问
security.basic.enabled=true
security.user.name=jeagine
security.user.password=jg123456

我们去spring-boot-autoconfig包下查看一下 SecurityProperties.class

发现是spring.security配置

3、修改

SpringBoot的版本不同,这个配置有所不同。有些版本是不需要spring前缀的,一般早期版本不需要spring前缀

#安全访问
spring.security.basic.enabled=true
spring.security.user.name=jeagine
spring.security.user.password=jg123456

 

 

025-09-01T01:14:41.593+08:00 ERROR 2125694 --- [uap-gateway] [ parallel-11] [ ] a.w.r.e.AbstractErrorWebExceptionHandler : [9d9934fe-11] 500 Server Error for HTTP GET "/gateway/api/vpp/jhgljs/v2/getRqddAndActualCurveByCommandIds?pt=49f66aac8e229f26af833fb7f3d34c1c3bbdb16cdba4ca6913f377a97ce29c9e5bbf7a8ca4a4ec4f735af36d1ed82665f091fc8c58fe489c18b01e6d67e10d7c8c30b6f5776a5d271b98c4a372c13b9783bf0f7e6005d37b279b2646bc233eb38cc96ab2bf53a1f303d01d059ba602e26e1ada75b2dc4164ff28f9f6692ce44873e7d3f7166ffadcdd55792945162a961d26a8336d3cc83b82e3855f0fe34e4ef053fe4236ffce7d8437aea1fd3217642894440a6a6aff44732aba89eca51adccb5c7fdc0b21d918526bd30c224cc2f9a5e6f32e3b927b958d433a7475e0d947d54b6772eb1b1b28ab111a936728dc06c9b7517d245f75325d1adc18d66ae4c13d9ae58fe8233a4cf2acc62113e413b518315b0f7918898fb8cc59bb7dc4ece16b65eb4f6291e8264211ff28366e234d10fe18c2d0fc625d32738f6a2fdc2a266aca70ae08088c4032d3b43e6d67cd47e13d8538ec52a42fa298113ce309f7f4" java.lang.IllegalArgumentException: When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead. at org.springframework.web.cors.CorsConfiguration.validateAllowCredentials(CorsConfiguration.java:568) ~[spring-web-6.2.8.jar!/:6.2.8] Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): *__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ AuthorizationWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ ExceptionTranslationWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ LogoutWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ ServerRequestCacheWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ SecurityContextServerWebExchangeWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ ReactorContextWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ HttpHeaderWriterWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ ServerWebExchangeReactorContextWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ org.springframework.security.web.server.WebFilterChainProxy [DefaultWebFilterChain] *__checkpoint ⇢ HTTP GET "/gateway/api/vpp/jhgljs/v2/getRqddAndActualCurveByCommandIds?pt=49f66aac8e229f26af833fb7f3d34c1c3bbdb16cdba4ca6913f377a97ce29c9e5bbf7a8ca4a4ec4f735af36d1ed82665f091fc8c58fe489c18b01e6d67e10d7c8c30b6f5776a5d271b98c4a372c13b9783bf0f7e6005d37b279b2646bc233eb38cc96ab2bf53a1f303d01d059ba602e26e1ada75b2dc4164ff28f9f6692ce44873e7d3f7166ffadcdd55792945162a961d26a8336d3cc83b82e3855f0fe34e4ef053fe4236ffce7d8437aea1fd3217642894440a6a6aff44732aba89eca51adccb5c7fdc0b21d918526bd30c224cc2f9a5e6f32e3b927b958d433a7475e0d947d54b6772eb1b1b28ab111a936728dc06c9b7517d245f75325d1adc18d66ae4c13d9ae58fe8233a4cf2acc62113e413b518315b0f7918898fb8cc59bb7dc4ece16b65eb4f6291e8264211ff28366e234d10fe18c2d0fc625d32738f6a2fdc2a266aca70ae08088c4032d3b43e6d67cd47e13d8538ec52a42fa298113ce309f7f4" [ExceptionHandlingWebHandler] Original Stack Trace: at org.springframework.web.cors.CorsConfiguration.validateAllowCredentials(CorsConfiguration.java:568) ~[spring-web-6.2.8.jar!/:6.2.8] at org.springframework.web.reactive.handler.AbstractHandlerMapping.lambda$getHandler$1(AbstractHandlerMapping.java:198) ~[spring-webflux-6.2.8.jar!/:6.2.8] at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:74) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxFilterWhen$FluxFilterWhenSubscriber.drain(FluxFilterWhen.java:272) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxFilterWhen$FluxFilterWhenSubscriber.request(FluxFilterWhen.java:160) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoNext$NextSubscriber.request(MonoNext.java:108) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxMap$MapSubscriber.request(FluxMap.java:164) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxMap$MapSubscriber.request(FluxMap.java:164) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.request(Operators.java:2330) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxMap$MapSubscriber.request(FluxMap.java:164) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.request(Operators.java:2330) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxConcatMapNoPrefetch$FluxConcatMapNoPrefetchSubscriber.request(FluxConcatMapNoPrefetch.java:339) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoNext$NextSubscriber.request(MonoNext.java:108) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2366) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2240) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoNext$NextSubscriber.onSubscribe(MonoNext.java:70) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxConcatMapNoPrefetch$FluxConcatMapNoPrefetchSubscriber.onSubscribe(FluxConcatMapNoPrefetch.java:164) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:201) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:83) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.Mono.subscribe(Mono.java:4576) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:82) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:299) ~[reactor-core-3.7.7.jar!/:3.7.7] at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:299) ~[reactor-core-3.7.7.jar!/:3.7.7] 启用allow-credentials后连get请求都500了
最新发布
09-02
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值