Skip to content

Commit

Permalink
Made public adapters visible only if they are authorized
Browse files Browse the repository at this point in the history
  • Loading branch information
inigo-cobian committed Jul 26, 2023
1 parent 0e3f44c commit aa3ec5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public class EngineController {
}


private boolean isPublicCapability(ResourceAdapterReference adapter) {
return PublicCapability.isPublicCapability(adapter.getName());
private boolean isPublicCapability(ResourceAdapterReference adapter, String permissions) {
return "*".equals(permissions) && PublicCapability.isPublicCapability(adapter.getName());
}

/**
Expand All @@ -92,7 +92,7 @@ public NodeCapabilities capabilities(EngineAuthorization user) {
// check if the adapter is authorized for this user
String authorized = Configuration.INSTANCE
.getProperty("klab.adapter." + adapter.getName().toLowerCase() + ".auth", "");
if (isAuthorized(user, authorized) || isPublicCapability(adapter)) {
if (isAuthorized(user, authorized) || isPublicCapability(adapter, authorized)) {
ret.getResourceAdapters().add(adapter);
if (adapter.isUniversal()) {
IUrnAdapter uad = Resources.INSTANCE.getUrnAdapter(adapter.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class PublicCapability {
private final static List<String> PUBLIC_CAPABILITIES = Arrays.asList("stats");

public static boolean isPublicCapability(String capability) {
return PUBLIC_CAPABILITIES.contains(capability);
}
Expand Down

1 comment on commit aa3ec5c

@inigo-cobian
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commited on the wrong branch. I decided to make a cherry-pick -> f70af11

Please sign in to comment.