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

Allow claim_name and json_type_label with script mappers #335

Merged
merged 1 commit into from
Nov 25, 2024
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
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