spring boot admin showing only details tab - spring-boot

I am not getting any other tabs like Environment,Loggers.Threads,Traces etc.. Except Details tab in Spring Boot Admin page.I have created the following micro services.
1)EurekaServer
2)ZuulGateway
3)Eurekaclient --2 instances
For all microservies only details tab is showing.
I am new to microservices.Any one please explain me and resolve my problem.Thank you.
admin-client properties:
#mongodb
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=Quickfix1
#logging
logging.level.org.springframework.data=debug
logging.level.=error
eureka.client.enabled=true
server.port=${PORT:0}
eureka.instance.instance-id=${spring.application.name}:${spring.application.instance_id:${random.value}}
eureka.client.serviceUrl.defaultZone=http://localhost:8090/eureka
spring.application.name=EurekaClientOne
spring.boot.admin.client.enabled=true
spring.boot.admin.client.url=http://localhost:8099
spring.boot.admin.client.username=admin
spring.boot.admin.client.password=admin
logging.level.de.codecentric.boot.admin.client=DEBUG
Admin server properties:
spring.application.name=Boot-Admin
server.port=8099
spring.security.user.name=admin
spring.security.user.password=admin

Please add below properties in your clients application property file/yml:
management.endpoints.web.exposure.include=*
Please let me know if it works :)

I have had a similar issue. On my spring boot application we had a cors filter to block Http Head requests. So head requests cannot be accepted.
Check Javascript console log.
Check your application filters which is blocking Http HEAD requests.
Setting management.security.enabled=false in the application.properties also necessary.

Related

Setting end session endpoint

With a Spring Boot client configured in the DMZ and Spring Security OAuth configured using:
issuer-uri: https://authentication_server/auth/realms/my-realm
I get this error from Spring Security:
The Issuer "https://external_url/auth/realms/my-realm" provided in the configuration metadata did not match the requested issuer "https://authentication_server/auth/realms/my-realm
From this post I have learned that I need to specify authorization-uri, token-uri and jwk-set-uri instead of issuer-uri, and then it also works.
authorization-uri: https://external_url/auth/realms/my-realm/protocol/openid-connect/auth
token-uri: https://authentication_server/auth/realms/my-realm/protocol/openid-connect/token
jwk-set-uri: https://authentication_server/auth/realms/my-realm/protocol/openid-connect/certs
(I do not get why Spring Security cannot auto-configure with the same values from the issuer-uri when it works setting the values individually)
Now the problem is that logout stops working. When using issuer-uri the OAuth is auto-configured and end_session_endpoint is fetched from the answer, but when specifying each setting there is no way to specify the end_session_endpoint.
Is this an outstanding issue in Spring Security OAuth, or do I need to configure it differently?
I had to make a work around for this. With little time I started by copying the existing OidcClientInitiatedLogoutSuccessHandler which I already were using in configuring LogoutRedirectUri.
I simply copied the class and changed the implementation of the method endSessionEndpoint() to return the URI which is returned by our OAuth server as end_session_endpoint.
This issue is tracked in spring-security GitHub.
Probable fix will be allowing to add "Additional attributes for ClientRegistration and ProviderDetails".

web.cors.allowed-origins in application.properties isn't allowing the CORS for specific urls

I'm trying to enable the CORS throughout the app for "http://localhost/4200". Since I'm using Springboot 2 and accord. to its docs, I just have to add this property in application.properties file:
management.endpoints.web.cors.allowed-origins=http://localhost:4200
But this doesn't work. Secondly since there is a request I'm making through a restController, for the testing purpose, I tried to add the inline :
CrossOrigin(origins = "http://localhost:4401")
This allowed the flow of data through 4401 port too.
It is not possible to set CORS settings from the application.properties file.
The property management.endpoints.web.cors.allowed-origins is related to Spring Actuator.
If you want to use the setting for a specific endpoint, you can use the #CrossOrigin annotation as you mentioned in your question.
If you want to set a global policy for your application, you can add a configuration class / bean for setting the CORS settings.
See: https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc-cors
Related question:
Spring Boot enabling CORS by application.properties

SpringBoot ignoring security settings in application.properties

I'm trying to secure a simple SpringBoot application using the properties defined in application.properties.
I have added at the bottom of my application.properties:
security.user.name = user
security.user.password = password
When starting the application I can see in the logs that a default password is being generated:
Using generated security password: 7382afa7-aab1-4476-8ea7-aa3b2a9c51d6
When I try to access the Web application I can see that the credentials in application.properties are ignored. On the other hand the generated security password is still used. am I missing something?
Thanks
I think you are missing the "spring" namespace in the property file.
Check with this:
spring.security.user.password=password
spring.security.user.name=user

