-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
Expected behaviour
Externalize OPA-related properties using configuration properties to improve configurability.
Actual behaviour
We have some properties such as opaURL, opaPath, and reasonKey. Currently, these properties can only be set through code. Moreover, there are some constants which can be defined as properties.
How to improve
By externalizing these properties using a @ConfigurationProperties (link1, link2), we could:
- manage these properties as a Spring bean
- setting default values
- standardize their name
- validate them
- enable client applications to change them through properties/yaml file, environment variables, system properties, ... without rebuilding code
We could define OPAProperties class:
...
@ConfigurationProperties(prefix = "opa")
@Data
@NoArgsConstructor
public class OpaProperties {
private String url = "http://localhost:8181";
private String path;
private String reasonKey = "en";
private String requestContextType = "http";
private String requestContextSubjectType = "java_authentication";
private String requestResourceType = "endpoint";
...
}and use these properties in classes like OPAAuthorizationManager. (request... properties can also be wrapped in a separate object.)
On the flip side, client applications can easily define and change these properties, for instance in:
- application.yaml:
opa:
url: http://localhost:8181
path: tickets/main
reason-key: de
...- command-line arguments (system properties):
java -jar myapp.jar --opa.url=http://localhost:8181 --opa.path=tickets/main- environment variables:
export OPA_URL=http://localhost:8181
export OPA_PATH=tickets/main
java -jar myapp.jarMetadata
Metadata
Assignees
Labels
No labels