Skip to content

Commit f584ed3

Browse files
authored
Update all samples (#764)
1 parent 8ef1cca commit f584ed3

File tree

1,065 files changed

+3088
-61390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,065 files changed

+3088
-61390
lines changed

.github/workflows/ci.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build-with-maven:
1010
strategy:
1111
matrix:
12-
java-version: ['8', '11', '17']
12+
java-version: ['21', '17']
1313
runs-on: ubuntu-latest
1414
name: Build with Java ${{ matrix.java-version }}
1515
steps:
@@ -20,9 +20,6 @@ jobs:
2020
java-version: ${{ matrix.java-version }}
2121
distribution: 'adopt'
2222
cache: maven
23-
- name: Build azure-spring-boot-samples 4.x with Maven - Java ${{ matrix.java-version }}
24-
run: mvn -f pom.xml -P spring-cloud-azure-4.x --batch-mode --update-snapshots verify
25-
- if: ${{ (matrix.java-version == '17') }}
26-
name: Build azure-spring-boot-samples 5.x with Maven - ${{ matrix.java-version }}
23+
- name: Build azure-spring-boot-samples 5.x with Maven - ${{ matrix.java-version }}
2724
run: mvn -f pom.xml --batch-mode --update-snapshots verify
2825

.github/workflows/markdown-link-check.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on: [push, pull_request]
44

55
jobs:
66
markdown-link-check:
7-
runs-on: ubuntu-latest
7+
runs-on: ubuntu-22.04 #workaround https://github.com/UmbrellaDocs/action-linkspector/issues/32
88
steps:
9-
- uses: actions/checkout@master
10-
- uses: umbrelladocs/[email protected]
11-
with:
9+
- uses: actions/checkout@master
10+
- uses: umbrelladocs/[email protected]
11+
with:
1212
reporter: github-pr-review
1313
config_file: '.github/workflows/.linkspector.yml'
1414
level: error

CONVERT_SAMPLE_TO_USE_SPRING_BOOT_3_TEMPLATE.md

-9
This file was deleted.

README.md

+210-125
Large diffs are not rendered by default.

aad/spring-cloud-azure-starter-active-directory-b2c/aad-b2c-resource-server/pom.xml

+24-5
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,37 @@
44
<modelVersion>4.0.0</modelVersion>
55

66
<parent>
7-
<groupId>com.azure.spring</groupId>
8-
<artifactId>azure-spring-boot-samples</artifactId>
9-
<version>1.0.0</version>
10-
<relativePath>../../../pom.xml</relativePath>
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-starter-parent</artifactId>
9+
<version>3.4.0</version>
10+
<relativePath/> <!-- lookup parent from repository -->
1111
</parent>
1212

13-
<artifactId>spring-cloud-azure-starter-active-directory-b2c-resource-server</artifactId>
13+
<groupId>com.azure.spring</groupId>
14+
<artifactId>aad-b2c-resource-server</artifactId>
1415
<version>1.0.0</version>
1516
<packaging>jar</packaging>
1617

1718
<name>Spring-Cloud-Azure-Starter-Active-Directory-B2C Sample: Resource Server</name>
1819

20+
<properties>
21+
<maven.compiler.source>17</maven.compiler.source>
22+
<maven.compiler.target>17</maven.compiler.target>
23+
<version.spring.cloud.azure>5.19.0</version.spring.cloud.azure>
24+
</properties>
25+
26+
<dependencyManagement>
27+
<dependencies>
28+
<dependency>
29+
<groupId>com.azure.spring</groupId>
30+
<artifactId>spring-cloud-azure-dependencies</artifactId>
31+
<version>${version.spring.cloud.azure}</version>
32+
<type>pom</type>
33+
<scope>import</scope>
34+
</dependency>
35+
</dependencies>
36+
</dependencyManagement>
37+
1938
<dependencies>
2039
<dependency>
2140
<groupId>com.azure.spring</groupId>

aad/spring-cloud-azure-starter-active-directory-b2c/aad-b2c-resource-server/src/main/java/com/azure/spring/sample/aad/b2c/security/WebSecurityConfiguration.java

+21-11
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,31 @@
33

44
package com.azure.spring.sample.aad.b2c.security;
55

6-
import com.azure.spring.cloud.autoconfigure.aad.AadJwtBearerTokenAuthenticationConverter;
7-
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
89
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
910
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
10-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
11+
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
12+
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
13+
import org.springframework.security.web.SecurityFilterChain;
1114

1215
@EnableWebSecurity
13-
@EnableGlobalMethodSecurity(prePostEnabled = true)
14-
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
16+
@EnableMethodSecurity
17+
@Configuration
18+
public class WebSecurityConfiguration {
1519

16-
@Override
17-
protected void configure(HttpSecurity http) throws Exception {
18-
http.authorizeRequests((requests) -> requests.anyRequest().authenticated())
19-
.oauth2ResourceServer()
20-
.jwt()
21-
.jwtAuthenticationConverter(new AadJwtBearerTokenAuthenticationConverter());
20+
@Bean
21+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
22+
JwtAuthenticationConverter authenticationConverter = new JwtAuthenticationConverter();
23+
JwtGrantedAuthoritiesConverter jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
24+
jwtGrantedAuthoritiesConverter.setAuthorityPrefix("APPROLE_");
25+
authenticationConverter.setJwtGrantedAuthoritiesConverter(jwtGrantedAuthoritiesConverter);
26+
27+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated())
28+
.oauth2ResourceServer(configure -> configure
29+
.jwt(jwt -> jwt.jwtAuthenticationConverter(authenticationConverter)));
30+
31+
return http.build();
2232
}
2333
}

