Skip to content

Commit

Permalink
WIP for new metadata type SRAM
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jun 27, 2024
1 parent d734e1d commit 6b65af1
Show file tree
Hide file tree
Showing 12 changed files with 565 additions and 8 deletions.
2 changes: 2 additions & 0 deletions manage-gui/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ I18n.translations.en = {
oauth20_rs: "Resource Servers",
provisioning: "Provisionings",
policy: "Policies",
sram: "SRAM",
saml20_sp_single: "Service Provider",
saml20_idp_single: "Identity Provider",
oidc10_rp_single: "Relying Party",
oauth20_rs_single: "Resource Server",
provisioning_single: "Provisioning",
policy_single: "Policy",
sram_single: "SRAM",
saml20_sp_revision_single: "Service Provider",
saml20_idp_revision_single: "Identity Provider",
oidc10_rp_revision_single: "Relying Party",
Expand Down
9 changes: 9 additions & 0 deletions manage-gui/src/pages/Detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ const tabsSingleTenant = [
"export"
];

const tabsSram = [
"connection",
"metadata",
"manipulation",
"revisions"
];


const aliasTabChanges = {
"mfa_entities": "stepup_entities"
Expand Down Expand Up @@ -1244,6 +1251,8 @@ class Detail extends React.PureComponent {
return tabsPr;
case "policy":
return tabsPolicy;
case "sram":
return tabsSram;
default:
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public ResponseEntity<Map> doPush(PushOptions pushOptions) {
Map<String, Map<String, Map<String, Object>>> json = this.pushPreview();

ResponseEntity<String> response = this.restTemplate.postForEntity(pushUri, json, String.class);
HttpStatus statusCode = response.getStatusCode();

result.put("status", "OK");
result.put("response", response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@

public class OidcValidationHook extends MetaDataHookAdapter {

private MetaDataAutoConfiguration metaDataAutoConfiguration;
private final MetaDataAutoConfiguration metaDataAutoConfiguration;

public OidcValidationHook(MetaDataAutoConfiguration metaDataAutoConfiguration) {
this.metaDataAutoConfiguration = metaDataAutoConfiguration;
}

@Override
public boolean appliesForMetaData(MetaData metaData) {
return metaData.getType().equals(EntityType.RP.getType());
return metaData.getType().equals(EntityType.RP.getType()) ||
(metaData.getType().equals(EntityType.SRAM.getType()) &&
"oidc_rp".equals(metaData.metaDataFields().get("connection_type")));
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion manage-server/src/main/java/manage/hook/SecretHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public SecretHook(MetaDataAutoConfiguration metaDataAutoConfiguration) {

@Override
public boolean appliesForMetaData(MetaData metaData) {
return metaData.getType().equals(EntityType.RP.getType()) || metaData.getType().equals(EntityType.RS.getType());
return metaData.getType().equals(EntityType.RP.getType()) ||
metaData.getType().equals(EntityType.RS.getType()) ||
metaData.getType().equals(EntityType.SRAM.getType());
}

@Override
Expand Down
1 change: 1 addition & 0 deletions manage-server/src/main/java/manage/model/EntityType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum EntityType {
RP("oidc10_rp", SP.getJanusDbValue()),
RS("oauth20_rs"),
STT("single_tenant_template", SP.getJanusDbValue()),
SRAM("sram", SP.getJanusDbValue()),
PROV("provisioning"),
PDP("policy");

Expand Down
3 changes: 2 additions & 1 deletion manage-server/src/main/java/manage/model/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.*;
import java.util.stream.Collectors;

import static java.util.Collections.emptyMap;
import static manage.mongo.MongoChangelog.REVISION_POSTFIX;

@Getter
Expand Down Expand Up @@ -166,7 +167,7 @@ public void merge(PathUpdates pathUpdates) {

@Transient
public Map<String, Object> metaDataFields() {
return (Map) data.get("metaDataFields");
return (Map) data.getOrDefault("metaDataFields", emptyMap());
}

@Transient
Expand Down
17 changes: 17 additions & 0 deletions manage-server/src/main/java/manage/mongo/MongoChangelog.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,23 @@ public void clearInvalidARPKeys(MongockTemplate mongoTemplate) {
});
}

@ChangeSet(order = "015", id = "addSRAMServices", author = "[email protected]")
public void addSRAMServices(MongockTemplate mongoTemplate) {
String schema = EntityType.SRAM.getType();
if (!mongoTemplate.collectionExists(schema)) {
mongoTemplate.createCollection(schema);
}
String revision = schema.concat(REVISION_POSTFIX);
if (!mongoTemplate.collectionExists(revision)) {
mongoTemplate.createCollection(revision);
}
mongoTemplate.indexOps(revision).ensureIndex(new Index("revision.parentId", Sort.Direction.ASC));
TextIndexDefinition textIndexDefinition = new TextIndexDefinition.TextIndexDefinitionBuilder()
.onField("$**")
.build();
mongoTemplate.indexOps(schema).ensureIndex(textIndexDefinition);
}

private void migrateRelayingPartyToResourceServer(Map<String, Map<String, Object>> properties, List<Pattern> patterns, Map<String, Object> simpleProperties, MetaData rs) {
rs.setType(EntityType.RS.getType());
rs.getData().entrySet().removeIf(entry -> !properties.containsKey(entry.getKey()));
Expand Down
Loading

0 comments on commit 6b65af1

Please sign in to comment.