Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
Expand All @@ -51,11 +53,14 @@ public StrictRbacManager() throws IOException {
}

private void initServiceRbacRules() throws IOException {
InputStream is = ClassLoader.getSystemResourceAsStream(SERVICE_RBAC_FILE_PATH);
if (is == null) {
is = ClassLoader.getSystemResourceAsStream(DEFAULT_RBAC_FILE_PATH);
ClassPathResource resource = new ClassPathResource(SERVICE_RBAC_FILE_PATH);
if (!resource.exists()) {
resource = new ClassPathResource(DEFAULT_RBAC_FILE_PATH);
if (!resource.exists()) {
throw new FileNotFoundException("rbac_policy.json cannot be opened because it does not exist");
}
}
serviceRbacRule = JsonUtil.readValue(is, ServiceRbacRule.class);
serviceRbacRule = JsonUtil.readValue(resource.getInputStream(), ServiceRbacRule.class);
}

@Override
Expand Down