// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/configuration/MachineToMachineWebClientConfigurer.java
// @FunctionalInterface
// public interface MachineToMachineWebClientConfigurer extends Consumer<WebClient.Builder> {
// 
// 	// No additional methods
// 
// }


import org.springframework.security.oauth2.client.registration.InMemoryReactiveClientRegistrationRepository;
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
import org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction;
import org.springframework.security.oauth2.client.web.server.UnAuthenticatedServerOAuth2AuthorizedClientRepository;
import org.springframework.web.reactive.function.client.ExchangeFilterFunctions;
import java.util.ArrayList;
import java.util.List;
import be.ordina.msdashboard.configuration.MachineToMachineWebClientConfigurer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.security.oauth2.client.ClientsConfiguredCondition;
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties;
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
/*
 * Copyright 2015-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.ordina.msdashboard.security;




/**
 * Class that contains all security related configuration.
 *
 * @author Tim Ysewyn
 */
@Configuration
@EnableConfigurationProperties({ BasicClientSecurityProperties.class, OAuth2ClientProperties.class })
public class SecurityConfiguration {

	private static final String CLIENT_NAME = "ms-dashboard-m2m";

	@Bean("ms-dashboard-m2m-basic-filter")
	@Conditional(BasicClientSecurityConfigured.class)
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/configuration/MachineToMachineWebClientConfigurer.java
// @FunctionalInterface
// public interface MachineToMachineWebClientConfigurer extends Consumer<WebClient.Builder> {
// 
// 	// No additional methods
// 
// }


// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/security/SecurityConfiguration.java
import org.springframework.security.oauth2.client.registration.InMemoryReactiveClientRegistrationRepository;
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
import org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction;
import org.springframework.security.oauth2.client.web.server.UnAuthenticatedServerOAuth2AuthorizedClientRepository;
import org.springframework.web.reactive.function.client.ExchangeFilterFunctions;
import java.util.ArrayList;
import java.util.List;
import be.ordina.msdashboard.configuration.MachineToMachineWebClientConfigurer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.security.oauth2.client.ClientsConfiguredCondition;
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties;
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.client.registration.ClientRegistration;

/*
 * Copyright 2015-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.ordina.msdashboard.security;




/**
 * Class that contains all security related configuration.
 *
 * @author Tim Ysewyn
 */
@Configuration
@EnableConfigurationProperties({ BasicClientSecurityProperties.class, OAuth2ClientProperties.class })
public class SecurityConfiguration {

	private static final String CLIENT_NAME = "ms-dashboard-m2m";

	@Bean("ms-dashboard-m2m-basic-filter")
	@Conditional(BasicClientSecurityConfigured.class)
	MachineToMachineWebClientConfigurer basicFilter(BasicClientSecurityProperties properties) {