Configure spring Security for Spring-boot-admin (for control access) _spring-boot-admin

Source: Internet
Author: User
Tags auth
In the Spring-boot-admin (SBA) monitoring side, in order to prevent unauthorized access, the general need to do access control. With a few simple steps, you can configure the spring security to control access to the SBA. 1, the introduction of dependence:
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId> Spring-boot-starter-security</artifactid>
		</dependency>

2. Configuration:
@Configuration @EnableWebSecurity public class Websecurityconfig extends Websecurityconfigureradapter {@Value ("${

	Spring.profiles} ") Private String env; @Override protected void Configure (Httpsecurity http) throws Exception {/*if ("dev". Equals (env)) {//If you need to be in the development service to avoid logging in to HT
			Tp.authorizerequests (). Antmatchers ("*//**", "*//**//*filters"). Permitall ();
			HTTP.CSRF (). disable ();
			Http.httpbasic ();
		Return }*/http. Formlogin (). LoginPage ("/login.html"). Loginprocessingurl ("/login"). Permitall ()-logout (). Lo Gouturl ("/logout"). and (). Authorizerequests (). Antmatchers ("/login.html", "/**/*.css", "/img/**", "/api/**")
		Release "/api/**": in order to be monitored by the end of login registration. Permitall (). and (). Authorizerequests (). Antmatchers ("/**"). authenticated ();
		HTTP.CSRF (). disable ();

	Http.httpbasic (); /* @Autowired///can also configure the login account password in the Application.yml file: Security.user.name/password public void Configureglobal ( Authenticationmanagerbuilder auth) throws Exception {auth. inmemoryAuthentication (). Withuser ("Svcadmin"). Password ("PW"). Roles ("USER"); }*/
}

APPLICATION.YML:
Security:
  User:
    name:sba
    password:passwd

3, Login page:
 



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.