Skip to content

feature: [174] Implement ACL DSL using Google Mug#175

Open
crazyrokr wants to merge 21 commits into
developfrom
feature/174-implement-acl-engine-in-java
Open

feature: [174] Implement ACL DSL using Google Mug#175
crazyrokr wants to merge 21 commits into
developfrom
feature/174-implement-acl-engine-in-java

Conversation

@crazyrokr

@crazyrokr crazyrokr commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Issue

#174

Description

This pull request implements an Access Control List (ACL) Domain-Specific Language (DSL) using Google Mug library and integrates it into the application configurations.

Changes

  • Implement ACL DSL with Mug: Implemented the parser and infrastructure for parsing ACLs.
  • Integrate new implementation into configs: Updated application configuration to utilize the new Mug-based DSL for ACL definitions.

Impact

This change enables ability to use authorization service (ACL engine) in native image

@crazyrokr crazyrokr linked an issue Jun 8, 2026 that may be closed by this pull request
@crazyrokr crazyrokr added enhancement New feature or request security labels Jun 8, 2026
@crazyrokr crazyrokr requested a review from JavaSaBr June 8, 2026 09:37
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Test Coverage Report

Overall Project 85.54% -0.27% 🍏
Files changed 90.13% 🍏

File Coverage
AclConfigurationException.java 100% 🍏
AclRulesLoader.java 100% 🍏
MugDslBasedAclServiceSpringConfig.java 100% 🍏
MqttBrokerSpringConfig.java 98.78% 🍏
GaclParser.java 89.14% -10.86% 🍏
UriLoaderAuthorizationService.java 83.22% 🍏
GroovyDslBasedAclServiceSpringConfig.java 0% -25%

@crazyrokr crazyrokr marked this pull request as ready for review June 8, 2026 09:45
@crazyrokr crazyrokr closed this Jun 9, 2026
@crazyrokr crazyrokr reopened this Jun 9, 2026
@crazyrokr crazyrokr changed the title feature: [174] Implement ACL DSL using Antlr feature: [174] Implement ACL DSL using Google Mug Jun 9, 2026
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
public class GaclParser {

CharPredicate WHITESPACE = CharPredicate.anyOf(" \t\r\n");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

why it looks like final static constans but it's not a static?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a new ACL DSL implementation based on Google Mug and wires it into the broker’s Spring configuration, aiming to replace/augment the existing Groovy-based ACL DSL and improve compatibility with native-image builds.

Changes:

  • Added new acl-mug-dsl module (parser + file loader) with Spock tests and example .gacl configs.
  • Integrated the Mug-based ACL engine selection into the standalone application and test configuration.
  • Updated Gradle configuration (module includes, version catalog, and JaCoCo aggregation) to account for the new module/dependencies.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test-coverage/build.gradle Adds JaCoCo aggregation for the new acl-mug-dsl module.
settings.gradle Registers the new :acl-mug-dsl Gradle module.
gradle/libs.versions.toml Adds Mug and dot-parse dependencies to the version catalog.
application/src/test/resources/application-test.properties Switches integration tests to use mug-dsl and a unified acl.engine.config.path property.
application/src/main/java/javasabr/mqtt/broker/application/config/MqttBrokerSpringConfig.java Switches the standalone app to import the Mug-based ACL Spring config.
application/build.gradle Replaces acl-groovy-dsl dependency with acl-mug-dsl.
acl-service/src/main/java/javasabr/mqtt/acl/service/impl/UriLoaderAuthorizationService.java Refactors authorization service to accept a pluggable rules loader function and loads ACL rules from a URI-backed path.
acl-service/src/main/java/javasabr/mqtt/acl/service/conifg/MugDslBasedAclServiceSpringConfig.java New Spring config enabling Mug DSL engine based on acl.engine.type=mug-dsl.
acl-service/src/main/java/javasabr/mqtt/acl/service/conifg/GroovyDslBasedAclServiceSpringConfig.java Updates Groovy DSL config to use the unified acl.engine.config.path property and shared loader-based service.
acl-service/build.gradle Adds compileOnly API dependency on acl-mug-dsl.
acl-mug-dsl/src/test/resources/acl/test-acl-shorthand.gacl Adds shorthand DSL example file for tests.
acl-mug-dsl/src/test/resources/acl/test-acl-full.gacl Adds full-feature DSL example file for tests.
acl-mug-dsl/src/test/resources/acl/invalid/invalid-syntax.gacl Adds invalid DSL sample for negative parsing tests.
acl-mug-dsl/src/test/groovy/javasabr/mqtt/acl/mug/dsl/parser/GaclParserTest.groovy Adds parser unit tests for directives/conditions/errors.
acl-mug-dsl/src/test/groovy/javasabr/mqtt/acl/mug/dsl/loader/AclRulesLoaderTest.groovy Adds loader tests for missing/unreadable file scenarios and success path.
acl-mug-dsl/src/main/java/javasabr/mqtt/acl/mug/dsl/parser/GaclParser.java Implements the Mug-based .gacl parser producing AclRule objects.
acl-mug-dsl/src/main/java/javasabr/mqtt/acl/mug/dsl/loader/AclRulesLoader.java Implements filesystem-based ACL rules loading and grouping by operation.
acl-mug-dsl/build.gradle Declares the new module’s dependencies and Groovy test setup.
acl-engine/src/main/java/javasabr/mqtt/acl/engine/exception/AclConfigurationException.java Adds a (message, cause) constructor to preserve error causes.
.gitignore Broadens ignoring of out/ folders across submodules.

Comment on lines +158 to +164
.map(s -> {
try {
return DynamicTopicMatcher.autoBuild(s);
} catch (RuntimeException e) {
throw new AclConfigurationException(e.getMessage());
}
}),
@RequiredArgsConstructor
public class AclRulesLoader {

private final GaclParser parser ;
GaclParser parser = new GaclParser()

@Unroll
def "should parse string literal containing #pattern without treating it as a comment"() {
thrown(AclConfigurationException)
}

def "should handle empty users section"() {

@Bean
AuthorizationService authorizationService(@Value("${acl.engine.groovy.dsl.config}") URI aclConfigUri) {
AuthorizationService authorizationService(@Value("${acl.engine.config.path}") URI aclConfigUri) {
Comment on lines 71 to 76
@Import({
AuthenticationServiceSpringConfig.class,
GroovyDslBasedAclServiceSpringConfig.class,
MugDslBasedAclServiceSpringConfig.class,
MqttExternalPlainNetworkConfig.class,
MqttExternalTlsNetworkConfig.class
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement ACL engine in Java

3 participants