Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Custom permission handlers #105

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Codestech1
Copy link

Adds a way to add custom permission handlers.
It's api breaking, however it's useful for me and may be useful for others who create their own permission system.

Copy link

@ajh123 ajh123 left a comment

Choose a reason for hiding this comment

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

I have some ideas so these changes are less breaking. Some code may expect getPermission, getAllPermissions, removePermission, hasPermission, addPermission by implementing these in the DefaultPermissionHandler existing code can expect the same behaviour.

I like the changes so far, this makes it easier to sync permissions with a database.

* @return the permissions of this handler.
*/
@NotNull
Set<Permission> getAllPermissions();
Copy link

@ajh123 ajh123 Jan 29, 2024

Choose a reason for hiding this comment

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

Shouldn't this be readded (to this interface) and implemented in DefaultPermissionHandler.

*
* @param permissionName the permission name
*/
default void removePermission(@NotNull String permissionName) {
Copy link

@ajh123 ajh123 Jan 29, 2024

Choose a reason for hiding this comment

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

Shouldn't this be readded (to this interface) and implemented in DefaultPermissionHandler.

* @return the permission from its name, null if not found
*/
@Nullable
default Permission getPermission(@NotNull String permissionName) {
Copy link

@ajh123 ajh123 Jan 29, 2024

Choose a reason for hiding this comment

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

Shouldn't this be readded (to this interface) and implemented in DefaultPermissionHandler.

* null means that only the permission name will be used
* @return true if the handler has the permission, false otherwise
*/
default boolean hasPermission(@NotNull String permissionName, @Nullable PermissionVerifier permissionVerifier) {
Copy link

@ajh123 ajh123 Jan 29, 2024

Choose a reason for hiding this comment

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

Shouldn't this be readded (to this interface) and implemented in DefaultPermissionHandler.

/**
* A default permission handler. Used when no custom permission handler is set.
*/
public final class DefaultPermissionHandler implements PermissionHandler {
Copy link

Choose a reason for hiding this comment

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

This class should implement the changes suggested in PermissionHandler. The implementations should have the same behaviour as before.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants