Skip to content

Commit

Permalink
simplify withings oauth config part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed Jul 15, 2023
1 parent bbf5eb7 commit 5bf0b6c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.security.web.SecurityFilterChain;

import io.github.mucsi96.kubetools.security.KubetoolsSecurityConfigurer;
import mucsi96.traininglog.oauth.AccessTokenResponseClient;

@Configuration
@EnableWebSecurity
Expand All @@ -22,13 +21,8 @@ public class SecurityConfiguration {
@Bean
SecurityFilterChain securityFilterChain(
HttpSecurity http,
KubetoolsSecurityConfigurer kubetoolsSecurityConfigurer,
AccessTokenResponseClient accessTokenResponseClient) throws Exception {
return kubetoolsSecurityConfigurer.configure(http)
.oauth2Client(configurer -> configurer
.authorizationCodeGrant(customizer -> customizer
.accessTokenResponseClient(accessTokenResponseClient)))
.build();
KubetoolsSecurityConfigurer kubetoolsSecurityConfigurer) throws Exception {
return kubetoolsSecurityConfigurer.configure(http).securityMatcher("/weight/**", "/withings/sync").build();
}

@Bean
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
package mucsi96.traininglog.withings.oauth;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientProvider;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientProviderBuilder;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizedClientManager;
import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository;
import org.springframework.security.web.SecurityFilterChain;

import io.github.mucsi96.kubetools.security.KubetoolsSecurityConfigurer;

@Configuration
public class WithingsOAuthConfiguration {

@Bean
SecurityFilterChain withingsSecurityFilterChain(
HttpSecurity http,
KubetoolsSecurityConfigurer kubetoolsSecurityConfigurer,
WithingsAccessTokenResponseClient accessTokenResponseClient) throws Exception {
return kubetoolsSecurityConfigurer.configure(http)
.securityMatcher("/withings/authorize")
.oauth2Client(configurer -> configurer
.authorizationCodeGrant(customizer -> customizer
.accessTokenResponseClient(accessTokenResponseClient)))
.build();
}

@Bean
OAuth2AuthorizedClientManager withingsAuthorizedClientManager(
ClientRegistrationRepository clientRegistrationRepository,
Expand Down

0 comments on commit 5bf0b6c

Please sign in to comment.