BYUApiCalls validates authentication and user information that you receive from WSO2.
Documentation
Description
This module allows other apps to use the data in your Mendix app by accessing the API. It does so by validating and decrypting the authentication token (called a JWT) coming from WSO2. More information on JWTs can be found here.
Typical Usage Scenario
This is only used if you are making a Web Service (API) in a Mendix app and you want to use WSO2 as the authentication layer instead of OAuth.
Prerequisites
Create a Web Service. Check out this YouTube video for instructions on how to do so.
How to Use
Run your project locally without authentication to make sure the Web Service works.
Add an authentication method.
Best practice is to use a custom authentication method (create a new microservice)
Make sure BYUApiCalls is installed along with all of it's dependencies (refer to the installation section for more information)
Navigate to the _USE_ME folder and call the microflow ACT_JWT_ValidateAndDecode in the microflow that you created
rename the variable to "JWT"
Validate if the JWT is empty or not
click on add a decision
click other decision and fill in the caption and expression. Refer to the example below.
Set two conditions, true and false. One that returns an empty user and one that returns a System.user object from your Mendix database.
When an empty JWT is returned your web service microflow won't be called and a 401 HTTP status code will be returned to the caller.
Read about implementing custom authentication in your microflow in section 3.3.
This is what this microflow should return. The example we have in the screenshot is one way to do it but it is not the only way.
This is what your microflow should look like:
The final step is to publish your API in the API manager.
Refer here for documentation on adding an API to the API Manager.
Download the package here. It will save as BYUApiCalls.mpk
Note: If you are using Mendix Studio Pro 8.8.* or 8.9.* downloading private app store modules/widgets was turned off due to security concerns. All the BYU Private App Store content can still be downloaded from the Company Content page in the Mendix App Store and then imported into those versions of Studio Pro. Upgrading to a newer version of Mendix Studio Pro fixes the problem.
After the download finishes, import BYUApiCalls into your project.
Right click on your Project Explorer
Select Import Module Package
Select the module you just downloaded and click Open