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://csruizhi.cn/article/ppjdgh.html

其他资讯

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