Skip to content

Commit

Permalink
Allow claim_name and json_type_label with script mappers (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock authored Nov 25, 2024
1 parent 31dc00c commit 992e2a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions lib/puppet/provider/keycloak_client_protocol_mapper/kcadm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def self.instances
if protocol_mapper[:type] == 'oidc-usermodel-property-mapper' || protocol_mapper[:type] == 'saml-user-property-mapper'
protocol_mapper[:user_attribute] = d['config']['user.attribute']
end
if ['oidc-usermodel-client-role-mapper', 'oidc-usermodel-property-mapper', 'oidc-group-membership-mapper'].include?(protocol_mapper[:type])
if ['oidc-usermodel-client-role-mapper', 'oidc-usermodel-property-mapper',
'oidc-group-membership-mapper'].include?(protocol_mapper[:type]) || (protocol_mapper[:protocol] == 'openid-connect' && protocol_mapper[:type] =~ %r{script-.+})
protocol_mapper[:claim_name] = d['config']['claim.name']
protocol_mapper[:json_type_label] = d['config']['jsonType.label']
end
Expand Down Expand Up @@ -109,7 +110,8 @@ def create
if (resource[:type] == 'oidc-usermodel-property-mapper' || resource[:type] == 'saml-user-property-mapper') && resource[:user_attribute]
data[:config][:'user.attribute'] = resource[:user_attribute]
end
if ['oidc-usermodel-client-role-mapper', 'oidc-usermodel-property-mapper', 'oidc-group-membership-mapper'].include?(resource[:type])
if ['oidc-usermodel-client-role-mapper', 'oidc-usermodel-property-mapper',
'oidc-group-membership-mapper'].include?(resource[:type]) || (resource[:protocol] == 'openid-connect' && resource[:type] =~ %r{script-.+})
data[:config][:'claim.name'] = resource[:claim_name] if resource[:claim_name]
data[:config][:'jsonType.label'] = resource[:json_type_label] if resource[:json_type_label]
end
Expand Down Expand Up @@ -197,7 +199,8 @@ def flush
if (resource[:type] == 'oidc-usermodel-property-mapper' || resource[:type] == 'saml-user-property-mapper') && resource[:user_attribute]
config[:'user.attribute'] = resource[:user_attribute]
end
if ['oidc-usermodel-client-role-mapper', 'oidc-usermodel-property-mapper', 'oidc-group-membership-mapper'].include?(resource[:type])
if ['oidc-usermodel-client-role-mapper', 'oidc-usermodel-property-mapper',
'oidc-group-membership-mapper'].include?(resource[:type]) || (resource[:protocol] == 'openid-connect' && resource[:type] =~ %r{script-.+})
config[:'claim.name'] = resource[:claim_name] if resource[:claim_name]
config[:'jsonType.label'] = resource[:json_type_label] if resource[:json_type_label]
end
Expand Down
12 changes: 8 additions & 4 deletions lib/puppet/provider/keycloak_protocol_mapper/kcadm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ def self.instances
if ['oidc-usermodel-property-mapper', 'saml-user-property-mapper', 'saml-user-attribute-mapper', 'oidc-usermodel-attribute-mapper'].include?(protocol_mapper[:type])
protocol_mapper[:user_attribute] = d['config']['user.attribute']
end
if ['oidc-usermodel-property-mapper', 'oidc-group-membership-mapper', 'oidc-usermodel-attribute-mapper'].include?(protocol_mapper[:type])
if ['oidc-usermodel-property-mapper', 'oidc-group-membership-mapper',
'oidc-usermodel-attribute-mapper'].include?(protocol_mapper[:type]) || (protocol_mapper[:protocol] == 'openid-connect' && protocol_mapper[:type] =~ %r{script-.+})
protocol_mapper[:claim_name] = d['config']['claim.name']
protocol_mapper[:json_type_label] = d['config']['jsonType.label']
end
if ['oidc-group-membership-mapper', 'saml-group-membership-mapper'].include?(protocol_mapper[:type])
protocol_mapper[:full_path] = d['config']['full.path']
end
if ['saml-group-membership-mapper', 'saml-user-property-mapper', 'saml-user-attribute-mapper'].include?(protocol_mapper[:type]) || protocol_mapper[:type] =~ %r{script-.+}
if ['saml-group-membership-mapper', 'saml-user-property-mapper',
'saml-user-attribute-mapper'].include?(protocol_mapper[:type]) || (protocol_mapper[:protocol] == 'saml' && protocol_mapper[:type] =~ %r{script-.+})
protocol_mapper[:friendly_name] = d['config']['friendly.name']
end
if protocol_mapper[:protocol] == 'openid-connect'
Expand Down Expand Up @@ -105,7 +107,8 @@ def create
if ['oidc-usermodel-property-mapper', 'saml-user-property-mapper', 'saml-user-attribute-mapper', 'oidc-usermodel-attribute-mapper'].include?(resource[:type]) && resource[:user_attribute]
data[:config][:'user.attribute'] = resource[:user_attribute]
end
if ['oidc-usermodel-property-mapper', 'oidc-group-membership-mapper', 'oidc-usermodel-attribute-mapper'].include?(resource[:type])
if ['oidc-usermodel-property-mapper', 'oidc-group-membership-mapper',
'oidc-usermodel-attribute-mapper'].include?(resource[:type]) || (resource[:protocol] == 'openid-connect' && resource[:type] =~ %r{script-.+})
data[:config][:'claim.name'] = resource[:claim_name] if resource[:claim_name]
data[:config][:'jsonType.label'] = resource[:json_type_label] if resource[:json_type_label]
end
Expand Down Expand Up @@ -188,7 +191,8 @@ def flush
if ['oidc-usermodel-property-mapper', 'saml-user-property-mapper', 'saml-user-attribute-mapper', 'oidc-usermodel-attribute-mapper'].include?(resource[:type]) && resource[:user_attribute]
config[:'user.attribute'] = resource[:user_attribute]
end
if ['oidc-usermodel-property-mapper', 'oidc-group-membership-mapper', 'oidc-usermodel-attribute-mapper'].include?(resource[:type])
if ['oidc-usermodel-property-mapper', 'oidc-group-membership-mapper',
'oidc-usermodel-attribute-mapper'].include?(resource[:type]) || (resource[:protocol] == 'openid-connect' && resource[:type] =~ %r{script-.+})
config[:'claim.name'] = resource[:claim_name] if resource[:claim_name]
config[:'jsonType.label'] = resource[:json_type_label] if resource[:json_type_label]
end
Expand Down

0 comments on commit 992e2a7

Please sign in to comment.