问题
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