This documentation is for WSO2 App Manager 1.0.0. View documentation for the latest release.
Demonstrating JSON Web Token (JWT) Usage - Plan Your Trip App - App Manager 1.0.0 - WSO2 Documentation
||
Skip to end of metadata
Go to start of metadata

Introduction

JSON Web Tokens (JWT) are a compact and URL-safe means of transferring claims between apps. This sample demonstrates how to share claims defined in WSO2 App Manager, with the apps that are published in it using JSON Web Tokens (JWT). It uses a sample Web app named Plan Your Trip to demonstrate how claims that you add as attributes of a user profile in WSO2 App Manager, are transferred to a published Web app.

Prerequisites

  • Download WSO2 App Manager, and start the server. 

  • Start the Web server (e.g. Apache Tomcat)

Building the sample

Follow the steps below to build the Plan Your Trip app.

  1. Download the Plan Your Trip sample app (plan-your-trip.war file).
  2. Copy the plan-your-trip.war file to <TOMCAT_HOME>/webapps/ directory, to host the file in the Web server.
  3. Restart the Web server. You can access the Plan Your Trip Web app from your Web browser using the following URL: http://<IP_ADDRESS>:8080/plan-your-trip/

Building from source

Alternatively, you can build the sample app by building the product source. Follow the steps below to download the source and build the app.

  1. Download the source code of the product using the following command.
    $ git clone https://github.com/wso2/product-app-manager/
  2. Navigate to product-app-manager/web_apps/plan-your-trip/ directory from the CLI, and build the source using the command: mvn clean install
  3. Copy the plan-your-trip/target/plan-your-trip.war file to <TOMCAT_HOME>/webapps/ directory, to host the file in the Web server.
  4. Restart the Web server. You can access the Plan Your Trip Web app from your Web browser using the following URL: http://<IP_ADDRESS>:8080/plan-your-trip/

Executing the sample

Follow the steps below to execute the sample.

Adding claims to the user

Follow the steps below to add claims as attributes of the admin user in WSO2 App Manager.

  1. Log in to the management console using the following URL with admin/admin credentials: https://<AppM_HOST>:<AppM_PORT>/carbon/
  2. Click Configure, and then click Claim Management.
  3. Click http://wso2.org/claims, and then click Add New Claim Mapping.
  4. Add a new claim for the Frequent Flyer ID by entering the following details, and click Add as shown below.

    add a new claim for frequent flyer ID
    You view the new claim added to the available claim mappings list.

  5. Click the corresponding Edit link of the Frequent Flyer ID.

  6. Select the Supported by Default option, and click Update as shown below.

    You will not be able to select the Supported by Default option when you add the claim in step 4 due to a known issue, which will be fixed in future releases.


    In addition to the above new claims, this sample uses the following claims that are available by default as shown below. 
    claims available by default

  7. Follow the steps below for each of the above claims to update them.

    • Click the corresponding Edit link.
    • Select the Supported by Default  checkbox, and click Update to add them as attributes of the user profile.

Updating the profile

Follow the steps below to update the profile by entering the values for the newly added claims.

  1. Log in to the management console using the following URL with admin/admin credentials: https://<AppM_HOST>:<AppM_PORT>/carbon/
  2. Click Configure, and then click Users and Roles.
  3. Click Users, and then since you are logged in as admin, click User Profile link of the admin user.
  4. Enter the details as shown below, and click Update.
    update user profile

Creating the Web app

Follow the steps below to create a new Web app in App Publisher to publish the Plan Your Trip app.

Completing the Overview section

Follow the steps below to complete the first step of creating a new Web app.

  1. Log in to the App Publisher of WSO2 App Manager using the following URL with admin/admin credentials: http://<AppM_HOST>:<AppM_PORT>/publisher
  2. Click Add New Web Application, to add the Plan Your Trip Web app using the App Publisher. 

  3. Enter the details in the Overview section as shown below. For instructions on the Overview section of adding a Web app, see Step 1 - Overview.
    create Web app - Overview
Completing the Advanced Configuration section
  1. Click Advanced Configuration, and then click Claims.

  2. Follow the steps below to enter all claims as shown below. For instructions on specifying the claims in the Advanced Configuration section of adding a Web app, see Step 4 - Advanced Configuration.

    • Select the claim URI from the Available Claims list.
    • Click Add Claim.
    add claims
  3. Click Create.

Publishing the Web app

Follow the steps below to publish the Web app in the App Publisher. For more instructions on publishing a Web app, see Publishing Web Applications.

  1. In the All Web Applications list, click Submit for Review button corresponding to the app.
  2. Click Approve.
  3. Click Publish.

Subscribing to the Web app

Follow the steps below to subscribe to the Web app. For instructions on subscribing to a Web app, see Subscribing to Applications.

  1. Log in to the App Store of WSO2 App Manager using the following URL: http://<AppM_HOST>:<AppM_PORT>/store
  2. Click on the image of the Web app.
  3. Click Subscribe Me.
  4. Click the Gateway Endpoint URL of the Web app as shown below.
    published Web app

You are automatically logged in to the app if the single sign-on feature is enabled in WSO2 App Manager. The values you added for the claims are filled automatically as shown below.

Plan Your Trip Web app

  • No labels