springcloud配置eureka访问密码

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();
    }
}

 


新闻标题:springcloud配置eureka访问密码
链接地址:http://bzwzjz.com/article/pgocco.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站制作 高端网站设计 成都企业网站设计 网站建设方案 成都定制网站建设 网站建设费用 营销型网站建设 手机网站制作 成都网站建设 成都网站建设 成都网站设计公司 专业网站建设 成都网站设计 企业网站建设公司 成都网站制作 网站制作 手机网站制作 企业网站设计 成都网站建设 成都品牌网站建设 成都网站制作 泸州网站建设