|
1 ano atrás | |
---|---|---|
.. | ||
src | 1 ano atrás | |
README.md | 1 ano atrás | |
app.js | 1 ano atrás | |
package.json | 1 ano atrás |
Level: Beginner Technologies: HTML5, JavaScript Summary: HTML5 Service Invocation Application run under Express Target Product: Keycloak Source: https://github.com/keycloak/keycloak-quickstarts
The app-nodejs-html5
quickstart demonstrates how to write an application with HTML5 and JavaScript that authenticates
using Keycloak. Once authenticated the application shows how to invoke a service secured with Keycloak.
You need to have Node.js version 12.x or later installed.
The quickstart requires that you have the service-nodejs running. It assumes the
services are located at http://localhost:3000/service
. If the services are running elsewhere you need to edit
app.js
and replace the value of serviceUrl
.
Prior to running the quickstart you need to create a client in Keycloak and download the installation file.
The following steps show how to create the client required for this quickstart:
Clients
from the menuCreate
marketing-html5
)openid-connect
http://localhost:8080/marketing-html5
).Save
If you deploy the application somewhere else change the hostname and port of the URLs accordingly.
Once saved you need to change the Access Type
to public
and click save.
Finally you need to configure the JavaScript adapter, this is done by retrieving the adapter configuration file:
Installation
in the tab for the client you createdKeycloak OIDC JSON
Download
keycloak.json
to the src/main/webapp
directory in the root of the quickstartAs an alternative you can create the client by importing the file client-import.json and
copying config/keycloak-example.json to src/main/webapp/keycloak.json
.
Open a terminal and navigate to the root directory of this quickstart.
The following shows the command to deploy the quickstart:
npm install
npm run start
You can access the application with the following URL: http://localhost:8080/marketing-html5.
The application provides buttons that allows invoking the different endpoints on the service:
user
to be logged-inadmin
to be logged-inIf you invoke the endpoints without the required permissions an error will be shown.