End User Authentication and Authorization with OpenShift Service Mesh and Keycloak
Recently I was working on a React project with Go backend using Gin web framework. Keycloak was the authentication mechanism for the frontend; I also wanted to secure the backend using JSON Web Tokens which was provided by Keycloak on every login. Setup for jwt verification in Go was easy.
First, copy RS256 algorithm public key value from Keycloak
Send the token as Authorization header
axios .get(BACKEND_URL.concat("sampleendpoint"), { headers: { Authorization: this.
In this post, I will show you how to secure a React app using RedHat SSO (upstream keycloak). In this case, openid-connect is my identity provider.
Install the official keycloak js adapter
npm i keycloak-js --save Setup the client with the host and port; in my case it’s localhost:9000
In App.js add in a JavaScript object with the required configuration; you will find these configurations under Clients->Installation
//keycloak init options const initOptions = { url: "https://localhost:8080/auth", realm: "test", clientId: "react-app", onLoad: "login-required" }; By default, to authenticate you need to call the login function.