【问题标题】:How to add standard Spring security to Spring Boot Admin (2.1.4)如何将标准 Spring 安全性添加到 Spring Boot Admin (2.1.4)
【发布时间】:2019-09-06 04:03:59
【问题描述】:

遵循参考指南为 Spring Boot 管理员 (https://codecentric.github.io/spring-boot-admin/current/) 添加安全性,但在启动应用程序时总是会获得标准登录页面,我无法绕过(并且不确定如何这样做 - 在哪里添加添加登录凭据等等)。现在想设置具有基本安全性的 Spring Boot Admin。

  1. 创建了一个具有“Spring Boot Admin”和“Spring Security”依赖项的标准启动应用程序
  2. 将项目导入IDE并在主类中添加@EnableAdminServer注解并运行

注意:

1) 没有向 application.properties 添加任何内容 2)还尝试了使用https://www.baeldung.com/spring-boot-admin的方法,其中使用WebSecurity config显示登录页面,但这会导致出现2个登录窗口(一个作为弹出窗口,第二个作为主页)


package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import de.codecentric.boot.admin.server.config.EnableAdminServer;

@EnableAdminServer
@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

Pom: http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.4.发布 com.example 演示 0.0.1-快照 演示 Spring Boot 演示项目

<properties>
    <java.version>1.8</java.version>
    <spring-boot-admin.version>2.1.4</spring-boot-admin.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-server</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-dependencies</artifactId>
            <version>${spring-boot-admin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

希望通过最基本的 Spring Security(使用 Spring Boot 2.x)来保护 Spring Boot Admin

【问题讨论】:

    标签: spring-boot-admin


    【解决方案1】:

    但这会导致出现 2 个登录窗口(一个作为弹出窗口,第二个作为主页)

    我遇到了这个问题,我通过更改 spring-boot-admin 的版本来解决它。

    2.1.6 可用时,您正在使用2.1.4

    尝试更改版本号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-17
      • 2021-07-14
      • 2016-05-14
      • 2017-07-02
      • 1970-01-01
      相关资源
      最近更新 更多