Chapter 3. Business application configuration
3.1. Business application authentication and authorization Copy linkLink copied to clipboard!
By default, business applications are secured by protecting all REST endpoints (URLs that contain /rest/). In addition, business applications have two sets of log in credentials that allow users to connect to Business Central in development mode: the user with the ID user and password user and the user with the ID kieserver and password kieserver1!.
Both authentication and authorization is based on Spring security. Alter this security configuration for all business applications used in production environments. You can make configuration changes in the <business-application>/<business-application>-services/src/main/java/com/company/service/DefaultWebSecurityConfig.java file:
3.2. Configuring the application.properties file Copy linkLink copied to clipboard!
After you create your business application, you can configure several components through the application.properties file to customize your application.
Prerequisites
-
You have a
<business-application>.zipfile that you created using the business application website.
Procedure
-
Unzip the
<business-application>.zipfile and navigate to the<business-application>/<business-application>-service/src/main/resourcesfolder. -
Open the
application.propertiesfile in a text editor. Configure the host, port, and path for the REST endpoints, for example:
server.address=localhost server.port=8090 cxf.path=/rest
server.address=localhost server.port=8090 cxf.path=/restCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Decision Server (
kieserver) so that it can be easily identified, for example:kieserver.serverId=<business-application>-service kieserver.serverName=<business-application>-service kieserver.location=http://localhost:8090/rest/server kieserver.controllers=http://localhost:8080/jbpm-console/rest/controller
kieserver.serverId=<business-application>-service kieserver.serverName=<business-application>-service kieserver.location=http://localhost:8090/rest/server kieserver.controllers=http://localhost:8080/jbpm-console/rest/controllerCopy to Clipboard Copied! Toggle word wrap Toggle overflow The following table lists the Decision Server parameters that you can configure in your business application:
Expand Table 3.1. kieserver parameters Parameter Values Description kieserver.serverIdstring
The ID used to identify the business application when connecting to the Decision Manager controller.
kieserver.serverNamestring
The name used to identify the business application when connecting to the Decision Manager controller. Can be the same string used for the
kieserver.serverIdparameter.kieserver.locationURL
Used by other components that use the REST API to identify the location of this server. Do not use the location as defined by
server.addressandserver.port.kieserver.controllersURLs
A comma-separated list of controller URLs.
If you selected Business Automation when you created your business application, specify which of the following components that you want to start at runtime:
Expand Table 3.2. kieserver capabilities parameters Parameter Values Description kieserver.drools.enabledtrue, falseEnables or disables the Decision Manager component.
kieserver.dmn.enabledtrue, falseEnables or disables the Decision Model and Notation (DMN) component.
3.3. Configuring the business application with Red Hat Single Sign-On Copy linkLink copied to clipboard!
You can use Red Hat Single Sign-On (RH SSO) to enable single sign-on between your services and to have a central place to configure and manage your users and roles.
Prerequisites
-
You have a
<business-application>.zipfile that you created using the business applications website.
Procedure
- Download and install RH SSO. For instructions, see the Red Hat Single Sign-On Getting Started Guide.
Configure RH SSO:
- Either use the default master realm or create a new realm.
-
Create the
springboot-appclient and set theAccessTypeto public. Set a valid redirect URI and web origin according to your local setup, for example:
-
Valid redirect URIs:
http://localhost:8090/* -
Web origin:
http://localhost:8090
-
Valid redirect URIs:
- Create realm roles that are used in the application.
- Create users that are used in the application and assign roles to them.
Add the following dependencies to the service project
pom.xmlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the
application.propertiesfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Modify the
DefaultWebSecurityConfig.javafile to ensure that Spring Security works correctly with RH SSO:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4. Configuring business application user group providers Copy linkLink copied to clipboard!
With Red Hat Decision Manager, you can manage human-centric activities. To provide integration with user and group repositories, you can use two KIE API entry points:
-
UserGroupCallback: Responsible for verifying whether a user or group exists and for collecting groups for a specific user -
UserInfo: Responsible for collecting additional information about users and groups, for example email addresses and preferred language
You can configure both of these components by providing alternative code, either code provided out of the box or custom developed code.
For the UserGroupCallback component, retain the default implementation because it is based on the security context of the application. For this reason, it does not matter which backend store is used for authentication and authorisation (for example, RH-SSO). It will be automatically used as a source of information for collecting user and group information.
The UserInfo component is a separate component because it collects more advanced information.
Prerequisites
-
You have a
<business-application>.zipfile that you created using the business application website and that contains a business automation project.
Procedure
To provide an alternative implementation of
UserGroupCallback, add the following code to the Application class or a separate class annotated with@Configuration:@Bean(name = "userGroupCallback") public UserGroupCallback userGroupCallback(IdentityProvider identityProvider) throws IOException { return new MyCustomUserGroupCallback(identityProvider); }@Bean(name = "userGroupCallback") public UserGroupCallback userGroupCallback(IdentityProvider identityProvider) throws IOException { return new MyCustomUserGroupCallback(identityProvider); }Copy to Clipboard Copied! Toggle word wrap Toggle overflow To provide an alternative implementation of
UserInfo, add the following code to the Application class or a separate class annotated with@Configuration:@Bean(name = "userInfo") public UserInfo userInfo() throws IOException { return new MyCustomUserInfo(); }@Bean(name = "userInfo") public UserInfo userInfo() throws IOException { return new MyCustomUserInfo(); }Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.5. Enabling Swagger documentation Copy linkLink copied to clipboard!
You can enable Swagger-based documentation for all endpoints available in the service project of your Red Hat Decision Manager business application.
Prerequisites
-
You have a
<business-application>.zipfile that you created using the business applications website.
Procedure
-
Unzip the
<business-application>.zipfile and navigate to the<business-application>/<business-application>-servicefolder. -
Open the service project
pom.xmlfile in a text editor. Add the following dependencies to the service project
pom.xmlfile and save the file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow To enable the Swagger UI (optional), add the following dependency to the
pom.xmlfile and save the file.<dependency> <groupId>org.webjars</groupId> <artifactId>swagger-ui</artifactId> <version>2.2.10</version> </dependency>
<dependency> <groupId>org.webjars</groupId> <artifactId>swagger-ui</artifactId> <version>2.2.10</version> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Open the
<business-application>/<business-application>-service/src/main/resources/application.propertiesfile in a text editor. Add the following line to the
application.propertiesfile to enable Swagger support:kieserver.swagger.enabled=true
kieserver.swagger.enabled=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
After you start the business application, you can view the Swagger document at http://localhost:8090/rest/swagger.json. The complete set of endpoints is available at http://localhost:8090/rest/api-docs?url=http://localhost:8090/rest/swagger.json.