Skip to content

Integral-Technology-Solutions/keycloak-fapi

 
 

Repository files navigation

FAPI-SIG (Financial-grade API Security : Special Interest Group)

Overview

FAPI-SIG is a group whose activity is mainly supporting Financial-grade API (FAPI) and its related specifications to keycloak.

FAPI-SIG is open to everybody so that anyone can join it anytime. Nothing special need not to be done to join it. Who want to join it can only access to the communication channels shown below. All of its activities and outputs are public so that anyone can access them.

FAPI-SIG mainly treats FAPI and its related specifications but not limited to. E.g., Ecosystems employing FAPI for their API Security like UK OpenBanking and Australia Consumer Data Right (CDR).

Goals

Currently, proposed goals are as follows.

Open Works

Currently, proposed open works are as follows.

Communication Channels

Not only FAPI-SIG member but others can communicate with each other by the following ways.

Working Repository

All of FAPI-SIG's activity outputs can be stored on jsoss-sig/keycloak-fapi repository in github.

Who want to submit the output needs to send the pull-request to this repository.

How to run FAPI Conformance suite with Keycloak server in your local machine

Software requirements

Run FAPI Conformance suite, Keycloak server and Test Runner

Edit hosts file as per the Modify your hosts file section

This repository contains default self-signed certificates for HTTPS, client private keys, Keycloak Realm JSON and FAPI Conformance suite config JSONs. If you would like to use the configurations as it is, you only need to build and boot all the containers using Docker Compose.

Run the following command from the project basedir to start the test suite

docker-compose up --build

The OpenID FAPI Conformance test interface will then be reachable at https://localhost:8443. See instructions in Run FAPI Conformance test plan section for running the tests manually in your browser.

To stop all containers after the automated tests have run:

docker-compose up --build --exit-code-from test_runner

The following options can be set as environment variables before the above command:

  • KEYCLOAK_BASE_IMAGE (default: quay.io/keycloak/keycloak:11.0.1)
    • The keycloak image version used in the test suite
  • KEYCLOAK_REALM_IMPORT_FILENAME (default: realm.json)
    • The keycloak realm import filename. Set this to realm.json if you are running the tests against a local build of keycloak.
  • AUTOMATE_TESTS (default: true)
    • Set to false to stop conformance-suite tests automatically running
  • MVN_HOME (default: ~/.m2)
    • Set to use a custom maven home path
  • OPENID_GIT_TAG (default: release-v4.1.4)
    • The OpenID Conformance Suite Git Tag to be cloned

Example:

KEYCLOAK_BASE_IMAGE=jboss/keycloak:6.0.1 docker-compose up --build

To stop and remove all containers, run the following:

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

Test Reports

Once test_runner service has finished and exited, test reports will be copied to the ./conformance-suite/report directory.

Modify your hosts file

To access to Keycloak and Resource server with FQDN, modify your hosts file in your local machine as follows.

127.0.0.1 as.keycloak-fapi.org rs.keycloak-fapi.org conformance-suite.keycloak-fapi.org

Run FAPI Conformance test plan manually

  1. Run this project with AUTOMATE_TESTS=false environment variable set
  2. Open https://conformance-suite.keycloak-fapi.org
  3. Click Create a new test plan button.
  4. Choose FAPI-RW-ID2 (and OpenBankingUK): Authorization server test (latest version) as Test Plan.
  5. Choose Client Authentication Type you want to test.
  6. Choose plain_fapi as FAPI Profile.
  7. Choose plain_response as FAPI Response Mode.
  8. Click JSON tab and paste content of the configuration.
  1. Click Create Test Plan button and follow the instructions. To proceed with the tests, You can authenticate using john account with password john. When rejecting authentication scenario, you can use mike account with password mike. In this case, you need to click No button to cancel the authentication in the consent screen.

For Developers

Currently, generators of all configurations are written with bash script and some CLI tools for linux-amd64.

Run generate-all.sh script simply to generate self-signed certificates for HTTPS, client private keys, Keycloak Realm JSON and FAPI Conformance suite config JSONs.

./generate-all.sh

Now, you can boot a Keycloak server with new configurations.

docker-compose up --force-recreate

Run FAPI Conformance test against local built keycloak

If you would like to run FAPI Conformance test against local built keycloak, modify docker-compose.yml as follows.

@@ -28,6 +28,7 @@ services:
      - ./https/server.pem:/etc/x509/https/tls.crt
      - ./https/server-key.pem:/etc/x509/https/tls.key
      - ./https/client-ca.pem:/etc/x509/https/client-ca.crt
+     - <path to locally built keycloak>:/opt/jboss/keycloak
     ports:
      - "8787:8787"
     environment:

It overrides the keycloak of the base image with the one built on the local machine.

Then run the FAPI Conformance Suite with KEYCLOAK_REALM_IMPORT_FILENAME env var:

KEYCLOAK_REALM_IMPORT_FILENAME=realm-local.json docker-compose up --build

Run FAPI Conformance test with persistent OpenID Server DB volume

Running this test suite does not require a persistent storage volume for MongoDB. The main benefit of using persistent volume storage is that the OpenID Conformance Suite will remember the last test plan config you used, allowing for easier and faster manual test operation. If you wish to enable persistent volume storage for the MongoDB container, uncomment the following lines in ./docker-compose.yml

...
#    volumes:
#     - mongodata:/data/db
...
#volumes:
#  mongodata:

Custom files in the conformance suite

The conformance-suite folder within this repository is a local copy of OpenIds FAPI conformance suite (https://gitlab.com/openid/conformance-suite/). Incorporating the suite and running the conformance tests within docker-compose requires adding custom files into the base OpenId FAPI conformance suite. Below is a list of the custom files currently used by the base conformance-suite.

  • /conformance-suite/run-tests.sh
    • Script for running / creating test plans
  • /conformance-suite/Dockerfile
    • Dockerfile which installs python dependencies, exposes ports and kicks off building the project via the server-entrypoint script
  • /conformance-suite/server-entrypoint.sh
    • Script for building the project with maven
  • /conformance-suite/scripts/run-test-plan.py
    • Existing file within the base conformance-suite repo that has been slightly modified to output test results to the file system.

Running different test plans

To create custom test plans, add code into /conformance-suite/run-tests.sh as per commented out examples. JSON configuration files for test plans should be created in /conformance-suite/.gitlab-ci/

License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 48.9%
  • Python 44.7%
  • Lua 2.3%
  • Dockerfile 2.1%
  • Go 2.0%