Clean, simple & fast way to handle your permissions in game.
IsAuthorized is a lightweight declarative-wrote library which allows for simple and fast permissions checking, reliable for a variety of projects. The library boasts customizable, and is easily accessible for all developer skill levels.
This library has been created with large scale comparison in mind, with a focus on performance at the core of the package.
IsAuthorized is available for Wally, or can be downloaded manually using a CLI or through GitHub. It is suggested you install this through Wally. If you have never used Wally before, I advise you take a quick tutorial on it from their website.
You can install this library by inserting the following into your wally.toml file, and
then
running wally install via your CLI.
You can directly install the IsAuthorized library through your CLI by querying to this website's files.
You are able to manually download the IsAuthorized rbxm file through the
Releases tab
in the library's GitHub. Make sure to install the
latest
version.
This library's API has been developed to be simplistic, compact; but powerful. The cost of the API is in the developer's hands. IsAuthorized uses a declarative API to ensure minimal resources, and does not overload functions with costly under-the-trunk code- allowing for full customization for the developer, and minimal resources used by the code.
IsAuthorized prides itself on this not only compact API, but its customization.
In order to apply configuration to IsAuthorized, developers can create .auth lua files in order to
configure settings within IsAuthorized.
To add groups to query, you simply add a Groups.auth.lua file anywhere in ReplicatedStorage.
IsAuthorized(...2)Parameters
1: Player type: Player2: AuthQuery type: AuthQuery<AuthQueryString>Returns
1: IsAuthorizedOrNot? type: booleanCompiles and compares the authorization query based on the player's attributes, data and other provided features. Lightweight and fast- does not cache; perfected for large comparisons and plenty of options for customization.
tostring(IsAuthorized, ...1<ST>)Parameters
1: ModuleAuthQuery type: ModuleScriptReturns
1: type: booleanUsed internally to stringify ModuleScripts for reading authorization queries.
IsAuthorized#EvaluateQuery(...2)Parameters
1: Player type: Player2: Query type: AuthQueryStringReturns
1: IsAuthorizedOrNot? type: boolean
Same functionality as IsAuthorized(...2) however accepts a singular query instead of a group of queries.
Faster compile speed & much less expensive, but it's recommended you only use this if you are only checking a small amount of individual
queries.
IsAuthorized#Async(...2)Parameters
1: Player type: Player2: AuthQuery type: AuthQuery<AuthQueryString>Returns
1: AuthPromise type: Promise
Same functionality as IsAuthorized(...2) however returns a promise instead of a pure-lua boolean.
Now that we have covered the core API, using IsAuthorized is simple.
All: AuthQueryStringThe "All" keyword allows for any user to have permissions, regardless of any other factors.
Group: AuthQueryStringThe "Group" function allows us to query the user's rank in a group and evaluate permissions from there.
Evaluating if a user is in a group
The following example evaluates if a user is in the group provided.
Specifying a specific rank
The following example evaluates if a user is the specific rank.
Evaluating a range of ranks
The following example evaluates if a user is within the given range of ranks.
The following example evaluates if a user is above or equal to the given rank.
The following example evaluates if a user is less or equal to the given rank.
Team: AuthQueryStringTeam allows for a specific team to be specified for evaluation, Team is based on the physical and current team on the Player.
IsClient: AuthQueryStringIf the code is being ran on the client.
IsServer: AuthQueryStringIf the code is being ran on the server.
IsAuthorized allows for complex validation that is dynamic and expressive based on your inputs.
RequireAll: AuthCommandQueryThe evaluation will only be true if the user meets all the requirements.
!: AuthCommandQueryThe evaluation will be negated (NOT QUERY, !QUERY, true = false, false = true), also known as inversing the operation.
Complex ExpressionsFeeling familiar with IsAuthorized, lets look at some complex expressions to ensure you get the full use of IsAuthorized.
The following expression requires the user to be a member of the Police Department team, but also they have the option of being in either the SWAT group at any role, or role 9+ in the Police group; however they are required to be in one of them alongside being in the Police Department team.
IsAuthorization allows you to simply add new functions which you can immediately use.
Step 1: Locate the "Groups" folder within the IsAuthorized source file. (If you are using Wally, this will be in the Packages>_Index folder.)Step 2: Create a ModuleScript; name this module script the name of your function.Utilize the following format to create your own function, with the comments as guidance:
Explaining the Function
Parameters
1: Player type: Player= The player who is being evaluated.2: Groups type: table= Provides a list of all the groups in the Groups.auth.lua (exact replica).3: Arguments type: string= Provides the string query, for example "Group:Test:*" which you can then string.split(":") to get each argument.4: RequestPacket type: RequestPacket= Provides information regarding the request.AuthQuery<T>
The full query provided to an IsAuthorized evaluation. Also known as a "Segment"
{ querystring, querystring }
AuthQueryStringAn individual string query within an AuthQuery.
AuthCommandQuery
Something that is included within the AuthQuery but is not an authorization
tool- rather acts to influence the behavior of the AuthQuery.
For example RequireAll is not a permission tool, rather influences that all queries must be true.
RequestPacketPacket of information regarding the sent authorization query. Also known as "StandardRequestPacket"