Spring Boot Actuator paths not enabled by default?

While updating my Spring Boot application to the latest build snapshot and I am seeing that none of the actuator endpoints are enabled by default. If I specify them to be enabled in application.properties, they show up.
1) Is this behavior intended? I tried searching for an issue to explain it but couldn't find one. Could somebody link me to the issue / documentation?
2) Is there a way to enable all the actuator endpoints? I often find myself using them during development and would rather not maintain a list of them inside my properties file.
Two parts to this answer:
"Is there a way to enable all the actuator endpoints?"
Add this property endpoints.enabled=true rather than enabling them individually with endpoints.info.enabled=true, endpoints.beans.enabled=true etc
Update: for Spring Boot 2.x the relevant property is:
endpoints.default.web.enabled=true
"Is this behavior intended?"
Probably not. Sounds like you might have spotted an issue with the latest milestone. If you have a reproducible issue with a Spring Boot milestone then Spring's advice is ...
Reporting Issues
Spring Boot uses GitHub’s integrated issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:
Before you log a bug, please search the issue tracker to see if someone has already reported the problem.
If the issue doesn’t already exist, create a new issue.
Even if we enable all the actuator endpoints as below
management.endpoints.web.exposure.include=* (In case of YAML the star character should be surrounded by double quotes as "*" because star is one of the special characters in YAML syntax)
The httptrace actuator endpoint will still not be enabled in web by default. HttpTraceRepository interface need to be implemented to enable httptrace (See Actuator default endpoints, Actuator endpoints, Actuator httptrace).
#Component
public class CustomHttpTraceRepository implements HttpTraceRepository {
AtomicReference<HttpTrace> lastTrace = new AtomicReference<>();
#Override
public List<HttpTrace> findAll() {
return Collections.singletonList(lastTrace.get());
}
#Override
public void add(HttpTrace trace) {
if ("GET".equals(trace.getRequest().getMethod())) {
lastTrace.set(trace);
}
}
}
Now the endpoints can be accessed using the url,
http://localhost:port/actuator/respective-actuator-endpoint
(Example http://localhost:8081/actuator/httptrace)
If there is a management.servlet.context-path value present in properties file then the URL will be,
http://localhost:port/<servlet-context-path>/respective-actuator-endpoint
(Example http://localhost:8081/management-servlet-context-path-value/httptrace)
UPDATE: use this only in dev environment, not in production!
Is there a way to enable all the actuator endpoints?
Using Spring Boot 2.2.2 Release, this worked for me:
On the file src/main/resources/application.properties add this:
management.endpoints.web.exposure.include=*
To check enabled endpoints go to http://localhost:8080/actuator
Source: docs.spring.io

Debugging facebook authentication using Spring Security / Social

I'm using Spring Security (4.0.1) and Spring Social (1.1.2) to implement authentication to a Spring MVC application using either a Form of using an existing facebook account. Form authentication is working perfectly. However, facebook authentication is not working.
As far as I can see, I've setup the pieces needed to make this work:
created a class that implements SocialConfigurer, adding the facebook connection factory, useridsource (existing AuthenticationNameUserIdSource) and usersconnectionrepository (custom made for use with OrientDB)
Added a line to apply SpringSocialConfigurer in my WebSecurityConfigurerAdapter
Added a SocialUserDetailsService bean
This seems to be working for the most part, but the authentication is not completed. When calling /auth/facebook, the following happens:
redirect to facebook.com oauth (login mechanism)
callback to /auth/facebook on my application, with a lengthy code variable and state variable
redirect to my defaultFailureUrl, without warning, error or any message in log or request variables
So there is something going wrong, but I can't determine what or where exactly.
I've tried to set logging for org.springframework.social to FINEST, but that doesn't show any messages.
Does anyone have any tips how to determine the cause of this failure to complete authentication using facebook?
Thanks in advance,
Sem
I found the answer to my question, I had to configure log4j correctly in order to receive all of Spring's log messages in my default server log.
These log messages helped me to determine the issue at hand: my app signature had been changed. Quite an awkward issue to be stuck with for a long time ..
Hope this helps someone else struggling with Spring issues, make sure you have log4j included in your project, create a log4j properties file and make sure it is available to your container.
For me the following configuration worked:
log4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
I put it in the domain config for my glassfish domain, and added it to the JVM options using the Dlog4j.configuration property.
Regards,
Sem

Resources