Skip to content

itk-dev/serviceplatformen_organisation_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serviceplatformen Organisation API

About the project

Sets up an API with data from Serviceplatformen Organisation.

Built with

Disclaimer

The API has no authentication methods and should not be exposed to the web.

SF1500 Data

The objects from SF1500 that we are interested in are Person, Bruger, Adresse, OrganisationFunktion and OrganisationEnhed. Each of these come with an identifier and at least one Registrering. See SF1500 objects and object model.

We create views combining information from objects, resulting in the following views which will serve as the base for our API.

View Columns
bruger id, az, navn, email, telefon, lokation
funktion id, bruger_id, funktionsnavn, enhedsnavn, adresse, tilknytted_enhed_id, funktions_type
organisation id, enhedsnavn, overordnet_id

Getting started

To get a local copy up and running follow these steps.

Installation

  1. Clone the repo

    git clone [email protected]:itk-dev/serviceplatformen_organisation_api.git
  2. Pull docker images and start docker containers

    docker compose pull
    docker compose up --detach
  3. Install composer packages

    docker compose exec phpfpm composer install
  4. Run database migrations

    docker compose exec phpfpm bin/console doctrine:migrations:migrate --no-interaction

You should now be able to browse to the api

open "http://$(docker compose port nginx 8080)/api"

Configuration

Configure the following environment variables in .env.local

###> serviceplatformen ###
# Certificate options
SF1500_ORGANISATION_CERTIFICATE_LOCATOR_TYPE=APP_SF1500_ORGANISATION_CERTIFICATE_LOCATOR_TYPE
# LOCATOR_TYPE Should be 'azure_key_vault' or 'file_system'.
SF1500_ORGANISATION_CERTIFICATE_PATH=APP_SF1500_ORGANISATION_CERTIFICATE_PATH
SF1500_ORGANISATION_CERTIFICATE_TENANT_ID=APP_SF1500_ORGANISATION_CERTIFICATE_TENANT_ID
SF1500_ORGANISATION_CERTIFICATE_APPLICATION_ID=APP_SF1500_ORGANISATION_CERTIFICATE_APPLICATION_ID
SF1500_ORGANISATION_CERTIFICATE_CLIENT_SECRET=APP_SF1500_ORGANISATION_CERTIFICATE_CLIENT_SECRET
SF1500_ORGANISATION_CERTIFICATE_NAME=APP_SF1500_ORGANISATION_CERTIFICATE_NAME
SF1500_ORGANISATION_CERTIFICATE_SECRET=APP_SF1500_ORGANISATION_CERTIFICATE_SECRET
SF1500_ORGANISATION_CERTIFICATE_VERSION=APP_SF1500_ORGANISATION_CERTIFICATE_VERSION
SF1500_ORGANISATION_CERTIFICATE_PASSPHRASE=APP_SF1500_ORGANISATION_CERTIFICATE_PASSPHRASE
# Other options
SF1500_ORGANISATION_AUTHORITY_CVR=APP_SF1500_ORGANISATION_AUTHORITY_CVR
SF1500_ORGANISATION_STS_APPLIES_TO=APP_SF1500_ORGANISATION_STS_APPLIES_TO
SF1500_ORGANISATION_TEST_MODE=APP_SF1500_ORGANISATION_TEST_MODE
SF1500_ORGANISATION_MANAGER_ROLE_UUID_TEST=APP_SF1500_ORGANISATION_MANAGER_ROLE_UUID_TEST
SF1500_ORGANISATION_MANAGER_ROLE_UUID_PROD=APP_SF1500_ORGANISATION_MANAGER_ROLE_UUID_PROD
###< serviceplatformen ###

Commands

Before fetching data the database should be emptied. If not, objects that were available during both fetches will appear twice.

Reset database

docker compose exec phpfpm bin/console doctrine:migrations:migrate --no-interaction first
docker compose exec phpfpm bin/console doctrine:migrations:migrate --no-interaction

Fetch data

To fetch data from SF1500 run

docker compose exec phpfpm bin/console organisation:fetch:data DATATYPES --page-size=PAGE-SIZE --max=MAX

for help run

docker compose exec phpfpm bin/console organisation:fetch:data --help

To avoid issues with memory leaks during development add the --no-debug flag to the fetch data command. You may also want to add the verbose flag to see progress.

docker compose exec phpfpm bin/console --no-debug organisation:fetch:data -vvv

API

See

open "http://$(docker compose port nginx 8080)/api"

for api specifics.

Example calls

Search for users

curl "http://$(docker compose port nginx 8080)/api/v1/bruger?page=1&navn=Jeppe%20Kuhlmann"

Search parameters

Name Type Example
navn Text navn=Jeppe%20Kuhlmann
az Text az=az12345
email Text email=jeppe%40test.dk
telefon Text telefon=12345678
lokation Text lokation=ITK

Get info on user

curl "http://$(docker compose port nginx 8080)/api/v1/bruger/ffdb7559-2ad3-4662-9fd4-d69849939b66"

Here ffdb7559-2ad3-4662-9fd4-d69849939b66 should be a bruger identifier.

Get funktioner

curl "http://$(docker compose port nginx 8080)/api/v1/bruger/ffdb7559-2ad3-4662-9fd4-d69849939b66/funktioner"

Here ffdb7559-2ad3-4662-9fd4-d69849939b66 should be a bruger identifier.

Using the API from another docker compose setup

To use the API you must use the serviceplatformen_organisation_api_app network.

networks:
  organisation_api:
    external: true
    name: serviceplatformen_organisation_api_app

services:
  phpfpm:
    networks:
      - organisation_api
    ...

The API is now available at http://organisation_api:8080 i.e.

curl "http://organisation_api:8080/api/v1/bruger?page=1&navn=Jeppe%20Kuhlmann"

Coding standard tests

The following commands let you test that the code follows the coding standards we decided to adhere to in this project.

  • PHP files (PHP-CS-Fixer with the Symfony ruleset enabled)

    docker compose exec phpfpm composer coding-standards-check
  • Markdown files (markdownlint standard rules)

    docker compose run --rm node yarn install
    docker compose run --rm node yarn coding-standards-check

Coding standards apply

The following commands let you apply the coding standards we decided to adhere to in this project.

  • PHP files (PHP-CS-Fixer with the Symfony ruleset enabled)

    docker compose exec phpfpm composer coding-standards-apply
  • Markdown files (markdownlint standard rules)

    docker compose run --rm node yarn install
    docker compose run --rm node yarn coding-standards-apply

Code analysis

psalm

docker compose exec phpfpm composer code-analysis