ACS2 (Access Control Service) is a microservice designed to handle access management and group-based authorization for distributed systems. It provides an API for managing permissions, roles, and user access across multiple services. ACS2 allows for flexible integration with various backends, including Spring Boot applications.
acs-client/java: Java client for interacting with the ACS2 API.acs-core: Shared components module for acs-plane and acs-server.acs-plane: Definitions server and control panelacs-proto: Protocol definitions and library for communication between ACS2 services.acs-server: Core backend service providing access control logic.acs-spring-boot-starter: Spring Boot integration module for seamless integration with Spring Security.examples: Example modules demonstrating use-cases of different ACS2 functionalities
- Java 17 or higher
- MariaDB (or any compatible database)
- Recommended: Docker/Kubernetes for production deployment
To set up ACS2 locally, clone the repository and use one of pre-defined configurations.
Docker Compose:
docker compose up -dThis setup directly runs gradle from within the main folder, so changing files and restarting the container has immediate effect.
Compose is configured with a test MariaDB database.
Kubernetes:
kubectl apply -k k8s/overlays/devACS2 relies on several environment variables for configuration. Below are the key variables:
| Variable Name | Description | Default Value | Required |
|---|---|---|---|
DATASOURCE_HOST |
Database host string (without port) | — | ✅ |
DATASOURCE_PORT |
Database port | 3306 | ❌ |
DATASOURCE_DB |
Database database name | — | ✅ |
DATASOURCE_USR |
Database user | — | ✅ |
DATASOURCE_PWD |
Database password | — | ✅ |
ACS_DELIMITER |
Permission nodes delimiter | . | ❌ |
ACS_DEFINITIONS_SOURCE |
Definitions source address | — | ✅ |
ACS_DEFINITIONS_FORMAT |
Definitions string format | YAML | ❌ |
ACS_REALM_NAME |
Realm name (only when using plane) | default | ❌ |
Definitions source URL example:
http://definitions-server/api/realm/<realm>/definitions/v1
Realm is your custom realm that you configured in the definitions server
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/groups |
List all access groups |
| POST | /api/permissions |
Create a new permission |
| PUT | /api/users/{id} |
Update user roles |
| DELETE | /api/groups/{id} |
Delete an access group |
For complete API documentation, refer to the OpenAPI/Swagger specification here.
The acs-spring-boot-starter module provides easy integration with Spring Boot and Spring Security.
To integrate ACS2 with your Spring Boot application, add the following dependency to your build.gradle or pom.xml:
dependencies {
implementation 'com.github.ZorTik:acs-spring-boot-starter:0.1.0'
}The starter automatically configures connection of your service with ACS2. First, please customize details in your application.yml/application.properties file:
acs.client:
base-url: http://acs-base-urlNow, you can access the AcsClientV1 instance anywhere in your Spring application:
@Autowired
private AcsClientV1 acsClient;First, enable Spring Security integration using the @EnableAcsSecurity annotation:
@EnableAcsSecurity
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}Next, create implementation of AcsUserDetailsService and register it using AcsSecurityConfigurer:
public class MyCustomAcsUserDetailsService extends AcsUserDetailsService {
public AcsUserDetailsService(
@NotNull AcsClientV1 client,
@NotNull SubjectProvider systemSubjectProvider, String userSubjectType) {
super(client, systemSubjectProvider, userSubjectType);
}
@Override
public UserDetails loadUserByUsernameAndAuthorities(
String username, Collection<? extends GrantedAuthority> authorities) {
// Custom logic to load user details by username.
// Authorities are already provided by ACS2.
}
@Override
public boolean existsByUsername(String username) {
// Check if a user exists by username.
// If returned false, this prevents from calling ACS2 for authorities.
}
}
@Configuration
public class SecurityConfig implements AcsSecurityConfigurer {
@Override
AcsUserDetailsService userDetailsService(
AcsClientV1 client, SubjectProvider systemSubjectProvider, String userSubjectType) {
return new MyCustomAcsUserDetailsService();
}
}- Declarative method security.
- Context-aware group resolution.
- Seamless integration with Spring Security's
@PreAuthorize,@Secured, and@RolesAllowedannotations.
- Implement your own
SystemSubjectProviderFactoryfor your own system subject resolution logic.
The acs-client module provides a lightweight Java client for interacting with the ACS2 backend.
AcsClientV1 client = AcsClient.v1()
.withOkHttpAdapter()
.withBaseUrl("<ACS2_URL>")
.withHttpSerializer(new GsonHttpSerializer(new Gson()))
.build();// Example of making a permission check
CheckAccessResponseV1 response = client.checkAccess(accessor, accessed, nodes);
boolean allGranted = response.all();
boolean anyGranted = response.anyOf("node1.subnode1", "node2");To run tests for ACS2, use the following Gradle commands:
- Unit tests:
./gradlew testacs2/
├── acs-client/ # Java client for interacting with the ACS2 API.
├── acs-core/ # Shared components module for acs-plane and acs-server.
├── acs-plane/ # Definitions server and control panel
├── acs-proto/ # Protocol definitions and library for communication between ACS2 services.
├── acs-server/ # Core backend service providing access control logic.
├── acs-spring-boot-starter/ # Spring Boot integration module for seamless integration with Spring Security.
└── k8s/ # Kubernetes configurations
- Add new roles to the
Permissionenum for fine-grained access control. - Extend
PermissionServiceto implement custom business logic. - Update the client or integration layers for enhanced functionality.
We welcome contributions to ACS2. To contribute, follow these steps:
- Fork the repository.
- Create a new branch:
feature/my-feature. - Implement your changes.
- Submit a Pull Request.
For detailed contribution guidelines, please refer to the CONTRIBUTING.md file.
This project is licensed under the MIT License. See the LICENSE file for more details.
For any issues, please open a GitHub Issue, and our team will respond as soon as possible.
