Skip to content

hmcts/opal-common-lib

Repository files navigation

opal-commonlib

Shared Opal components for authentication, authorisation, and other cross-cutting concerns. This module builds a reusable Java library—there is no runnable Spring Boot application here.

Build & Test

Use the bundled Gradle wrapper:

./gradlew clean build

The task runs the JUnit 5 test suite and produces build/libs/opal-common-lib-<version>.jar. During day-to-day work the library is usually brought into opal-fines-service via Gradle composite build (includeBuild('../opal-common-lib') in settings.gradle), which gives instant feedback in IntelliJ.

Local Development Tips

  • Library source lives under src/main/java/uk/gov/hmcts/opal/common/...; unit tests live in src/test/java/uk/gov/hmcts/opal/common/....
  • Additional source sets (functionalTest, integrationTest, smokeTest) are configured and available if extra coverage is helpful.
  • Dependency versions are managed through the Spring Boot and Spring Cloud BOMs declared in build.gradle.
  • If you prefer testing the published coordinates instead of includeBuild, install the jar to your local Maven cache:
    ./gradlew publishToMavenLocal
    Then depend on uk.gov.hmcts:opal-common-lib:<version> from the consuming project.

Permission Model

The shared authentication models expose permissions via the PermissionDescriptor contract. Each consuming service supplies its own implementation (an enum is the recommended approach) that returns the numeric id issued by the user service. For example:

@Getter
@RequiredArgsConstructor
public enum FinesPermission implements PermissionDescriptor {
    ACCOUNT_ENQUIRY(3L, "Account Enquiry");

    private final long id;
    private final String description;
}

Those enums can then be passed straight into UserState and BusinessUnitUser helpers (hasPermission, anyBusinessUnitUserHasPermission, etc.).

Publishing

Azure Artifacts publishing is handled by the CI pipeline once pull requests merge; no local publish step is required when developing.

License

This project is licensed under the MIT License – see LICENSE for details.