Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all samples #764

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6d92f8c
update and fix
Netyyyy Dec 24, 2024
13a0870
update pom
Netyyyy Dec 26, 2024
0a982b6
update ci
Netyyyy Dec 26, 2024
ff07aa2
update pom
Netyyyy Dec 26, 2024
9e5a1ae
update readme
Netyyyy Dec 30, 2024
277645c
add aad samples
Netyyyy Dec 30, 2024
7b7e055
update login sample
Netyyyy Jan 2, 2025
98668b3
update filter sample
Netyyyy Jan 3, 2025
2338ec6
update stateless sample
Netyyyy Jan 3, 2025
e6465b1
update web/resource samples
Netyyyy Jan 6, 2025
9801ae0
update web resource samples
Netyyyy Jan 7, 2025
a5bf4ec
update b2c samples
Netyyyy Jan 8, 2025
bee8bf4
update
Netyyyy Jan 8, 2025
1cdf092
update reactive sample
Netyyyy Jan 8, 2025
026e241
update multiple sample
Netyyyy Jan 8, 2025
338e97c
update client resource sample
Netyyyy Jan 8, 2025
3a78b7d
update
Netyyyy Jan 8, 2025
340818a
update
Netyyyy Jan 9, 2025
d52f68d
update
Netyyyy Jan 10, 2025
3da42d4
update
Netyyyy Jan 10, 2025
41d657a
update
Netyyyy Jan 10, 2025
1c3ccc8
update name
Netyyyy Jan 10, 2025
5d65656
update name
Netyyyy Jan 10, 2025
046b790
update
Netyyyy Jan 10, 2025
8de1213
update readme
Netyyyy Jan 13, 2025
9800c22
update
Netyyyy Jan 13, 2025
6cd2a0d
update
Netyyyy Jan 13, 2025
2995f6c
update
Netyyyy Jan 13, 2025
ceac576
fix
Netyyyy Jan 13, 2025
575220b
fix
Netyyyy Jan 13, 2025
cecba2e
fix
Netyyyy Jan 13, 2025
629b6c6
fix
Netyyyy Jan 14, 2025
df7a49e
fix
Netyyyy Jan 14, 2025
a70ccf2
fix
Netyyyy Jan 14, 2025
8179e8e
fix
Netyyyy Jan 14, 2025
2fc7eec
fix
Netyyyy Jan 14, 2025
04f6e9e
update
Netyyyy Jan 14, 2025
827d6de
update
Netyyyy Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build-with-maven:
strategy:
matrix:
java-version: ['8', '11', '17']
java-version: ['21', '17']
runs-on: ubuntu-latest
name: Build with Java ${{ matrix.java-version }}
steps:
Expand All @@ -20,9 +20,6 @@ jobs:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
cache: maven
- name: Build azure-spring-boot-samples 4.x with Maven - Java ${{ matrix.java-version }}
run: mvn -f pom.xml -P spring-cloud-azure-4.x --batch-mode --update-snapshots verify
- if: ${{ (matrix.java-version == '17') }}
name: Build azure-spring-boot-samples 5.x with Maven - ${{ matrix.java-version }}
- name: Build azure-spring-boot-samples 5.x with Maven - ${{ matrix.java-version }}
run: mvn -f pom.xml --batch-mode --update-snapshots verify

8 changes: 4 additions & 4 deletions .github/workflows/markdown-link-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on: [push, pull_request]

jobs:
markdown-link-check:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04 #workaround https://github.com/UmbrellaDocs/action-linkspector/issues/32
steps:
- uses: actions/checkout@master
- uses: umbrelladocs/[email protected]
with:
- uses: actions/checkout@master
- uses: umbrelladocs/[email protected]
with:
reporter: github-pr-review
config_file: '.github/workflows/.linkspector.yml'
level: error
Expand Down
9 changes: 0 additions & 9 deletions CONVERT_SAMPLE_TO_USE_SPRING_BOOT_3_TEMPLATE.md

