Commit 2e148f6b7d5b566bd9367cd7087d999e4bb9c384
Merge branch 'master' of github.com:thingsboard/thingsboard
Showing
5 changed files
with
9 additions
and
10 deletions
@@ -338,7 +338,7 @@ public class AuthController extends BaseController { | @@ -338,7 +338,7 @@ public class AuthController extends BaseController { | ||
338 | 338 | ||
339 | @RequestMapping(value = "/noauth/oauth2Clients", method = RequestMethod.POST) | 339 | @RequestMapping(value = "/noauth/oauth2Clients", method = RequestMethod.POST) |
340 | @ResponseBody | 340 | @ResponseBody |
341 | - public List<OAuth2ClientInfo> getOath2Clients() throws ThingsboardException { | 341 | + public List<OAuth2ClientInfo> getOAuth2Clients() throws ThingsboardException { |
342 | try { | 342 | try { |
343 | return oauth2Service.getOAuth2Clients(); | 343 | return oauth2Service.getOAuth2Clients(); |
344 | } catch (Exception e) { | 344 | } catch (Exception e) { |
@@ -51,9 +51,9 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen | @@ -51,9 +51,9 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen | ||
51 | String firstName = getStringAttributeByKey(attributes, config.getBasic().getFirstNameAttributeKey()); | 51 | String firstName = getStringAttributeByKey(attributes, config.getBasic().getFirstNameAttributeKey()); |
52 | oauth2User.setFirstName(firstName); | 52 | oauth2User.setFirstName(firstName); |
53 | } | 53 | } |
54 | - if (!StringUtils.isEmpty(config.getBasic().getCustomerNameStrategyPattern())) { | 54 | + if (!StringUtils.isEmpty(config.getBasic().getCustomerNamePattern())) { |
55 | StrSubstitutor sub = new StrSubstitutor(attributes, START_PLACEHOLDER_PREFIX, END_PLACEHOLDER_PREFIX); | 55 | StrSubstitutor sub = new StrSubstitutor(attributes, START_PLACEHOLDER_PREFIX, END_PLACEHOLDER_PREFIX); |
56 | - String customerName = sub.replace(config.getBasic().getCustomerNameStrategyPattern()); | 56 | + String customerName = sub.replace(config.getBasic().getCustomerNamePattern()); |
57 | oauth2User.setCustomerName(customerName); | 57 | oauth2User.setCustomerName(customerName); |
58 | } | 58 | } |
59 | return getOrCreateSecurityUserFromOAuth2User(oauth2User, config.getBasic().isAllowUserCreation()); | 59 | return getOrCreateSecurityUserFromOAuth2User(oauth2User, config.getBasic().isAllowUserCreation()); |
@@ -68,7 +68,7 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen | @@ -68,7 +68,7 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen | ||
68 | return email.substring(email .indexOf("@") + 1); | 68 | return email.substring(email .indexOf("@") + 1); |
69 | case CUSTOM_TENANT_STRATEGY: | 69 | case CUSTOM_TENANT_STRATEGY: |
70 | StrSubstitutor sub = new StrSubstitutor(attributes, START_PLACEHOLDER_PREFIX, END_PLACEHOLDER_PREFIX); | 70 | StrSubstitutor sub = new StrSubstitutor(attributes, START_PLACEHOLDER_PREFIX, END_PLACEHOLDER_PREFIX); |
71 | - return sub.replace(config.getBasic().getTenantNameStrategyPattern()); | 71 | + return sub.replace(config.getBasic().getTenantNamePattern()); |
72 | default: | 72 | default: |
73 | throw new RuntimeException("Tenant Name Strategy with type " + config.getBasic().getTenantNameStrategy() + " is not supported!"); | 73 | throw new RuntimeException("Tenant Name Strategy with type " + config.getBasic().getTenantNameStrategy() + " is not supported!"); |
74 | } | 74 | } |
@@ -78,7 +78,6 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen | @@ -78,7 +78,6 @@ public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implemen | ||
78 | String result = null; | 78 | String result = null; |
79 | try { | 79 | try { |
80 | result = (String) attributes.get(key); | 80 | result = (String) attributes.get(key); |
81 | - | ||
82 | } catch (Exception e) { | 81 | } catch (Exception e) { |
83 | log.warn("Can't convert attribute to String by key " + key); | 82 | log.warn("Can't convert attribute to String by key " + key); |
84 | } | 83 | } |
@@ -41,7 +41,7 @@ public class CustomOAuth2ClientMapper extends AbstractOAuth2ClientMapper impleme | @@ -41,7 +41,7 @@ public class CustomOAuth2ClientMapper extends AbstractOAuth2ClientMapper impleme | ||
41 | return getOrCreateSecurityUserFromOAuth2User(oauth2User, config.getBasic().isAllowUserCreation()); | 41 | return getOrCreateSecurityUserFromOAuth2User(oauth2User, config.getBasic().isAllowUserCreation()); |
42 | } | 42 | } |
43 | 43 | ||
44 | - public OAuth2User getOAuth2User(OAuth2AuthenticationToken token, OAuth2ClientMapperConfig.CustomOAuth2ClientMapperConfig custom) { | 44 | + private synchronized OAuth2User getOAuth2User(OAuth2AuthenticationToken token, OAuth2ClientMapperConfig.CustomOAuth2ClientMapperConfig custom) { |
45 | if (!StringUtils.isEmpty(custom.getUsername()) && !StringUtils.isEmpty(custom.getPassword())) { | 45 | if (!StringUtils.isEmpty(custom.getUsername()) && !StringUtils.isEmpty(custom.getPassword())) { |
46 | restTemplateBuilder = restTemplateBuilder.basicAuthentication(custom.getUsername(), custom.getPassword()); | 46 | restTemplateBuilder = restTemplateBuilder.basicAuthentication(custom.getUsername(), custom.getPassword()); |
47 | } | 47 | } |
@@ -126,8 +126,8 @@ security: | @@ -126,8 +126,8 @@ security: | ||
126 | firstNameAttributeKey: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_FIRST_NAME_ATTRIBUTE_KEY:}" | 126 | firstNameAttributeKey: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_FIRST_NAME_ATTRIBUTE_KEY:}" |
127 | lastNameAttributeKey: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_LAST_NAME_ATTRIBUTE_KEY:}" | 127 | lastNameAttributeKey: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_LAST_NAME_ATTRIBUTE_KEY:}" |
128 | tenantNameStrategy: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_TENANT_NAME_STRATEGY:domain}" # domain, email or custom | 128 | tenantNameStrategy: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_TENANT_NAME_STRATEGY:domain}" # domain, email or custom |
129 | - tenantNameStrategyPattern: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_TENANT_NAME_STRATEGY_PATTERN:}" | ||
130 | - customerNameStrategyPattern: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_CUSTOMER_NAME_STRATEGY_PATTERN:}" | 129 | + tenantNamePattern: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_TENANT_NAME_PATTERN:}" # %{attribute_key} as placeholder for attributes value by key |
130 | + customerNamePattern: "${SECURITY_OAUTH2_DEFAULT_MAPPER_BASIC_CUSTOMER_NAME_PATTERN:}" # %{attribute_key} as placeholder for attributes value by key | ||
131 | custom: | 131 | custom: |
132 | url: "${SECURITY_OAUTH2_DEFAULT_MAPPER_CUSTOM_URL:}" | 132 | url: "${SECURITY_OAUTH2_DEFAULT_MAPPER_CUSTOM_URL:}" |
133 | username: "${SECURITY_OAUTH2_DEFAULT_MAPPER_CUSTOM_USERNAME:}" | 133 | username: "${SECURITY_OAUTH2_DEFAULT_MAPPER_CUSTOM_USERNAME:}" |
@@ -31,8 +31,8 @@ public class OAuth2ClientMapperConfig { | @@ -31,8 +31,8 @@ public class OAuth2ClientMapperConfig { | ||
31 | private String firstNameAttributeKey; | 31 | private String firstNameAttributeKey; |
32 | private String lastNameAttributeKey; | 32 | private String lastNameAttributeKey; |
33 | private String tenantNameStrategy; | 33 | private String tenantNameStrategy; |
34 | - private String tenantNameStrategyPattern; | ||
35 | - private String customerNameStrategyPattern; | 34 | + private String tenantNamePattern; |
35 | + private String customerNamePattern; | ||
36 | } | 36 | } |
37 | 37 | ||
38 | @Data | 38 | @Data |