Java group/privilege management library
Find a file
2026-02-11 15:47:16 +00:00
src Tests and minimum working 2026-02-08 19:31:02 +00:00
.gitignore Initial structure Hans Gruper 2026-02-03 12:30:12 +00:00
pom.xml Gruper inital release 2026-02-11 15:47:16 +00:00
README.md Merge branch 'main' of ssh://192.168.2.5:2222/Mazzola/Gruper 2026-02-08 08:13:31 +00:00

Hans Gruper

Hans

Hit it again

Java group/privilege management library

What and why

We assign groups to users to mange permissions. Groups can be single groups such as api.users.create; which allows a user to access the create user api, or arrays of groups such as ["api.users.create", "api.keys.read"]; which allows this user to access the create user api but only read API keys.

Gruper is simply a shared utility to compare the groups arrays/strings with preset permissions set in code.

Usage

In this example, we have a API controller endpoint for creating a new user. Within the controller, we can compare the current users groups with a pre-set permission id to see if they have correct access permissions

...
List<String> usersGroups = Arrays.asList("api.users.create", "api.keys.read");
if (!Gruper.compare(usersGroups, "api.users.create")) {
    return "Access denied";
}
...

In this example, if the user had the permissions api.users, this would allow them to access ALL of the api.users sub-groups too, such as api.users.create.