aad/spring-cloud-azure-starter-active-directory-b2c/aad-b2c-resource-server/src/main/resources/application.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# In v2.0 tokens, `aud` is always the client ID of the API, while in v1.0 tokens it can be the resource URI used in the request.
22

33
spring:
4+
http:
5+
client:
6+
factory: jdk
47
cloud:
58
azure:
69
# Properties like spring.cloud.azure.credential.client-id are global properties.

aad/spring-cloud-azure-starter-active-directory-b2c/aad-b2c-web-application/pom.xml

+25-6
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,39 @@
44
<modelVersion>4.0.0</modelVersion>
55

66
<parent>
7-
<groupId>com.azure.spring</groupId>
8-
<artifactId>azure-spring-boot-samples</artifactId>
9-
<version>1.0.0</version>
10-
<relativePath>../../../pom.xml</relativePath>
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-starter-parent</artifactId>
9+
<version>3.4.0</version>
10+
<relativePath/> <!-- lookup parent from repository -->
1111
</parent>
1212

13-
<artifactId>spring-cloud-azure-starter-active-directory-b2c-oidc</artifactId>
13+
<groupId>com.azure.spring</groupId>
14+
<artifactId>aad-b2c-web-application</artifactId>
1415
<version>1.0.0</version>
1516
<packaging>jar</packaging>
1617

1718
<name>Spring-Cloud-Azure-Starter-Active-Directory-B2C Sample: Web Application</name>
1819
<description>Azure Active Directory B2C Spring Security 5 OAuth2 Integration Spring Boot Sample</description>
1920
<url>https://github.com/Azure/azure-sdk-for-java</url>
2021

22+
<properties>
23+
<maven.compiler.source>17</maven.compiler.source>
24+
<maven.compiler.target>17</maven.compiler.target>
25+
<version.spring.cloud.azure>5.19.0</version.spring.cloud.azure>
26+
</properties>
27+
28+
<dependencyManagement>
29+
<dependencies>
30+
<dependency>
31+
<groupId>com.azure.spring</groupId>
32+
<artifactId>spring-cloud-azure-dependencies</artifactId>
33+
<version>${version.spring.cloud.azure}</version>
34+
<type>pom</type>
35+
<scope>import</scope>
36+
</dependency>
37+
</dependencies>
38+
</dependencyManagement>
39+
2140
<dependencies>
2241
<dependency>
2342
<groupId>com.azure.spring</groupId>
@@ -41,7 +60,7 @@
4160

