1. pom.xml 加入依赖
<!-- 加入密码认证 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
2. application.properties 配置如下 用户名和密码
#开启安全认证 用户名和密码
spring.security.basic.enabled=true
spring.security.user.name=admin
spring.security.user.password=root
3. 加入配置类 WebSecurityConfig.java
package org.fh.config;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
/**
* 说明:CSRF保护禁用
* 作者:www.1b23.com
*/
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
http.headers().frameOptions().disable();
http.csrf().disable().authorizeRequests().antMatchers("/actuator/**").permitAll().anyRequest().authenticated().and().httpBasic();
}
}
相关推荐
spring boot 实践学习案例,与其它组件结合如 mybatis、jpa、dubbo、redis、mongodb、memcached、kafka、... - Spring Cloud 入门,包括 Eureka(服务注册与发现)、Config(配置中心)、Hystrix(断路器)、Bus(消息总线) 等
正springboot介绍zheng-springboot-demo├── zheng-springboot springboot功能示例├── zheng-springboot-eureka-server 服务注册中心├── zheng-springboot-compute-service 服务提供者├── zheng-...
codecentric 的Spring Boot Admin 是⼀个社区项⽬,能够监控和管理您的Spring Boot 应⽤。这些应⽤通过Http 注册到Spring Boot Admin 或者通过Spring Cloud的注册中⼼(如Eureka、Consul)来发现。UI是Spring Boot。...
任务-定时任务 26、尚硅谷-SpringBoot高级-任务-邮件任务 27、尚硅谷-SpringBoot高级-安全-测试环境搭建 28、尚硅谷-SpringBoot高级-安全-登录&认证&授权 29、尚硅谷-SpringBoot高级-安全-权限控制&注销 30、尚硅谷-...
一:RestApi接口增加JWT认证功能 用户填入用户名密码后,与数据库里存储的用户信息进行比对,如果通过,则认证成功。传统的方法是在认证通过后,创建sesstion,并给客户端返回cookie。 现在我们采用JWT来处理...
28、尚硅谷-SpringBoot高级-安全-登录&认证&授权 29、尚硅谷-SpringBoot高级-安全-权限控制&注销 30、尚硅谷-SpringBoot高级-安全-记住我&定制登陆页 31、尚硅谷-SpringBoot高级-分布式-dubbo简介 32、尚硅谷-...
python库,解压后可用。 资源全名:py_eureka_client-0.9.8-py3-none-any.whl
我的博客《Spring Boot学习笔记-------(十一)Eureka使用》配套代码资源,博客地址为:https://blog.csdn.net/huaya1127/article/details/105969177
springcloud的eureka服务注册案例,包括consumer-user,eureka-server,product_ticket
针对原生的EurekaClient做了简单的二次封装,引入了额外依赖,对consul做了适配的Eureka注册中心,适用Prometheus自动注册。
集成mybatis、eureka、feign、springboot-admin基础控件,供初期学习使用;
springboot整合mybatis,非常适合新手学习.同时整合了swagger.
博客《Spring Boot学习笔记-------(十一)Eureka使用-高可用性》。https://blog.csdn.net/huaya1127/article/details/105973387,配套资源代码,做高可用性配置处理。
单机版本的eureka-server和eureka-client
eureka-server:eureka注册中心 account-service:用户账户服务 storage-service:商品库存服务 order-service:订单服务 resources/database-sql:mysql数据库表结构的初始化脚本 resources/seata-server:seata ...
spring boot添加admin监控demojar包,可以在本地依次命令行执行java -jar jar包,然后访问端口查看监控情况,执行顺序为:1、eureka-server-0.0.1-SNAPSHOT.jar 2、spring-boot-admin-client-0.0.1-SNAPSHOT.jar 3、...
Eureka服务注册与发现-Eureka是Spring Cloud Netflix的一个子模块,也是核心模块之一
Windows一键启动Eureka和Cassandra和redis-server的脚本.bat
eureka-server+gateway-service+user-service+zipkin-server 本文案例一共四个工程采用多Module形式。需要新建一个主Maven工程,主要指定了Spring Boot的版本为1.5.3,Spring Cloud版本为Dalston.RELEASE。包含了...