Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Brandon Vulaj bvulaj

🏠
Working from home
Block or report user

Report or block bvulaj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bvulaj
bvulaj / SecurityConfiguration.java
Last active Sep 29, 2019
Multiple Oauth2 Providers in Spring Security
View SecurityConfiguration.java
@Autowired
private FacebookPrincipalExtractor facebookPrincipalExtractor;
@Autowired
private FacebookAuthoritiesExtractor facebookAuthoritiesExtractor;
@Autowired
private GooglePrincipalExtractor googlePrincipalExtractor;
@Autowired
private GoogleAuthoritiesExtractor googleAuthoritiesExtractor;
@Bean
View ConfigurePrincipalExtractor.java
@Autowired
private PrincipalExtractor principalExtractor;
private Filter ssoFilter() {
OAuth2ClientAuthenticationProcessingFilter facebookFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/facebook");
OAuth2RestTemplate facebookTemplate = new OAuth2RestTemplate(facebook(), oauth2ClientContext);
facebookFilter.setRestTemplate(facebookTemplate);
UserInfoTokenServices tokenServices = new UserInfoTokenServices(facebookResource().getUserInfoUri(), facebook().getClientId());
tokenServices.setRestTemplate(facebookTemplate);
tokenServices.setPrincipalExtractor(principalExtractor);
@bvulaj
bvulaj / ProviderInfo.java
Created Mar 14, 2018
Basic Type Safe Injection
View ProviderInfo.java
@Component
@ConfigurationProperties("provider")
public class ProviderInfo {
private String name;
private boolean enabled;
private List<String> roles;
}
@bvulaj
bvulaj / AppConfig.java
Last active Mar 14, 2018
Simple Field Injection w/ @value
View AppConfig.java
@Configuration
public class AppConfig {
// Using SpEL
@Value("#{providerInfo.name ?: 'bar'}")
private String providerName;
// Injecting a Duration w/ a default
@Value("${timeout:500ms}")
private Duration timeout;
}
@bvulaj
bvulaj / AppConfig.java
Last active Mar 14, 2018
Third Party Injection
View AppConfig.java
@Configuration
public class AppConfig {
@Bean
@ConfigurationProperties("provider")
public ProviderInfo providerInfo() {
return new ProviderInfo();
}
}
@bvulaj
bvulaj / NonInnerClass.java
Last active Mar 14, 2018
Nested Configuration Objects w/o an Inner Class
View NonInnerClass.java
public class NonInnerClass {
private String name;
}
@bvulaj
bvulaj / InnerClassProperties.java
Last active Mar 14, 2018
Nested Configuration Objects w/ an Inner Class
View InnerClassProperties.java
@Component
@ConfigurationProperties("props")
public class InnerClassProperties {
private InnerClass innerClass;
private InnerClass otherInnerClass;
public static class InnerClass {
private String name;
}
}
@bvulaj
bvulaj / AppConfig.java
Last active Mar 14, 2018
Configuring Multiple Objects of the Same Type
View AppConfig.java
@Configuration
public class AppConfig {
@Bean
@ConfigurationProperties("foo")
public ProviderInfo fooProviderInfo() {
return new ProviderInfo();
}
@Bean
@ConfigurationProperties("bar")
@bvulaj
bvulaj / when-im-remote-youre-remote.html
Last active Aug 1, 2017
When I'm Remote, You're Remote
View when-im-remote-youre-remote.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>When I'm Remote, You're Remote</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"></link>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="page-header">
@bvulaj
bvulaj / CrossDomainCookieCsrfTokenRepository.java
Created Jul 27, 2017
The Cookie based, provided implementation of CsrfTokenRepository, CookieCsrfTokenRepository, does not allow setting the domain or domain pattern, so it is not possible to use the cookie across sub-domains. This implementation, which assumes `httpOnly=false` at this time, allows you to customize the cookie's domain as you would with `org.springfr…
View CrossDomainCookieCsrfTokenRepository.java
package com.phrankly.commons.security;
import java.lang.reflect.Method;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
You can’t perform that action at this time.