4261
<dependency>
4362
<groupId>org.thymeleaf.extras</groupId>
44-
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
63+
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
4564
</dependency>
4665
</dependencies>
4766
</project>

aad/spring-cloud-azure-starter-active-directory-b2c/aad-b2c-web-application/src/main/java/com/azure/spring/sample/aad/b2c/security/WebSecurityConfiguration.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33

44
package com.azure.spring.sample.aad.b2c.security;
55

6-
import com.azure.spring.cloud.autoconfigure.aadb2c.AadB2cOidcLoginConfigurer;
6+
import com.azure.spring.cloud.autoconfigure.implementation.aadb2c.security.AadB2cOidcLoginConfigurer;
7+
import org.springframework.context.annotation.Bean;
8+
import org.springframework.context.annotation.Configuration;
79
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
810
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
9-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
11+
import org.springframework.security.web.SecurityFilterChain;
1012

1113
@EnableWebSecurity
12-
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
14+
@Configuration
15+
public class WebSecurityConfiguration {
1316

1417
private final AadB2cOidcLoginConfigurer configurer;
1518

1619
public WebSecurityConfiguration(AadB2cOidcLoginConfigurer configurer) {
1720
this.configurer = configurer;
1821
}
1922

20-
@Override
21-
protected void configure(HttpSecurity http) throws Exception {
22-
// @formatter:off
23-
http.authorizeRequests()
24-
.anyRequest().authenticated()
25-
.and()
26-
.apply(configurer);
27-
// @formatter:on
23+
@Bean
24+
public SecurityFilterChain filterChain (HttpSecurity http) throws Exception {
25+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated())
26+
.with(configurer, c -> {});
27+
return http.build();
2828
}
2929
}

aad/spring-cloud-azure-starter-active-directory-b2c/aad-b2c-web-application/src/main/resources/application.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
spring:
2+
http:
3+
client:
4+
factory: jdk
25
cloud:
36
azure:
47
# Properties like spring.cloud.azure.credential.client-id are global properties.

aad/spring-cloud-azure-starter-active-directory/aad-resource-server-by-filter-stateless/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Key concepts
44

5-
This demo project explains the usage of the stateless authentication filter `AadAppRoleStatelessAuthenticationFilter`.
5+
This demo project explains the usage of the stateless authentication filter `AadAppRoleStatelessAuthenticationFilter`.
66
This project is composed of a vue.js frontend and a simple backend with three endpoints
77
* `/public` (accessible by anyone)
88
* `/authorized` (role "UserRule" required)
@@ -57,7 +57,7 @@ For the test SPA provided with this example you should create the following role
5757

5858
After you've created the roles, go to **Microsoft Entra ID** and select **Users** to add two new users named "Admin" and "UserRule". Then back to select **Enterprise applications** in the left-hand navigation pane, click on your created application and select **Users and groups**, finally assign the new roles to your new Users (assignment of roles to groups is not available in the free tier of Microsoft Entra ID).
5959

60-
Furthermore enable the implicit flow in the manifest for the demo application
60+
Furthermore, enable the implicit flow in the manifest for the demo application
6161
(or if you have SPAs calling you):
6262

