Merge branch 'master' of github.com:thingsboard/thingsboard
This commit is contained in:
commit
2e148f6b7d
@ -338,7 +338,7 @@ public class AuthController extends BaseController {
|
||||
|
||||
@RequestMapping(value = "/noauth/oauth2Clients", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public List<OAuth2ClientInfo> getOath2Clients() throws ThingsboardException {
|
||||
public List<OAuth2ClientInfo> getOAuth2Clients() throws ThingsboardException {
|
||||
try {
|
||||
return oauth2Service.getOAuth2Clients();
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -51,9 +51,9 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen
|
||||
String firstName = getStringAttributeByKey(attributes, config.getBasic().getFirstNameAttributeKey());
|
||||
oauth2User.setFirstName(firstName);
|
||||
}
|
||||
if (!StringUtils.isEmpty(config.getBasic().getCustomerNameStrategyPattern())) {
|
||||
if (!StringUtils.isEmpty(config.getBasic().getCustomerNamePattern())) {
|
||||
StrSubstitutor sub = new StrSubstitutor(attributes, START_PLACEHOLDER_PREFIX, END_PLACEHOLDER_PREFIX);
|
||||
String customerName = sub.replace(config.getBasic().getCustomerNameStrategyPattern());
|
||||
String customerName = sub.replace(config.getBasic().getCustomerNamePattern());
|
||||
oauth2User.setCustomerName(customerName);
|
||||
}
|
||||
return getOrCreateSecurityUserFromOAuth2User(oauth2User, config.getBasic().isAllowUserCreation());
|
||||
@ -68,7 +68,7 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen
|
||||
return email.substring(email .indexOf("@") + 1);
|
||||
case CUSTOM_TENANT_STRATEGY:
|
||||
StrSubstitutor sub = new StrSubstitutor(attributes, START_PLACEHOLDER_PREFIX, END_PLACEHOLDER_PREFIX);
|
||||
return sub.replace(config.getBasic().getTenantNameStrategyPattern());
|
||||
return sub.replace(config.getBasic().getTenantNamePattern());
|
||||
default:
|
||||
throw new RuntimeException("Tenant Name Strategy with type " + config.getBasic().getTenantNameStrategy() + " is not supported!");
|
||||
}
|
||||
@ -78,7 +78,6 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen
|
||||
String result = null;
|
||||
try {
|
||||
result = (String) attributes.get(key);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warn("Can't convert attribute to String by key " + key);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class CustomOAuth2ClientMapper extends AbstractOAuth2ClientMapper impleme
|
||||
return getOrCreateSecurityUserFromOAuth2User(oauth2User, config.getBasic().isAllowUserCreation());
|
||||
}
|
||||
|
||||
public OAuth2User getOAuth2User(OAuth2AuthenticationToken token, OAuth2ClientMapperConfig.CustomOAuth2ClientMapperConfig custom) {
|
||||
private synchronized OAuth2User getOAuth2User(OAuth2AuthenticationToken token, OAuth2ClientMapperConfig.CustomOAuth2ClientMapperConfig custom) {
|
||||
if (!StringUtils.isEmpty(custom.getUsername()) && !StringUtils.isEmpty(custom.getPassword())) {
|
||||
restTemplateBuilder = restTemplateBuilder.basicAuthentication(custom.getUsername(), custom.getPassword());
|
||||
}
|
||||
|
||||
@ -126,8 +126,8 @@ security:
|
||||
firstNameAttributeKey: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_FIRST_NAME_ATTRIBUTE_KEY:}"
|
||||
lastNameAttributeKey: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_LAST_NAME_ATTRIBUTE_KEY:}"
|
||||
tenantNameStrategy: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_TENANT_NAME_STRATEGY:domain}" # domain, email or custom
|
||||
tenantNameStrategyPattern: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_TENANT_NAME_STRATEGY_PATTERN:}"
|
||||
customerNameStrategyPattern: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_CUSTOMER_NAME_STRATEGY_PATTERN:}"
|
||||
tenantNamePattern: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_TENANT_NAME_PATTERN:}" # %{attribute_key} as placeholder for attributes value by key
|
||||
customerNamePattern: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_CUSTOMER_NAME_PATTERN:}" # %{attribute_key} as placeholder for attributes value by key
|
||||
custom:
|
||||
url: "${SECURITY_OAUTH2_DEFAULT_MAPPER_CUSTOM_URL:}"
|
||||
username: "${SECURITY_OAUTH2_DEFAULT_MAPPER_CUSTOM_USERNAME:}"
|
||||
|
||||
@ -31,8 +31,8 @@ public class OAuth2ClientMapperConfig {
|
||||
private String firstNameAttributeKey;
|
||||
private String lastNameAttributeKey;
|
||||
private String tenantNameStrategy;
|
||||
private String tenantNameStrategyPattern;
|
||||
private String customerNameStrategyPattern;
|
||||
private String tenantNamePattern;
|
||||
private String customerNamePattern;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user