Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't assume component fields are returned by Keycloak API #80

Merged
merged 1 commit into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions keycloak/ldap_full_name_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ func convertFromLdapFullNameMapperToComponent(ldapFullNameMapper *LdapFullNameMa
}

func convertFromComponentToLdapFullNameMapper(component *component, realmId string) (*LdapFullNameMapper, error) {
readOnly, err := strconv.ParseBool(component.getConfig("read.only"))
readOnly, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("read.only"))
if err != nil {
return nil, err
}

writeOnly, err := strconv.ParseBool(component.getConfig("write.only"))
writeOnly, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("write.only"))
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions keycloak/ldap_group_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ func convertFromComponentToLdapGroupMapper(component *component, realmId string)
groupObjectClasses[i] = strings.TrimSpace(v)
}

preserveGroupInheritance, err := strconv.ParseBool(component.getConfig("preserve.group.inheritance"))
preserveGroupInheritance, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("preserve.group.inheritance"))
if err != nil {
return nil, err
}

ignoreMissingGroups, err := strconv.ParseBool(component.getConfig("ignore.missing.groups"))
ignoreMissingGroups, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("ignore.missing.groups"))
if err != nil {
return nil, err
}

dropNonExistingGroupsDuringSync, err := strconv.ParseBool(component.getConfig("drop.non.existing.groups.during.sync"))
dropNonExistingGroupsDuringSync, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("drop.non.existing.groups.during.sync"))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion keycloak/ldap_msad_user_account_control_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func convertFromLdapMsadUserAccountControlMapperToComponent(ldapMsadUserAccountC
}

func convertFromComponentToLdapMsadUserAccountControlMapper(component *component, realmId string) (*LdapMsadUserAccountControlMapper, error) {
ldapPasswordPolicyHintsEnabled, err := strconv.ParseBool(component.getConfig("ldap.password.policy.hints.enabled"))
ldapPasswordPolicyHintsEnabled, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("ldap.password.policy.hints.enabled"))
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions keycloak/ldap_user_attribute_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ func convertFromLdapUserAttributeMapperToComponent(ldapUserAttributeMapper *Ldap
}

func convertFromComponentToLdapUserAttributeMapper(component *component, realmId string) (*LdapUserAttributeMapper, error) {
isMandatoryInLdap, err := strconv.ParseBool(component.getConfig("is.mandatory.in.ldap"))
isMandatoryInLdap, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("is.mandatory.in.ldap"))
if err != nil {
return nil, err
}

readOnly, err := strconv.ParseBool(component.getConfig("read.only"))
readOnly, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("read.only"))
if err != nil {
return nil, err
}

alwaysReadValueFromLdap, err := strconv.ParseBool(component.getConfig("always.read.value.from.ldap"))
alwaysReadValueFromLdap, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("always.read.value.from.ldap"))
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions keycloak/ldap_user_federation.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func convertFromLdapUserFederationToComponent(ldap *LdapUserFederation) (*compon
}

func convertFromComponentToLdapUserFederation(component *component) (*LdapUserFederation, error) {
enabled, err := strconv.ParseBool(component.getConfig("enabled"))
enabled, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("enabled"))
if err != nil {
return nil, err
}
Expand All @@ -172,24 +172,24 @@ func convertFromComponentToLdapUserFederation(component *component) (*LdapUserFe
return nil, err
}

importEnabled, err := strconv.ParseBool(component.getConfig("importEnabled"))
importEnabled, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("importEnabled"))
if err != nil {
return nil, err
}

syncRegistrations, err := strconv.ParseBool(component.getConfig("syncRegistrations"))
syncRegistrations, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("syncRegistrations"))
if err != nil {
return nil, err
}

userObjectClasses := strings.Split(component.getConfig("userObjectClasses"), ", ")

validatePasswordPolicy, err := strconv.ParseBool(component.getConfig("validatePasswordPolicy"))
validatePasswordPolicy, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("validatePasswordPolicy"))
if err != nil {
return nil, err
}

pagination, err := strconv.ParseBool(component.getConfig("pagination"))
pagination, err := parseBoolAndTreatEmptyStringAsFalse(component.getConfig("pagination"))
if err != nil {
return nil, err
}
Expand Down