mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 09:37:54 +01:00
Add API to tell Plan what permissions an endpoint uses.
This commit is contained in:
parent
394c47ba6f
commit
9c9058eda9
@ -19,7 +19,9 @@ package com.djrapitops.plan.delivery.web.resolver;
|
|||||||
import com.djrapitops.plan.delivery.web.resolver.request.Request;
|
import com.djrapitops.plan.delivery.web.resolver.request.Request;
|
||||||
import com.djrapitops.plan.delivery.web.resolver.request.WebUser;
|
import com.djrapitops.plan.delivery.web.resolver.request.WebUser;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for resolving requests of Plan webserver.
|
* Interface for resolving requests of Plan webserver.
|
||||||
@ -40,6 +42,25 @@ public interface Resolver {
|
|||||||
*/
|
*/
|
||||||
boolean canAccess(Request request);
|
boolean canAccess(Request request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override this to tell Plan what web permissions this endpoint uses.
|
||||||
|
* <p>
|
||||||
|
* This allows:
|
||||||
|
* <ul>
|
||||||
|
* <li>Plan to store these permissions in the permission list</li>
|
||||||
|
* <li>Users can grant/deny the permission for a group</li>
|
||||||
|
* <li>Plan can show what endpoints specific permission gives access to</li>
|
||||||
|
* </ul>
|
||||||
|
* <p>
|
||||||
|
* Requires PAGE_EXTENSION_USER_PERMISSIONS capability
|
||||||
|
*
|
||||||
|
* @return Set of permissions eg. [plugin.custom.permission, plugin.custom.permission.child.node]
|
||||||
|
* @see com.djrapitops.plan.capability.CapabilityService for Capability checks
|
||||||
|
*/
|
||||||
|
default Set<String> usedWebPermissions() {
|
||||||
|
return new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement request resolution.
|
* Implement request resolution.
|
||||||
*
|
*
|
||||||
|
@ -64,6 +64,8 @@ public class ResolverSvc implements ResolverService {
|
|||||||
public void registerResolver(String pluginName, String start, Resolver resolver) {
|
public void registerResolver(String pluginName, String start, Resolver resolver) {
|
||||||
basicResolvers.add(new Container(pluginName, checking -> checking.startsWith(start), resolver, start));
|
basicResolvers.add(new Container(pluginName, checking -> checking.startsWith(start), resolver, start));
|
||||||
Collections.sort(basicResolvers);
|
Collections.sort(basicResolvers);
|
||||||
|
Set<String> usedWebPermissions = resolver.usedWebPermissions();
|
||||||
|
dbSystem.getDatabase().executeTransaction(new StoreMissingWebPermissionsTransaction(usedWebPermissions));
|
||||||
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
||||||
logger.info("Registered basic resolver '" + start + "' for plugin " + pluginName);
|
logger.info("Registered basic resolver '" + start + "' for plugin " + pluginName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user