How to Authenticate with OpenID Connect + Angular2 SPA + ZAP (Part 1)

How to Authenticate with OpenID Connect + Angular2 SPA + ZAP (Part 1)

This blog post will show you how to perform authentication with OpenID Connect with ZAP using a Angular2 sample application. We will be using KeyCloak ( to provide the OpenID Connect feature. 


The Setup

KeyCloak Server
With reference to,

  • Unzip the Keycloak server downloaded file
  • Depending on your OS, modify the bin/ file to include the line 
    JAVA_OPTS=%JAVA_OPTS% -Djboss.socket.binding.port-offset=100
    This is set the Keycloak server to operate on 8180 so as to prevent port clash with the Wildfly server 
  • Execute .\bin\ depending on your OS, to start up the Keycloak server.
  • Following the instructions here – under the  Creating the admin account and Logging into the admin console sections. Do not do anything else outside these 2 sections.
  • Going back to , follow the instructions under Create Roles and User section. In addition to those instructions, please add the admin role to the user as well on top of the user role.

Wildfly Server
This is where we will be deploying the angular2 app and also an additional JAX-RS Service with public and protected endpoints which will be called by the angular2 app.

  • Unzip the Wildfly server downloaded file
  • Unzip and copy all contents (bin, doc, module) into wildfly top level directory.
  • Depending on your OS, execute .\bin\ –file=adapter-install-offline.cli to install the OpenID Connect client adapter into Wildfly server.
  • Depending on your OS, execute .\bin\ to start up the Wildfly server.

With reference to, 

  • Unzip the download quickstarts zip file.
  • Follow the instructions under the Configuration in Keycloak section.
  • Go into the keycloak-quickstarts-latest\service-jee-jaxrs source directory.
  • Open up pom.xml and add in the xml snippet just after the section
  • Follow instructions under Build and Deploy the Quickstart section to deploy the service-jee-jaxrs service to Wildfly server.

With reference to ,

  • Follow instructions under System Requirements section.
  • Go into the keycloak-quickstarts-latest\app-angular2 source directory
  • Edit the pom.xml to add in the xml snippet in the <properties/> section.
  • Follow instructions in the Configuration in Keycloak section. Be sure to specify the username and password to be myusern and mypassword to be the same as what’s used in the authentication script. Or alternatively, you can just update the authentication script.
  • Change the code in keycloak-quickstarts-latest\app-angular2\src\main\webapp\app\app.component.js from
    this.serviceUrl = ‘’;
    this.serviceUrl = ‘http://localhost:8080/service/’;
    or you will get a CORS error when clicking on the links of the application.
  • Follow instructions in Build and Deploy the Quickstart section to deploy app-angular2 application to the Wildfly server.
  • Look at the information under the Access the Quickstart section

When you launch ZAP while the Wildfly server is running, you will get an error message that port 8080 is in use. We will need to change this to 8081 or any other unused port.

If you missed that, then you can change the port here, under options:

in the Context

Create a new Jython HttpSender script

Go to Part 2

1 thought on “How to Authenticate with OpenID Connect + Angular2 SPA + ZAP (Part 1)”

  1. Ӏt’s in reality a nice and usefuⅼ рiece of information. I’m
    ѕatisfied that you just shaгed this helpful info with us.
    Please keeр us up to date like this. Thanks for sharing.

Leave a Comment

Your email address will not be published. Required fields are marked *