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

1. pom.xml 加入依赖

在侯马等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都做网站、成都网站建设、成都外贸网站建设 网站设计制作按需网站制作,公司网站建设,企业网站建设,品牌网站建设,营销型网站,成都外贸网站制作,侯马网站建设费用合理。

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

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

#开启安全认证 用户名和密码
spring.security.basic.enabled=true
spring.security.user.name=fh_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保护禁用
 * 作者:F-H Admin
 * 官网: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();
    }
}


分享文章:eureka加入密码认证springboot-admin加入密码认证
URL分享:http://csruizhi.cn/article/jgdcoc.html

其他资讯

Copyright © 2007-2024 成都优众联杰科技有限公司 All Rights Reserved 蜀ICP备2024116266号
友情链接: 成都网站设计 营销型网站建设 网站建设公司 网站设计公司 重庆手机网站建设 企业网站建设 成都网站设计 网站制作公司 app网站建设 响应式网站建设 成都企业网站建设公司 网站建设费用 H5网站制作 网站建设 上市集团网站建设 网站制作 高端网站设计 成都网站设计制作公司 高端网站设计推广 四川成都网站建设 成都营销网站制作 品牌网站建设