Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rj93
rj93 / HelloControllerWithReactiveOAuth2AuthorizedClientService.java
Last active January 24, 2021 20:13
Hello Controller, that reaches out to Reddit to obtain the username.
@RestController
public class HelloController {
private final ReactiveOAuth2AuthorizedClientService authorizedClientService;
private final WebClient webClient = WebClient.builder().build();
public HelloController(ReactiveOAuth2AuthorizedClientService authorizedClientService) {
this.authorizedClientService = authorizedClientService;
}
@rj93
rj93 / HelloControllerWithRedditWebClient.java
Created January 24, 2021 19:50
Hello Controller, that reaches out to Reddit to obtain the username.
@RestController
public class HelloController {
private final WebClient webClient;
public HelloController(@Qualifier("redditWebClient") WebClient webClient) {
this.webClient = webClient;
}
@GetMapping
public Mono<String> hello() {
@rj93
rj93 / application-google-oauth2.yml
Created January 24, 2021 15:50
Spring Boot Configuration for Google OAuth 2.0
spring:
security:
oauth2:
client:
registration:
google:
client-id: googleIssuedId
client-secret: googleIssuedSecret
@rj93
rj93 / application-reddit-oauth2.yml
Last active January 24, 2021 15:51
Spring Boot Configuration for Reddit OAuth 2.0
spring:
security:
oauth2:
client:
registration:
reddit:
clientId: redditIssuedId
clientSecret: redditIssuedSecret
redirectUri: http://localhost:8080/login/oauth2/code/reddit
scope:
@rj93
rj93 / SecurityConfig.java
Last active January 24, 2021 15:47
Reactive OAuth 2.0 Login Configuration
@Configuration
public class SecurityConfig {
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.authorizeExchange().anyExchange().authenticated()
.and()
.oauth2Login();
return http.build();
}
@rj93
rj93 / HelloController.java
Created January 24, 2021 15:45
Reactive Hello World Controller
@RestController
public class HelloController {
@GetMapping
public Mono<String> hello() {
return Mono.just("Hello, Medium");
}
}
@rj93
rj93 / WebFluxConfig.java
Created January 24, 2021 15:42
Enable WebFlux Configuration
@Configuration
@EnableWebFlux
public class WebFluxConfig implements WebFluxConfigurer {
}
### Keybase proof
I hereby claim:
* I am rj93 on github.
* I am rj93 (https://keybase.io/rj93) on keybase.
* I have a public key ASArMY44eY3XYI394UjYuLLrW9hm7UC2dRNnDCboXeEhJgo
To claim this, I am signing this object: