Skip to content

Commit

Permalink
Idempotency bugfix for manage queries
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Mar 1, 2024
1 parent 7549e6b commit 81ff669
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
Expand Down
8 changes: 2 additions & 6 deletions server/src/main/java/access/api/ManageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,8 @@ public ResponseEntity<Map<String, Object>> providerById(@PathVariable("type") En
public ResponseEntity<List<Map<String, Object>>> providers(@Parameter(hidden = true) User user) {
LOG.debug("/providers");
UserPermissions.assertAuthority(user, Authority.SUPER_USER);
List<Map<String, Object>> serviceProviders = manage.providers(EntityType.SAML20_SP);
List<Map<String, Object>> relyingParties = manage.providers(EntityType.OIDC10_RP);
List<Map<String, Object>> results = new ArrayList<>();
results.addAll(serviceProviders);
results.addAll(relyingParties);
return ResponseEntity.ok(results);
List<Map<String, Object>> providers = manage.providers(EntityType.SAML20_SP, EntityType.OIDC10_RP);
return ResponseEntity.ok(providers);
}

@GetMapping("applications")
Expand Down
11 changes: 8 additions & 3 deletions server/src/main/java/access/manage/RemoteManage.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public List<Map<String, Object>> provisioning(Collection<String> ids) {

@Override
public List<Map<String, Object>> providersByInstitutionalGUID(String organisationGUID) {
Map<String, Object> baseQuery = (Map<String, Object>) this.queries.get("base_query");
Map<String, Object> baseQuery = getBaseQuery();
baseQuery.put("metaDataFields.coin:institution_guid", organisationGUID);
List serviceProviders = restTemplate.postForObject(
String.format("%s/manage/api/internal/search/%s", this.url, EntityType.SAML20_SP.collectionName()),
Expand All @@ -86,7 +86,7 @@ public List<Map<String, Object>> providersByInstitutionalGUID(String organisatio

@Override
public Optional<Map<String, Object>> identityProviderByInstitutionalGUID(String organisationGUID) {
Map<String, Object> baseQuery = (Map<String, Object>) this.queries.get("base_query");
Map<String, Object> baseQuery = getBaseQuery();
baseQuery.put("metaDataFields.coin:institution_guid", organisationGUID);
List<Map<String, Object> > identityProviders = restTemplate.postForObject(
String.format("%s/manage/api/internal/search/%s", this.url, EntityType.SAML20_IDP.collectionName()),
Expand All @@ -95,9 +95,14 @@ public Optional<Map<String, Object>> identityProviderByInstitutionalGUID(String
}

private List<Map<String, Object>> getRemoteMetaData(String type) {
Object baseQuery = this.queries.get("base_query");
Map<String, Object> baseQuery = getBaseQuery();
String url = String.format("%s/manage/api/internal/search/%s", this.url, type);
return transformProvider(restTemplate.postForObject(url, baseQuery, List.class));
}

private Map<String, Object> getBaseQuery() {
return new HashMap<>((Map<String, Object>) this.queries.get("base_query"));
}


}
3 changes: 2 additions & 1 deletion server/src/main/resources/manage/query_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
"metaDataFields.logo:0:url",
"metaDataFields.coin:application_url"
]
}}
}
}

0 comments on commit 81ff669

Please sign in to comment.