foundation-techstack

FROM PROJECT DIRECTORY

BUILD OF IMAGE

Build a Docker image of container from shell command (including force remove of intermediary container) from shell command line:

  docker-compose build --force-rm

CHECK IMAGE

Scan image vulnerabilities from shell command line:

  docker scan agnet/cybnity-keycloak-distribution

START IMAGE

Run a docker container without shell console (as a daemon without interaction) or without -d argument to maintain shell console opened from shell command line:

  docker-compose up -d

RUN

When start process is executed, a Quarkus Keycloack server in development mode is executed:

Integration with CYBNITY Frontend ui

Realm registration

Create a Realm similar to a Tenant Id relative to an organization (e.g named cybnity) from the top-left select menu with click on Create Realm button.

Set the Cybnity realm configuration

Set the Security defenses configuration:

Clients registrations from Cybnity realm

Register a new Keycloak client dedicated to proto-frontend-ui-server (allowing user authentication from web browser when access to web UI) from the administration console:

Register a new Keycloak client dedicated to proto-backend-ui-server (allowing sso check by server-side during reception of Event bus messages) from the administration console:

From the Installation panel (allowing download of keycloack.json setting file to store into the resources folder of proto-backend-ui-server Maven project), the Keycloak OIDC JSON file is similar to the sample:

  {
  "realm": "cybnity",
  "auth-server-url": "http://localhost:8082/",
  "ssl-required": "external",
  "resource": "cybnity-backend-api",
  "verify-token-audience": true,
  "credentials": {
    "secret": "eNnieaQ63RE33bugdVJBHXe69XcfHbEX"
  },
  "use-resource-role-mappings": true,
  "confidential-port": 0,
  "policy-enforcer": {}
  }

Applicative roles definition

Test user account creation

By default, new created Realm has none user. Create a test account declared for a test user allowing to use the proto-frontend-ui-server web UI:

Test user account creation

By default, new created Realm has none user. Create a test account declared for a test user allowing to use the proto-frontend-ui-server web UI:

Client scope creation

If you have many applications you need to secure and register within your organization, it can become tedious to configure role scope mappings for each of these clients. Keycloak allows you to define a shared client configuration in an entity called a client scope. If we want to get client roles in a custom key in the JWT token, we have to add client scope to put client roles in access token.

Go to Client Scopes and create a new scope:

Go to Clients > cybnity-frontend-ui-react > Client Scopes panel for add the custom scope previously created:

From now, we can get the client roles from the JWT token with roles key, allowing to enable/disable proto-frontend-ui-server’s view to particular roles received from the token.

Tests

Test user account authentication

When disconnected of any user account:

Test of secured access to frontend

From proto-front-end-ui web access, try access to Secured Screen with use of Keycloak test account.

MONITOR

Check that startup log contains (ensuring that desired feature is enabled) the following line:

  INFO  [org.key.com.Profile] (main) Preview feature enabled: token_exchange

Read logs from shell command line:

  docker-compose logs -f

STOP IMAGE

Kill container from shell command line:

  docker-compose kill

or

  docker kill agnet/cybnity-keycloak-distribution

PUBLISH TO DOCKER REPOSITORY

Create tag for built container distribution specific to CYBNITY technology from shell command line:

  docker tag cybnity-keycloak-distribution agnet/cybnity-keycloak-distribution:latest

Push docker image to online CYBNITY private Docker repository from shell command line:

  docker push agnet/cybnity-keycloak-distribution:latest