spring - Togglz 控制台错误 403 Spring Boot

标签 spring spring-boot togglz

我正在尝试在 Spring Boot 上运行 Togglz 控制台,但我在屏幕上看到了这个:

(type=Forbidden, status=403). You are not allowed to access the Togglz Console.

我只是注意到很多人都有同样的问题,一些解决方案对他们有用。但我不明白我做错了什么。

这是我的代码:

我的功能
  public enum MyFeatures implements Feature {

    @EnabledByDefault
    @Label("The list of employees can be displayed")
    SHOW_LIST,

    @Label("Second Feature")
    FEATURE_TWO;

    public boolean isActive() {
        return FeatureContext.getFeatureManager().isActive(this);
    }


@Bean
public FeatureProvider featureProvider() {
    return new EnumBasedFeatureProvider(MyFeatures.class);
}}

我的Togglz配置
public class MyTogglzConfiguration implements TogglzConfig {
@Override
public Class<? extends Feature> getFeatureClass() {
    return null;
}

@Override
public StateRepository getStateRepository() {
    return null;
}


@Override
public UserProvider getUserProvider() {
    return new UserProvider() {
        @Override
        public FeatureUser getCurrentUser() {
            return new SimpleFeatureUser("admin", true);
        }
    };
}}

我的依赖:
<dependency>
        <groupId>org.togglz</groupId>
        <artifactId>togglz-console</artifactId>
        <version>2.3.0.RC1</version>
    </dependency>
    <dependency>
        <groupId>org.togglz</groupId>
        <artifactId>togglz-spring-boot-starter</artifactId>
        <version>2.3.0.Final</version>
</dependency>

应用程序属性
togglz:
enabled:true # Enable Togglz for the application.
feature-enums:# Comma-separated list of fully-qualified feature enum class names.
feature-manager-name:# The name of the feature manager.
features:# The feature states. Only needed if feature states are stored in application properties.
HELLO_WORLD:true
REVERSE_GREETING:true
REVERSE_GREETING.strategy:username
REVERSE_GREETING.param.users:user2, user3
features-file:# The path to the features file that contains the feature states. Only needed if feature states are stored in external properties file.
features-file-min-check-interval:# The minimum amount of time in milliseconds to wait between checks of the file's modification date.
cache:
enabled:false # Enable feature state caching.
time-to-live:0 # The time after which a cache entry will expire.
time-unit:milliseconds # The time unit as java.util.concurrent.TimeUnit enum name (one of "nanoseconds", "microseconds", "milliseconds", "seconds", "minutes", "hours", "days").
console:
enabled:true # Enable admin console.
path:/togglz-console # The path of the admin console when enabled.
feature-admin-authority:ROLE_ADMIN # The name of the authority that is allowed to access the admin console.
secured:false # Indicates if the admin console runs in secured mode. If false the application itself should take care of securing the admin console.
endpoint:
id:togglz # The endpoint identifier.
enabled:true # Enable actuator endpoint.
sensitive:true # Indicates if the endpoint exposes sensitive information.

如果有人可以帮助我,我将不胜感激。

谢谢!

最佳答案

我已经发现我做错了什么,所以我的提示:

  1. No need for MyTogglzConfiguration class
  2. Change application.properties to application.yml
  3. Use either Spring Security for togglz-console or make is disabled.


我更新的应用程序属性 (application.yml):
   togglz.console.enabled: true

   togglz:
     feature-enums: service.Features
     console:
      path: /togglz-console
      secured: false

关于spring - Togglz 控制台错误 403 Spring Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39343417/

相关文章:

java - Togglz: JDBCStateRepository.Builder 中的 noCommit 选项,它有什么作用?

java - 如何在jsp中检查togglz的 Activity 和非 Activity 状态?

java - Spring 4方法拦截器并使用自定义实现

将war部署到tomcat时的Spring MVC Servlet

java - 在 Spring 中配置 ObjectMapper

java - 如何在云 Jelastic 上使用 PostgreSQL 部署 Spring Boot 应用程序?

java - 使用 SnakeYaml 将 java 对象写入文件 - 使用 Yaml.dump() 时不会写出内部对象列表

java - Spring RowMapper NullPointerException

java - @SpringBootTest + @BeforeAll

spring - 在 tomcat 上部署 Togglz Spring Boot 时出错