This file was deleted.

335 changes: 210 additions & 125 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,39 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-samples</artifactId>
<version>1.0.0</version>
<relativePath>../../../pom.xml</relativePath>
</parent>

<artifactId>spring-cloud-azure-starter-active-directory-b2c-resource-server</artifactId>
<groupId>com.azure.spring</groupId>
<artifactId>aad-b2c-resource-server</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

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

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<version.spring.boot>3.4.0</version.spring.boot>
<version.spring.cloud.azure>5.19.0</version.spring.cloud.azure>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring.boot}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>${version.spring.cloud.azure}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.azure.spring</groupId>
Expand All @@ -26,4 +46,14 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${version.spring.boot}</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@

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

import com.azure.spring.cloud.autoconfigure.aad.AadJwtBearerTokenAuthenticationConverter;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
import org.springframework.security.web.SecurityFilterChain;

@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@EnableMethodSecurity
@Configuration
public class WebSecurityConfiguration {

@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests((requests) -> requests.anyRequest().authenticated())
.oauth2ResourceServer()
.jwt()
.jwtAuthenticationConverter(new AadJwtBearerTokenAuthenticationConverter());
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
JwtAuthenticationConverter authenticationConverter = new JwtAuthenticationConverter();
JwtGrantedAuthoritiesConverter jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
jwtGrantedAuthoritiesConverter.setAuthorityPrefix("APPROLE_");
authenticationConverter.setJwtGrantedAuthoritiesConverter(jwtGrantedAuthoritiesConverter);

http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated())
.oauth2ResourceServer(configure -> configure
.jwt(jwt -> jwt.jwtAuthenticationConverter(authenticationConverter)));

return http.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# 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.

spring:
http:
client:
factory: jdk
cloud:
azure:
# Properties like spring.cloud.azure.credential.client-id are global properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,41 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-samples</artifactId>
<version>1.0.0</version>
<relativePath>../../../pom.xml</relativePath>
</parent>

<artifactId>spring-cloud-azure-starter-active-directory-b2c-oidc</artifactId>
<groupId>com.azure.spring</groupId>
<artifactId>aad-b2c-web-application</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

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

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<version.spring.boot>3.4.0</version.spring.boot>
<version.spring.cloud.azure>5.19.0</version.spring.cloud.azure>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring.boot}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>${version.spring.cloud.azure}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.azure.spring</groupId>
Expand All @@ -41,7 +61,17 @@

<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${version.spring.boot}</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@

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

import com.azure.spring.cloud.autoconfigure.aadb2c.AadB2cOidcLoginConfigurer;
import com.azure.spring.cloud.autoconfigure.implementation.aadb2c.security.AadB2cOidcLoginConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.SecurityFilterChain;

@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Configuration
public class WebSecurityConfiguration {

private final AadB2cOidcLoginConfigurer configurer;

public WebSecurityConfiguration(AadB2cOidcLoginConfigurer configurer) {
this.configurer = configurer;
}

@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.apply(configurer);
// @formatter:on
@Bean
public SecurityFilterChain filterChain (HttpSecurity http) throws Exception {
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated())
.with(configurer, c -> {});
return http.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
spring:
http:
client:
factory: jdk
cloud:
azure:
# Properties like spring.cloud.azure.credential.client-id are global properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Key concepts

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

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).

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

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,41 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-samples</artifactId>
<version>1.0.0</version>
<relativePath>../../../pom.xml</relativePath>
</parent>

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

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

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<version.spring.boot>3.4.0</version.spring.boot>
<version.spring.cloud.azure>5.19.0</version.spring.cloud.azure>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring.boot}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>${version.spring.cloud.azure}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.azure.spring</groupId>
Expand All @@ -42,4 +62,13 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${version.spring.boot}</version>
</plugin>
</plugins>
</build>
</project>
Loading
Loading