6363
```

aad/spring-cloud-azure-starter-active-directory/aad-resource-server-by-filter-stateless/pom.xml

+24-6
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,39 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<parent>
8-
<groupId>com.azure.spring</groupId>
9-
<artifactId>azure-spring-boot-samples</artifactId>
10-
<version>1.0.0</version>
11-
<relativePath>../../../pom.xml</relativePath>
8+
<groupId>org.springframework.boot</groupId>
9+
<artifactId>spring-boot-starter-parent</artifactId>
10+
<version>3.4.0</version>
11+
<relativePath/> <!-- lookup parent from repository -->
1212
</parent>
1313

14-
<artifactId>spring-cloud-azure-starter-active-directory-resource-server-by-filter-stateless</artifactId>
14+
<groupId>com.azure.spring</groupId>
15+
<artifactId>aad-resource-server-by-filter-stateless</artifactId>
1516
<version>1.0.0</version>
1617
<packaging>jar</packaging>
1718

1819
<name>Spring-Cloud-Azure-Starter-Active-Directory Sample: Stateless Resource Server by Filter</name>
1920
<description>Sample project using the Microsoft Entra ID stateless app-role filter for Microsoft Entra ID integration in Spring Security</description>
2021
<url>https://github.com/Azure/azure-sdk-for-java</url>
2122

23+
<properties>
24+
<maven.compiler.source>17</maven.compiler.source>
25+
<maven.compiler.target>17</maven.compiler.target>
26+
<version.spring.cloud.azure>5.19.0</version.spring.cloud.azure>
27+
</properties>
28+
29+
<dependencyManagement>
30+
<dependencies>
31+
<dependency>
32+
<groupId>com.azure.spring</groupId>
33+
<artifactId>spring-cloud-azure-dependencies</artifactId>
34+
<version>${version.spring.cloud.azure}</version>
35+
<type>pom</type>
36+
<scope>import</scope>
37+
</dependency>
38+
</dependencies>
39+
</dependencyManagement>
40+
2241
<dependencies>
2342
<dependency>
2443
<groupId>com.azure.spring</groupId>
@@ -41,5 +60,4 @@
4160
<artifactId>spring-security-oauth2-jose</artifactId>
4261
</dependency>
4362
</dependencies>
44-
4563
</project>

aad/spring-cloud-azure-starter-active-directory/aad-resource-server-by-filter-stateless/src/main/java/com/azure/spring/sample/aad/security/AadWebSecurityConfig.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,38 @@
33

44
package com.azure.spring.sample.aad.security;
55

6-
import com.azure.spring.cloud.autoconfigure.aad.filter.AadAppRoleStatelessAuthenticationFilter;
6+
import com.azure.spring.cloud.autoconfigure.implementation.aad.filter.AadAppRoleStatelessAuthenticationFilter;
77
import org.springframework.beans.factory.annotation.Autowired;
8-
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.Configuration;
10+
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
911
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
1012
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
11-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
13+
import org.springframework.security.config.annotation.web.configurers.CsrfConfigurer;
1214
import org.springframework.security.config.http.SessionCreationPolicy;
15+
import org.springframework.security.web.SecurityFilterChain;
1316
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1417

1518
@EnableWebSecurity
16-
@EnableGlobalMethodSecurity(prePostEnabled = true)
17-
public class AadWebSecurityConfig extends WebSecurityConfigurerAdapter {
19+
@EnableMethodSecurity(prePostEnabled = true)
20+
@Configuration
21+
public class AadWebSecurityConfig {
1822

1923
@Autowired
2024
private AadAppRoleStatelessAuthenticationFilter aadAuthFilter;
2125

22-
@Override
23-
protected void configure(HttpSecurity http) throws Exception {
24-
http.csrf().disable();
26+
@Bean
27+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
2528

26-
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);
27-
28-
http.authorizeRequests()
29-
.antMatchers("/admin/**").hasRole("Admin")
30-
.antMatchers("/", "/index.html", "/public").permitAll()
31-
.anyRequest().authenticated();
32-
33-
http.addFilterBefore(aadAuthFilter, UsernamePasswordAuthenticationFilter.class);
29+
http.csrf(CsrfConfigurer::disable)
30+
.sessionManagement(configurer ->
31+
configurer.sessionCreationPolicy(SessionCreationPolicy.NEVER))
32+
.authorizeHttpRequests(request -> request
33+
.requestMatchers("/admin/**").hasRole("Admin")
34+
.requestMatchers("/", "/index.html", "/public").permitAll()
35+
.anyRequest().authenticated())
36+
.addFilterBefore(aadAuthFilter, UsernamePasswordAuthenticationFilter.class);
3437

38+
return http.build();
3539
}
3640
}

aad/spring-cloud-azure-starter-active-directory/aad-resource-server-by-filter-stateless/src/main/resources/application.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
spring:
3+
http:
4+
client:
5+
factory: jdk
36
cloud:
47
azure:
58
# Properties like spring.cloud.azure.credential.client-id are global properties.

0 commit comments

Comments
 (0)