Skip to main content

BYUApiCalls

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

  1. Run your project locally without authentication to make sure the Web Service works.
  2. Add an authentication method. 
    1. Best practice is to use a custom authentication method (create a new microservice)
    2. Make sure BYUApiCalls is installed along with all of it's dependencies (refer to the installation section for more information)
    3. Navigate to the _USE_ME folder and call the microflow ACT_JWT_ValidateAndDecode in the microflow that you created
      1. rename the variable to "JWT"
    4. Validate if the JWT is empty or not
      1. click on add a decision
      2. click other decision and fill in the caption and expression. Refer to the example below.
    5. Set two conditions, true and false. One that returns an empty user and one that returns a System.user object from your Mendix database.
      1. 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.
    6. Read about implementing custom authentication in your microflow in section 3.3.
      1. 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. 
    7. This is what your microflow should look like:
    8. The final step is to publish your API in the API manager.
      1. Refer here for documentation on adding an API to the API Manager.

    Dependencies

    Installation

    1. Download the package here. It will save as BYUApiCalls.mpk
      1. 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.
    2. After the download finishes, import BYUApiCalls into your project.
      1. Right click on your Project Explorer
      2. Select Import Module Package
      3. Select the module you just downloaded and click Open

    More Resources

    Learn how to install a module in Mendix.

    Slack

    For additional help, refer to the appropriate slack channels in their respective workspaces:

    1. BYU-OIT workspace
      1. #api-management
      2. #mendix
    2. BYU-Web workspace
      1. #mendix-user-group