Polish gh-4560

This commit is contained in:
Joe Grandja 2017-09-21 15:32:04 -04:00
parent 7fb386669f
commit 8521ca8f94
3 changed files with 57 additions and 59 deletions

View File

@ -16,36 +16,34 @@
package org.springframework.security.config.oauth2.client;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.ResourcePropertySource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import java.io.IOException;
import java.util.Map;
/**
* Utility methods for OAuth 2.0 client properties.
* A resource loader for OAuth 2.0 client template(s) properties.
*
* @author Joe Grandja
* @since 5.0.0
*/
public final class OAuth2ClientPropertiesUtil {
public final class OAuth2ClientTemplatePropertiesLoader {
public static final String CLIENT_TYPES_PROPERTY_PREFIX = "spring.security.oauth2.client.client-types";
public static final String CLIENT_TEMPLATES_PROPERTY_PREFIX = "spring.security.oauth2.client.templates";
private static final String CLIENT_TYPES_RESOURCE_LOCATION = "spring-security-oauth2-client-types.properties";
private static final String CLIENT_TEMPLATES_RESOURCE_LOCATION = "spring-security-oauth2-client-templates.properties";
private OAuth2ClientPropertiesUtil() {
private OAuth2ClientTemplatePropertiesLoader() {
}
public static PropertiesPropertySource loadClientTypesPropertySource() {
public static Map<String, Object> loadClientTemplates() {
try {
return new ResourcePropertySource(
new ClassPathResource(CLIENT_TYPES_RESOURCE_LOCATION, OAuth2ClientPropertiesUtil.class));
}
catch (IOException ioe) {
throw new RuntimeException("Failed to load OAuth 2.0 client types resource: "
+ CLIENT_TYPES_RESOURCE_LOCATION, ioe);
return (Map) PropertiesLoaderUtils.loadProperties(
new ClassPathResource(CLIENT_TEMPLATES_RESOURCE_LOCATION, OAuth2ClientTemplatePropertiesLoader.class));
} catch (IOException ioe) {
throw new RuntimeException("Failed to load OAuth 2.0 client templates resource: "
+ CLIENT_TEMPLATES_RESOURCE_LOCATION, ioe);
}
}
}

View File

@ -0,0 +1,44 @@
# Google
spring.security.oauth2.client.templates.google.client-authentication-method=basic
spring.security.oauth2.client.templates.google.authorization-grant-type=authorization_code
spring.security.oauth2.client.templates.google.redirect-uri={scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}
spring.security.oauth2.client.templates.google.scope=openid, profile, email, address, phone
spring.security.oauth2.client.templates.google.authorization-uri=https://accounts.google.com/o/oauth2/v2/auth
spring.security.oauth2.client.templates.google.token-uri=https://www.googleapis.com/oauth2/v4/token
spring.security.oauth2.client.templates.google.user-info-uri=https://www.googleapis.com/oauth2/v3/userinfo
spring.security.oauth2.client.templates.google.jwk-set-uri=https://www.googleapis.com/oauth2/v3/certs
spring.security.oauth2.client.templates.google.client-name=Google
spring.security.oauth2.client.templates.google.client-alias=google
# GitHub
spring.security.oauth2.client.templates.github.client-authentication-method=basic
spring.security.oauth2.client.templates.github.authorization-grant-type=authorization_code
spring.security.oauth2.client.templates.github.redirect-uri={scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}
spring.security.oauth2.client.templates.github.scope=user
spring.security.oauth2.client.templates.github.authorization-uri=https://github.com/login/oauth/authorize
spring.security.oauth2.client.templates.github.token-uri=https://github.com/login/oauth/access_token
spring.security.oauth2.client.templates.github.user-info-uri=https://api.github.com/user
spring.security.oauth2.client.templates.github.user-name-attribute-name=name
spring.security.oauth2.client.templates.github.client-name=GitHub
spring.security.oauth2.client.templates.github.client-alias=github
# Facebook
spring.security.oauth2.client.templates.facebook.client-authentication-method=post
spring.security.oauth2.client.templates.facebook.authorization-grant-type=authorization_code
spring.security.oauth2.client.templates.facebook.redirect-uri={scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}
spring.security.oauth2.client.templates.facebook.scope=public_profile, email
spring.security.oauth2.client.templates.facebook.authorization-uri=https://www.facebook.com/v2.8/dialog/oauth
spring.security.oauth2.client.templates.facebook.token-uri=https://graph.facebook.com/v2.8/oauth/access_token
spring.security.oauth2.client.templates.facebook.user-info-uri=https://graph.facebook.com/me
spring.security.oauth2.client.templates.facebook.user-name-attribute-name=name
spring.security.oauth2.client.templates.facebook.client-name=Facebook
spring.security.oauth2.client.templates.facebook.client-alias=facebook
# Okta
spring.security.oauth2.client.templates.okta.client-authentication-method=basic
spring.security.oauth2.client.templates.okta.authorization-grant-type=authorization_code
spring.security.oauth2.client.templates.okta.redirect-uri={scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}
spring.security.oauth2.client.templates.okta.scope=openid, profile, email, address, phone
spring.security.oauth2.client.templates.okta.client-name=Okta
spring.security.oauth2.client.templates.okta.client-alias=okta

View File

@ -1,44 +0,0 @@
# Google
spring.security.oauth2.client.client-types.google.client-authentication-method=basic
spring.security.oauth2.client.client-types.google.authorization-grant-type=authorization_code
spring.security.oauth2.client.client-types.google.redirect-uri={scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}
spring.security.oauth2.client.client-types.google.scope=openid, profile, email, address, phone
spring.security.oauth2.client.client-types.google.authorization-uri=https://accounts.google.com/o/oauth2/v2/auth
spring.security.oauth2.client.client-types.google.token-uri=https://www.googleapis.com/oauth2/v4/token
spring.security.oauth2.client.client-types.google.user-info-uri=https://www.googleapis.com/oauth2/v3/userinfo
spring.security.oauth2.client.client-types.google.jwk-set-uri=https://www.googleapis.com/oauth2/v3/certs
spring.security.oauth2.client.client-types.google.client-name=Google
spring.security.oauth2.client.client-types.google.client-alias=google
# GitHub
spring.security.oauth2.client.client-types.github.client-authentication-method=basic
spring.security.oauth2.client.client-types.github.authorization-grant-type=authorization_code
spring.security.oauth2.client.client-types.github.redirect-uri={scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}
spring.security.oauth2.client.client-types.github.scope=user
spring.security.oauth2.client.client-types.github.authorization-uri=https://github.com/login/oauth/authorize
spring.security.oauth2.client.client-types.github.token-uri=https://github.com/login/oauth/access_token
spring.security.oauth2.client.client-types.github.user-info-uri=https://api.github.com/user
spring.security.oauth2.client.client-types.github.user-name-attribute-name=name
spring.security.oauth2.client.client-types.github.client-name=GitHub
spring.security.oauth2.client.client-types.github.client-alias=github
# Facebook
spring.security.oauth2.client.client-types.facebook.client-authentication-method=post
spring.security.oauth2.client.client-types.facebook.authorization-grant-type=authorization_code
spring.security.oauth2.client.client-types.facebook.redirect-uri={scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}
spring.security.oauth2.client.client-types.facebook.scope=public_profile, email
spring.security.oauth2.client.client-types.facebook.authorization-uri=https://www.facebook.com/v2.8/dialog/oauth
spring.security.oauth2.client.client-types.facebook.token-uri=https://graph.facebook.com/v2.8/oauth/access_token
spring.security.oauth2.client.client-types.facebook.user-info-uri=https://graph.facebook.com/me
spring.security.oauth2.client.client-types.facebook.user-name-attribute-name=name
spring.security.oauth2.client.client-types.facebook.client-name=Facebook
spring.security.oauth2.client.client-types.facebook.client-alias=facebook
# Okta
spring.security.oauth2.client.client-types.okta.client-authentication-method=basic
spring.security.oauth2.client.client-types.okta.authorization-grant-type=authorization_code
spring.security.oauth2.client.client-types.okta.redirect-uri={scheme}://{serverName}:{serverPort}{contextPath}/oauth2/authorize/code/{clientAlias}
spring.security.oauth2.client.client-types.okta.scope=openid, profile, email, address, phone
spring.security.oauth2.client.client-types.okta.client-name=Okta
spring.security.oauth2.client.client-types.okta.client-alias=okta