/csaf-cms-backend

Primary LanguageJavaMIT LicenseMIT

BSI Secvisogram CSAF Backend

Coverage

About The Project

TODO

(back to top)

Getting started

To run the CSAF CMS server you need the following:

You can find an example setup for local development in the 'compose.yaml' and an example configuration for Keycloak in 'keycloak/csaf-realm.json'. You can take this as a starting point, but please check the documentation of the individual projects for a proper production setup. We also recommend running everything behind some kind of reverse proxy. Please take a look at our Architecture for an overview.

The secvisogram frontend is usable as a standalone version without this server. You can still use this standalone mode if the frontend is not behind the proxy, like in the development setup. In this setup where both standalone and server mode are available, the login is only required to manage documents on the server or validate against the validator service.

To build the application run:

./gradlew clean build

The resulting jar file in the build/libs folder can then be run with java -jar filename.jar. To manage the process you can use Docker or an init system of your choice.

(back to top)

How to use

Please have a look at the API documentation on how to use this application.

(back to top)

Developing

The configuration of the application as well as the compose file is done in a local .env file. To start, simply copy the .env.example file to .env. If you want different passwords, database names or ports you can change them in that file. Please note that the following setup is for development purposes only and should not be used in production.

  • run docker compose up
  • After Keycloak is up, open a second terminal window and run docker compose up csaf-keycloak-cli to import a realm with all the users and roles already set up.
  • To set up our CouchDB server open http://127.0.0.1:5984/_utils/#/setup and run the Single Node Setup. This creates databases like _users and stops CouchDB from spamming our logs
  • Open http://localhost:9000/ and log in with the admin user.
    • The port is defined in .env - CSAF_KEYCLOAK_PORT, default 9000
    • On the left side, navigate to "Clients" and select the Secvisogram client.
    • Select the Credentials tab and copy the Secret. This is our CSAF_CLIENT_SECRET environment variable.
  • Generate a cookie secret and paste it in CSAF_COOKIE_SECRET.
  • Create a database in CouchDB with the name specified in CSAF_COUCHDB_DBNAME
  • restart compose
  • (required for exports) install pandoc (tested with version 2.18) as well as weasyprint (tested with version 56.0) and make sure both are in your PATH
  • (optional for exports) define the path to a company logo that should be used in the exports through the environment variable CSAF_COMPANY_LOGO_PATH. The path can either be relative to the project root or absolute. See .env.example file for an example.

You should now be able to start the spring boot application, navigate to localhost:4180/api/v1/about, log in with one of the users and get a response from the server. The port is defined in .env - CSAF_APP_EXTERNAL_PORT, default 4180

build and execute tests

./gradlew clean build

build and run SpotBugs

./gradlew clean assemble spotbugsMain

start application

./gradlew bootRun

with main class: de.bsi.secvisogram.csaf_cms_backend.SecvisogramApplication

check application running

The port is defined in .env - CSAF_CMS_BACKEND_PORT, default 8081.

http://localhost:8081/api/v1/about

Swagger UI

http://localhost:8081/swagger-ui/index.html

OpenAPI specification

http://localhost:8081/v3/api-docs/

access couchDB

The port is defined in .env - CSAF_CMS_BACKEND_PORT, default 5984.

http://localhost:5984/_utils/#login

CouchDb Info (port is defined in .env):

http://localhost:5984/

Contributing

You can find our guidelines here CONTRIBUTING.md

(back to top)

Dependencies

Spring Boot

Reference Documentation

For further reference, please consider the following sections:

(back to top)

Guides

The following guides illustrate how to use some features concretely:

(back to top)

Additional Links

These additional references should also help you:

(back to top)

Code Quality Rules

Exxcellent Code Quality Rules

(back to top)

SpotBugs

(back to top)

Jacoco

(back to top)

Links

CSAF

OASIS CSAF

BSI CSAF

(back to top)

JSON

(back to top)

Mustache

Mustache samskivert

(back to top)

PoC for Backend

PoC Backend

(back to top)

Open API/ Swagger

Open API Swagger Annotations

(back to top)

diagrams.net (formerly known as draw.io)

(back to top)