快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

eureka配置密码认证springboot-admin加入密码认证

1. pom.xml 加入依赖

成都网站设计、成都网站建设、外贸网站建设的关注点不是能为您做些什么网站,而是怎么做网站,有没有做好网站,给创新互联建站一个展示的机会来证明自己,这并不会花费您太多时间,或许会给您带来新的灵感和惊喜。面向用户友好,注重用户体验,一切以用户为中心。

	
		
		
            org.springframework.boot
            spring-boot-starter-security
        

2. application.properties 配置如下 用户名和密码

#开启安全认证 用户名和密码spring.security.basic.enabled=truespring.security.user.name=adminspring.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
 */@EnableWebSecuritypublic 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();
    }
}

 


本文名称:eureka配置密码认证springboot-admin加入密码认证
标题网址:http://6mz.cn/article/ppjdgh.html

其他资讯