Spring security auto configuration not working in spring boot 2.1.2.RELEASE - spring-boot

I have included spring security dependency in pom.xml but the endpoints are not getting secured by default .This is happening in spring boot version 2.1.2.RELEASE but when i switched back to 2.0.3.RELEASE, spring security is auto configured and all the endpoints are secured
I am not even getting the following line when using 2.1.2.RELEASE
Using default security password: ce6c3d39-8f20-4a41-8e01-803166bb99b6
Dependency added in pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

Related

How to externalize spring.cloud.vault.* properties to a spring cloud config server

I am using spring boot 2.7.8
I am following this https://docs.spring.io/spring-cloud-vault/docs/current/reference/html/#client-side-usage and https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_client_side_usage
I have a spring cloud config server too which hosts the externalized properties for my application. So my pom.xml has below
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-vault-config</artifactId>
</dependency>
I can point to the external spring cloud config server using the below in my properties file
spring.config.import=optional:configserver:http://myconfigserver.com
But as per https://docs.spring.io/spring-cloud-vault/docs/current/reference/html/#client-side-usage, I still have to define spring.cloud.vault.* in my application properties? How can I move spring.cloud.vault.* properties into my spring cloud config server so that all my properties are externalized. I want to avoid having some properties within the application and some externalized.
Please help to clarify if I am misunderstanding this

Azure AppConfiguration with Spring Boot 2.5.x

Question
How to integrate an Azure AppConfiguration with SpringBoot 2.5.x or higher?
Info
Im trying to use an Azure AppConfiguration resource with a Spring Boot 2.5.4 project. Unfortunately I cant get it to read a setting from the AppConfiguration or even connect to it as far as I can tell.
The project is newly created with the Spring Initializr where I only added
Spring Boot Starter Web
Spring Boot Starter Security
Spring Boot Starter WebSocket
Afterwards I tried following the Microsoft Quickstart documentation with no success. The documentation mentions that its using Spring 2.4.x so I assume some changes broke it.
I also tried to identify the issue by looking through some Azure Spring Boot Code Samples.
All the examples so far use the bootstrap.properties file which I learned during my search so far is deprecated. Moving the settings to the application.yml or enabling use-legacy-processing: true did not work either. Any ideas?
pom.xml
...
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
...
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-cloud-appconfiguration-config</artifactId>
<version>2.0.0</version>
</dependency>
...
application.yml
spring:
config:
use-legacy-processing: true
profiles:
active: "develop"
application:
name: "MySampleService"
cloud:
azure:
appconfiguration:
stores:
- connection-string: "SomeAzureAppConfigurationResourceConnectionString"
label: ${spring.profiles.active}
#mysampleservice:
# message: "this is a message from file"
AppConfiguration Resource
Im not entirely sure about the format for the setting name. I tried to build the format based on this documentation.
The configuration classes should be fine since commenting in the mysampleservice causes the value of message beeing used.
Any hints are appreciated!
Some more info to elaborate on the accepted answer
The documentation linked in the answer refers to two different packages. The one linked right at the start in the maven repository is spring-cloud-azure-appconfiguration-config while the one used further down is azure-spring-cloud-appconfiguration-config. The second one works with the bootstrap.properties file.
Working pom.xml and bootstrap.properties:
...
<dependencies>
<!-- Dependency to load configuration from azure app configuration resource. Note that additional settings are required in bootstrap.properties
Documentation of settings: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/appconfiguration/azure-spring-cloud-starter-appconfiguration-config
-->
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-cloud-appconfiguration-config-web</artifactId>
<version>2.1.0</version>
</dependency>
...
# Use this to enable or disable the cloud config, disabling it results in application.yaml beeing used.
spring.cloud.azure.appconfiguration.enabled=true
# Connection string to azure app configuration resource
spring.cloud.azure.appconfiguration.stores[0].connection-string= Endpoint=https://myofficeconfiguration.azconfig.io;Id=zUcT-l9-s0:PFYfW7WM0/Pz7WZOnH3v;Secret=JTB9myJqGekDAJ5m8Z1vjmkJZrPd88JbOEE3EqoqJYs=
# Configured filters for settings in the previous defined app configuration resource
spring.cloud.azure.appconfiguration.stores[0].selects[0].key-filter = /mysampleservice/
spring.cloud.azure.appconfiguration.stores[0].selects[0].label-filter = Sample
spring.cloud.azure.appconfiguration.stores[0].selects[1].key-filter = /notificationservice/
spring.cloud.azure.appconfiguration.stores[0].selects[1].label-filter = Sample2
bootstrap.yml/bootstrap.properties can still be used, they are no longer part of the base Spring packages.
Also, you want to use this doc for 2.0.0 and newer https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/appconfiguration/azure-spring-cloud-starter-appconfiguration-config.

Spring boot 2 actuator without autoconfiguration

Can anyone help me to figure out how to enable actuator endpoints without using autoconfiguration dependencies?
I'm working on a Spring-Boot 2 project but starter poms and autocnfiguration dependencies are forbidden.
Try to adding this dependency :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
And add this on application.properties in order to enable all endpoints of actuator if you want enable all.
management.endpoints.web.exposure.include=*

Moving from Spring Boot 2.0.0.M6 to 2.0.0.M7 - dependencies.dependency.version' for org.springframework.social:spring-social-security:jar is missing

I'm trying to upgrade my application from Spring Boot 2.0.0.M6 to 2.0.0.M7
After upgrading my Maven application I ran into the following errors:
For example the following dependency
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-security</artifactId>
</dependency>
shows the following error:
Project build error: 'dependencies.dependency.version' for org.springframework.social:spring-social-security:jar is missing.
What am I doing wrong and how to fix it?
Dependency management and auto-configuration for Spring Social was removed from Spring Boot in 2.0 M7. The longer-term plan is for it to move into Spring Social itself but that has yet to happen.

Spring Boot 2 with actuator

i'm using spring boot 2.0.0.M3 with the spring-boot-starter-actuator. I enabled two health checks:
management.health.diskspace.enabled=true
management.health.mongo.enabled=true
The healt check beans are created by the auto configure, but not the HealthMvcEndpoint. The response of localhost:8080/health is 404.
What did I do wrong?
Thanks in advance
EDIT:
Mhm do the actuator project works with reactive and webflux?
Ok found this issue:
https://github.com/spring-projects/spring-boot/issues/7970
according to the documentations for 2.0.0M the actuator endpoints have been prefixed with /application so they become /application/health instead.
You should also be able to see all this in the info logs about the endpoints, when booting up your application
https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready-endpoints
also an actual release note about it:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0.0-M1-Release-Notes#actuator-default-mapping
I'm using webflux+springboot 2.0.2.RELEASE.
Checking the logs I found that it is actuallu under /actuator now.
so: http://localhost:8080/actuator/health will work
Add this to your application.properties file:
management.endpoints.web.base-path=/
The actuator endpoints will now be '/health'
Include the spring-boot-starter-web dependency in your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

Resources