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

Fix compilation error to update latest code on 4.0 branch #203

Merged
merged 6 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This sample illustrates how to use `azure-spring-boot-starter-active-directory-b

1. Constructs trusted iss by configuring tenant id.
2. Obtain the access token from the HTTP request header.
3. Analyze access token to `iss` and construct `JwtDecoder` by `AADIssuerJWSKeySelector`.
3. Analyze access token to `iss` and construct `JwtDecoder` by `AadIssuerJWSKeySelector`.
4. Use `JwtDecoder` to parse the access token into `Jwt`.
5. Verify `aud`, `iss`, `nbf`, `exp` claims in access token.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AzureADB2CResourceServerSampleApplication {
public class AadB2cResourceServerSampleApplication {

public static void main(String[] args) {
SpringApplication.run(AzureADB2CResourceServerSampleApplication.class, args);
SpringApplication.run(AadB2cResourceServerSampleApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

import com.azure.spring.cloud.autoconfigure.aad.implementation.webapi.AADJwtBearerTokenAuthenticationConverter;
import com.azure.spring.cloud.autoconfigure.aad.implementation.webapi.AadJwtBearerTokenAuthenticationConverter;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand All @@ -18,6 +18,6 @@ protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests((requests) -> requests.anyRequest().authenticated())
.oauth2ResourceServer()
.jwt()
.jwtAuthenticationConverter(new AADJwtBearerTokenAuthenticationConverter());
.jwtAuthenticationConverter(new AadJwtBearerTokenAuthenticationConverter());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AzureADB2COIDCSampleApplication {
public class AadB2cOidcSampleApplication {

public static void main(String[] args) {
//
SpringApplication.run(AzureADB2COIDCSampleApplication.class, args);
SpringApplication.run(AadB2cOidcSampleApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

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

import com.azure.spring.cloud.autoconfigure.aadb2c.AADB2COidcLoginConfigurer;
import com.azure.spring.cloud.autoconfigure.aadb2c.AadB2cOidcLoginConfigurer;
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;

@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

private final AADB2COidcLoginConfigurer configurer;
private final AadB2cOidcLoginConfigurer configurer;

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

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 "user" required)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AzureADOAuth2WebAppSampleApplication {
public class AadStatelessBackendSampleApplication {

public static void main(String[] args) {
SpringApplication.run(AzureADOAuth2WebAppSampleApplication.class, args);
SpringApplication.run(AadStatelessBackendSampleApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public String onlyAuthorizedUsers() {

@GetMapping("/admin/demo")
@ResponseBody
// For demo purposes for this endpoint we configure the required role in the AADWebSecurityConfig class.
// For demo purposes for this endpoint we configure the required role in the AadWebSecurityConfig class.
// However, it is advisable to use method level security with @PreAuthorize("hasRole('xxx')")
public String onlyForAdmins() {
return "admin endpoint";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

import com.azure.spring.cloud.autoconfigure.aad.filter.AADAppRoleStatelessAuthenticationFilter;
import com.azure.spring.cloud.autoconfigure.aad.filter.AadAppRoleStatelessAuthenticationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
Expand All @@ -14,10 +14,10 @@

@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class AADWebSecurityConfig extends WebSecurityConfigurerAdapter {
public class AadWebSecurityConfig extends WebSecurityConfigurerAdapter {

@Autowired
private AADAppRoleStatelessAuthenticationFilter aadAuthFilter;
private AadAppRoleStatelessAuthenticationFilter aadAuthFilter;

@Override
protected void configure(HttpSecurity http) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AzureADOAuth2WebAppAndResourceServerSampleApplication {
public class AadIntegrationSpringBootAutoconfigureSampleApplication {

public static void main(String[] args) {
SpringApplication.run(AzureADOAuth2WebAppAndResourceServerSampleApplication.class, args);
SpringApplication.run(AadIntegrationSpringBootAutoconfigureSampleApplication.class, args);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package com.azure.spring.sample.aad.controller;

import com.azure.spring.cloud.autoconfigure.aad.filter.UserPrincipal;
import com.azure.spring.cloud.autoconfigure.aad.properties.AADAuthenticationProperties;
import com.azure.spring.cloud.autoconfigure.aad.properties.AadAuthenticationProperties;
import com.azure.spring.sample.aad.model.TodoItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand All @@ -30,7 +30,7 @@
@RestController
public class TodoListController {
@Autowired
private AADAuthenticationProperties aadAuthenticationProperties;
private AadAuthenticationProperties aadAuthenticationProperties;

private final List<TodoItem> todoList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

import com.azure.spring.cloud.autoconfigure.aad.filter.AADAuthenticationFilter;
import com.azure.spring.cloud.autoconfigure.aad.filter.AadAuthenticationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
Expand All @@ -17,7 +17,7 @@
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Autowired
private AADAuthenticationFilter aadAuthFilter;
private AadAuthenticationFilter aadAuthFilter;

@Override
protected void configure(HttpSecurity http) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AADOAuth2ResourceServerOboSampleApplication {
public class AadOAuth2ResourceServerOboSampleApplication {

public static void main(String[] args) {
SpringApplication.run(AADOAuth2ResourceServerOboSampleApplication.class, args);
SpringApplication.run(AadOAuth2ResourceServerOboSampleApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
public class AADSampleConfiguration {
public class AadSampleConfiguration {

@Bean
public WebClient webClient(OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This sample illustrates how to protect a Java web API by restricting access to i
1. Obtain the access token from the HTTP request header.
2. Use `JwtDecoder` to parse the access token into `Jwt`.
3. Verify `aud`, `iss`, `nbf`, `exp` claims in access token.
4. Extract information from JWT in `AADOAuth2AuthenticatedPrincipal` object after a successful verification.
4. Extract information from JWT in `AadOAuth2AuthenticatedPrincipal` object after a successful verification.
5. Save the `AADOAuth2AuthenticatedPrincipal` into SecurityContext.

### Protocol diagram
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AzureADStatelessBackendSampleApplication {
public class AadOAuth2ResourceServerSampleApplication {

public static void main(String[] args) {
SpringApplication.run(AzureADStatelessBackendSampleApplication.class, args);
SpringApplication.run(AadOAuth2ResourceServerSampleApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.spring.sample.aad;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AadOAuth2WebAppAndResourceServerSampleApplication {

public static void main(String[] args) {
SpringApplication.run(AadOAuth2WebAppAndResourceServerSampleApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

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

import com.azure.spring.cloud.autoconfigure.aad.AADResourceServerWebSecurityConfigurerAdapter;
import com.azure.spring.cloud.autoconfigure.aad.AADWebSecurityConfigurerAdapter;
import com.azure.spring.cloud.autoconfigure.aad.AadResourceServerWebSecurityConfigurerAdapter;
import com.azure.spring.cloud.autoconfigure.aad.AadWebSecurityConfigurerAdapter;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
Expand All @@ -13,11 +13,11 @@

@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class AADWebApplicationAndResourceServerConfig {
public class AadWebApplicationAndResourceServerConfig {

@Order(1)
@Configuration
public static class ApiWebSecurityConfigurationAdapter extends AADResourceServerWebSecurityConfigurerAdapter {
public static class ApiWebSecurityConfigurationAdapter extends AadResourceServerWebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.antMatcher("/api/**")
Expand All @@ -26,7 +26,7 @@ protected void configure(HttpSecurity http) throws Exception {
}

@Configuration
public static class HtmlWebSecurityConfigurerAdapter extends AADWebSecurityConfigurerAdapter {
public static class HtmlWebSecurityConfigurerAdapter extends AadWebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AzureADOAuth2ResourceServerSampleApplication {
public class AadOAuth2WebAppSampleApplication {

public static void main(String[] args) {
SpringApplication.run(AzureADOAuth2ResourceServerSampleApplication.class, args);
SpringApplication.run(AadOAuth2WebAppSampleApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.security.oauth2.client.endpoint.JwtBearerGrantRequestEntityConverter;
import org.springframework.util.MultiValueMap;

public class AzureADJwtBearerGrantRequestEntityConverter extends JwtBearerGrantRequestEntityConverter {
public class AadJwtBearerGrantRequestEntityConverter extends JwtBearerGrantRequestEntityConverter {

@Override
protected MultiValueMap<String, String> createParameters(JwtBearerGrantRequest jwtBearerGrantRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private JwtBearerOAuth2AuthorizedClientProvider jwtBearerOAuth2AuthorizedClientP

private DefaultJwtBearerTokenResponseClient oAuth2AccessTokenResponseClient() {
DefaultJwtBearerTokenResponseClient client = new DefaultJwtBearerTokenResponseClient();
client.setRequestEntityConverter(new AzureADJwtBearerGrantRequestEntityConverter());
client.setRequestEntityConverter(new AadJwtBearerGrantRequestEntityConverter());
return client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import com.azure.spring.messaging.checkpoint.CheckpointConfig;
import com.azure.spring.messaging.checkpoint.CheckpointMode;
import com.azure.spring.servicebus.core.ServiceBusProcessorContainer;
import com.azure.spring.servicebus.core.ServiceBusProcessorFactory;
import com.azure.spring.servicebus.core.ServiceBusProducerFactory;
import com.azure.spring.servicebus.core.ServiceBusTemplate;
import com.azure.spring.servicebus.core.processor.DefaultServiceBusNamespaceProcessorFactory;
import com.azure.spring.servicebus.core.processor.ServiceBusProcessorFactory;
import com.azure.spring.servicebus.core.producer.DefaultServiceBusNamespaceProducerFactory;
import com.azure.spring.servicebus.core.producer.ServiceBusProducerFactory;
import com.azure.spring.servicebus.core.properties.ProcessorProperties;
import com.azure.spring.servicebus.core.properties.ProducerProperties;
import com.azure.spring.servicebus.implementation.core.DefaultServiceBusNamespaceProcessorFactory;
import com.azure.spring.servicebus.implementation.core.DefaultServiceBusNamespaceProducerFactory;
import com.azure.spring.servicebus.support.converter.ServiceBusMessageConverter;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.springframework.stereotype.Service;

/**
* @author Miao Cao
*
*/
@Service
public class ReceiveService {
Expand Down