Package dev.sympho.bot_utils.access
Interface AccessManager
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A manager that provides access validators for different execution contexts.
The most basic manager creates validators that simply check if the
user belongs to the given group; however, manager implementations are free to customize
access control by checking additional context information, external state, or even
dynamically applying different validation rules depending on the context.
- Since:
- 1.0
- Version:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic AccessManagerCreates a manager for which all validators always allow access.static AccessManagerCreates a manager for which all validators always deny access.static AccessManagerbasic()Creates a manager that issues validators that perform simple group memebership checks (that is, a user has equivalent access to a group if and only if they belong to that group).doValidate(AccessContext context, Group group, Supplier<Mono<Boolean>> membershipCheck) Validates that an access is legal.static AccessManageroverridable(GuildGroup overrideGroup) Creates a manager that issues validators that generally perform group membership checks, but also allows a given group to override any permission in the system (that is, users that are members of the given group have equivalent permissions to any other group).default AccessValidatorvalidator(AccessContext context) Creates an access validator under the given context.default ChannelAccessValidatorvalidator(ChannelAccessContext context) Creates an access validator under the given context.
-
Method Details
-
doValidate
Mono<Boolean> doValidate(AccessContext context, Group group, Supplier<Mono<Boolean>> membershipCheck) Validates that an access is legal.- Parameters:
context- The access context.group- The required group.membershipCheck- A function that appliesGroup.belongs(ChannelAccessContext)orGuildGroup.belongs(AccessContext)(as appropriate).- Returns:
- Whether the access is allowed.
-
validator
Creates an access validator under the given context.- Parameters:
context- The access context for the current execution.- Returns:
- The appropriate access validator.
-
validator
Creates an access validator under the given context.- Parameters:
context- The access context for the current execution.- Returns:
- The appropriate access validator.
-
alwaysAllow
Creates a manager for which all validators always allow access. That is, a manager that allows access for any user to any group (effectively disabling group checking).- Returns:
- The manager.
-
alwaysDeny
Creates a manager for which all validators always deny access. That is, a manager that denies access for any user to any group (effectively disabling any functionality that requires group membership).- Returns:
- The manager.
-
basic
Creates a manager that issues validators that perform simple group memebership checks (that is, a user has equivalent access to a group if and only if they belong to that group).- Returns:
- The manager.
-
overridable
Creates a manager that issues validators that generally perform group membership checks, but also allows a given group to override any permission in the system (that is, users that are members of the given group have equivalent permissions to any other group).- Parameters:
overrideGroup- The group that overrides any permission check.- Returns:
- The manager.
-