Skip to content

Commit

Permalink
SHIBUI-2380
Browse files Browse the repository at this point in the history
adding in support for OIDC specific relying overrides
  • Loading branch information
chasegawa committed Oct 6, 2022
1 parent a7f7b84 commit 8e5ab06
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class MetadataSourcesUiDefinitionController {
def parsedJson = jacksonObjectMapper.readValue(url, Map)
jsonSchemaBuilderService.hideServiceEnabledFromNonAdmins(parsedJson)
jsonSchemaBuilderService.addReleaseAttributesToJson(parsedJson['properties']['attributeRelease']['items'])
jsonSchemaBuilderService.addRelyingPartyOverridesToJson(parsedJson['properties']['relyingPartyOverrides'])
jsonSchemaBuilderService.addRelyingPartyOverridesCollectionDefinitionsToJson(parsedJson["definitions"])
jsonSchemaBuilderService.addRelyingPartyOverridesToJson(parsedJson['properties']['relyingPartyOverrides'], protocol.toLowerCase())
jsonSchemaBuilderService.addRelyingPartyOverridesCollectionDefinitionsToJson(parsedJson["definitions"], protocol.toLowerCase())
return ResponseEntity.ok(parsedJson)
}
catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ class JsonSchemaBuilderService {
}

void addRelyingPartyOverridesToJson(Object json) {
addRelyingPartyOverridesToJson(json, "saml")
}

void addRelyingPartyOverridesToJson(Object json, String protocol) {
def properties = [:]
customPropertiesConfiguration.getOverrides().each {
customPropertiesConfiguration.getOverrides().stream().filter {
it -> it.protocol.contains(protocol)
}.each {
if (it.protocol)
def property
if (it['displayType'] == 'list' || it['displayType'] == 'set' || it['displayType'] == 'selection_list') {
property = [$ref: '#/definitions/' + it['name']]
Expand All @@ -61,8 +68,12 @@ class JsonSchemaBuilderService {
}

void addRelyingPartyOverridesCollectionDefinitionsToJson(Object json) {
addRelyingPartyOverridesCollectionDefinitionsToJson(json, "saml")
}

void addRelyingPartyOverridesCollectionDefinitionsToJson(Object json, String protocol) {
customPropertiesConfiguration.getOverrides().stream().filter {
it -> it['displayType'] && (it['displayType'] == 'list' || it['displayType'] == 'set' || it['displayType'] == 'selection_list')
it -> it.protocol.contains(protocol) && it['displayType'] && (it['displayType'] == 'list' || it['displayType'] == 'set' || it['displayType'] == 'selection_list')
}.each {
def definition = [title : it['displayName'],
description: it['helpText'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public class CustomEntityAttributeDefinition implements IRelyingPartyOverridePro
@Id
@Column(name = "resource_id", nullable = false)
String resourceId = UUID.randomUUID().toString();


String protocol = "saml";

@Override
public Set<String> getDefaultValues() {
return customAttrListDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public interface IRelyingPartyOverrideProperty {
public String getPersistType();

public String getPersistValue();


public String getProtocol();

/**
* When the override actually is used in the UI, the "type" list is fairly limited, so each implementing class
* should adjust the real value so the UI gets a value it expects. For actual file configured overrides, this
Expand Down Expand Up @@ -61,4 +63,6 @@ public interface IRelyingPartyOverrideProperty {
public void setPersistType(String persistType);

public void setPersistValue(String persistValue);
}

public void setProtocol(String protocol);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class RelyingPartyOverrideProperty implements IRelyingPartyOverrideProper
private String name;
private String persistType;
private String persistValue;
private String protocol = "saml";

@Override
public Boolean getFromConfigFile() {
Expand All @@ -43,7 +44,11 @@ public CustomAttributeType getAttributeType() {
return CustomAttributeType.valueOf(displayType.toUpperCase());
}
}


public String getProtocol() {
return protocol == null ? "saml" : protocol;
}

public String getTypeForUI() {
return getDisplayType();
}
Expand Down

0 comments on commit 8e5ab06

Please sign in to comment.