Using Spring Boot's ENV variables from JHipster App

空扰寡人 提交于 2019-12-12 04:47:17

问题


I'm trying to figure out how to use the JhiConfigurationService from JHipster Angular App. I've managed to access the env variables using this service from the App after injecting the service into my Angular component but it only works if I'm logged in as an "admin" user. As soon as I switch to the normal user, the service won't return any values. I've found that there is an endpoint configuration for Spring Boot but in the existing application.yml configs there is nothing which would change the default behavior (sanitizing specific keywords).

Edit: I thought that there might be a way of telling spring which ENV variables it should allow to read without ADMIN role. Similar to endpoints.env.keys-to-sanitize from docs


回答1:


Just edit configure() method in SecurityConfiguration.java so that /management/env does not require ADMIN authority (order matters) but be careful to expose only safe data.

.antMatchers("/management/health").permitAll()
.antMatchers("/management/env").permitAll()
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)    


来源:https://stackoverflow.com/questions/43620898/using-spring-boots-env-variables-from-jhipster-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!