first commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
plugins { id("java-library-conventions") }
|
||||
dependencies { implementation(project(":main-infrastructure")) }
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package net.bquarkz.ai.gateway.authorization.contracts;
|
||||
|
||||
import lombok.Value;
|
||||
import java.util.Set;
|
||||
|
||||
@Value
|
||||
public class Permission {
|
||||
String toolPattern;
|
||||
Set<String> allowedActions;
|
||||
|
||||
public boolean matchesTool(String toolName) {
|
||||
if (toolPattern.endsWith(".*")) {
|
||||
String prefix = toolPattern.substring(0, toolPattern.length() - 2);
|
||||
return toolName.startsWith(prefix + ".");
|
||||
}
|
||||
return toolPattern.equals(toolName) || toolPattern.equals("*");
|
||||
}
|
||||
|
||||
public boolean allowsAction(String action) {
|
||||
return allowedActions.contains("*") || allowedActions.contains(action);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package net.bquarkz.ai.gateway.authorization.contracts;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class Scope {
|
||||
String name;
|
||||
|
||||
public static Scope of(String name) {
|
||||
return new Scope(name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user