diff --git a/README.md b/README.md index 7f58b7f5..17e22412 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,17 @@ An application to get authorization from users to access their data through 3rd party APIs. Mainly supports OAuth2 Authorization code follow to request authorization and processes the returned authorization code to add new entries of users. It creates new users and adds properties compatible and required by the [RADAR REST and Fitbit connectors](https://github.com/RADAR-base/RADAR-REST-Connector). + +* [RADAR-REST-Source-Auth](#radar-rest-source-auth) + * [Features supported](#features-supported) + * [APIs to be used by REST Source-Connectors](#apis-to-be-used-by-rest-source-connectors) + * [Installation](#installation) + * [Authorization](#authorization) + * [Registering OAuth Clients with ManagementPortal](#registering-oauth-clients-with-managementportal) + * [Sentry monitoring](#sentry-monitoring) + * [Migrating from 1.\*.\* version to 2.\*](#migrating-from-1-version-to-2) + + ## Features supported 1. It has one active entity where we store user properties. @@ -60,6 +71,10 @@ callback-url: /login # the callback-url should be resolvable and match with the environment variable of radar-rest-sources-authorizer -> AUTH_CALLBACK_URL in the docker-compose.yml file. ``` +## Sentry monitoring + +See [here](authorizer-app-backend/README.md#sentry-monitoring) for instructions on how to enable Sentry monitoring. + ## Migrating from 1.\*.\* version to 2.\* 1. Move configurations from application.yml and environment variables to `authorizer.yml` following the description in `authorizer.yml.template`. diff --git a/authorizer-app-backend/README.md b/authorizer-app-backend/README.md new file mode 100644 index 00000000..6fca1938 --- /dev/null +++ b/authorizer-app-backend/README.md @@ -0,0 +1,19 @@ +# RADAR-REST-Source-Auth backend + +This is the backend for the RADAR REST Source Authorizer application. + +## Sentry monitoring + +To enable Sentry monitoring: +1. Set a `SENTRY_DSN` environment variable that points to the desired Sentry DSN. +2. (Optional) Set the `SENTRY_LOG_LEVEL` environment variable to control the minimum log level of events sent to Sentry. + The default log level for Sentry is `ERROR`. Possible values are `TRACE`, `DEBUG`, `INFO`, `WARN`, and `ERROR`. + +For further configuration of Sentry via environmental variables see [here](https://docs.sentry.io/platforms/java/configuration/#configuration-via-the-runtime-environment). For instance: + +``` +SENTRY_LOG_LEVEL: 'ERROR' +SENTRY_DSN: 'https://000000000000.ingest.de.sentry.io/000000000000' +SENTRY_ATTACHSTACKTRACE: true +SENTRY_STACKTRACE_APP_PACKAGES: org.radarbase.authorizer +``` diff --git a/authorizer-app-backend/build.gradle.kts b/authorizer-app-backend/build.gradle.kts index 5f1b9613..e059681f 100644 --- a/authorizer-app-backend/build.gradle.kts +++ b/authorizer-app-backend/build.gradle.kts @@ -1,9 +1,12 @@ +import org.radarbase.gradle.plugin.radarKotlin + plugins { application - kotlin("plugin.serialization") - kotlin("plugin.noarg") - kotlin("plugin.jpa") - kotlin("plugin.allopen") + id("org.radarbase.radar-kotlin") + kotlin("plugin.serialization") version Versions.kotlin + kotlin("plugin.noarg") version Versions.kotlin + kotlin("plugin.jpa") version Versions.kotlin + kotlin("plugin.allopen") version Versions.kotlin } application { @@ -11,7 +14,6 @@ application { } dependencies { - api(kotlin("stdlib-jdk8")) implementation(kotlin("reflect")) implementation("org.radarbase:radar-jersey:${Versions.radarJersey}") @@ -22,7 +24,7 @@ dependencies { implementation("redis.clients:jedis:${Versions.jedis}") - implementation(enforcedPlatform("io.ktor:ktor-bom:${Versions.ktor}")) + implementation(enforcedPlatform("io.ktor:ktor-bom")) implementation("io.ktor:ktor-client-core") implementation("io.ktor:ktor-client-auth") implementation("io.ktor:ktor-client-cio") @@ -39,3 +41,11 @@ allOpen { annotation("jakarta.persistence.MappedSuperclass") annotation("jakarta.persistence.Embeddable") } + +radarKotlin { + javaVersion.set(Versions.java) + kotlinVersion.set(Versions.kotlin) + log4j2Version.set(Versions.log4j2) + sentryEnabled.set(true) + openTelemetryAgentEnabled.set(true) +} diff --git a/authorizer-app-backend/docker-compose.yml b/authorizer-app-backend/docker-compose.yml index 5cd1bce7..011cb474 100644 --- a/authorizer-app-backend/docker-compose.yml +++ b/authorizer-app-backend/docker-compose.yml @@ -59,6 +59,10 @@ services: # - REST_SOURCE_AUTHORIZER_MANAGEMENT_PORTAL_OAUTH_CLIENT_SECRET=secret # - LOGGING_LEVEL_ORG_RADARBASE_AUTHORIZER=DEBUG # - APP_SLEEP=10 # gives time for the database to boot before the application +# - SENTRY_LOG_LEVEL='ERROR' +# - SENTRY_DSN='https://000000000000.ingest.de.sentry.io/000000000000' +# - SENTRY_ATTACHSTACKTRACE=true +# - SENTRY_STACKTRACE_APP_PACKAGES=org.radarbase.authorizer # volumes: # - ./docker/etc/rest-source-authorizer/:/app-includes/ # healthcheck: diff --git a/authorizer-app-backend/src/main/resources/log4j2.xml b/authorizer-app-backend/src/main/resources/log4j2.xml new file mode 100644 index 00000000..69476831 --- /dev/null +++ b/authorizer-app-backend/src/main/resources/log4j2.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/build.gradle.kts b/build.gradle.kts index 8a4e778e..d182e7d7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,28 +1,10 @@ -import org.radarbase.gradle.plugin.radarKotlin - plugins { id("org.radarbase.radar-root-project") version Versions.radarCommons id("org.radarbase.radar-dependency-management") version Versions.radarCommons id("org.radarbase.radar-kotlin") version Versions.radarCommons apply false - kotlin("plugin.serialization") version Versions.kotlin apply false - kotlin("plugin.noarg") version Versions.kotlin apply false - kotlin("plugin.jpa") version Versions.kotlin apply false - kotlin("plugin.allopen") version Versions.kotlin apply false } radarRootProject { projectVersion.set(Versions.project) gradleVersion.set(Versions.gradle) } - -subprojects { - apply(plugin = "org.radarbase.radar-kotlin") - - radarKotlin { - javaVersion.set(Versions.java) - kotlinVersion.set(Versions.kotlin) - slf4jVersion.set(Versions.slf4j) - log4j2Version.set(Versions.log4j2) - junitVersion.set(Versions.junit) - } -} diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 24b29a33..6961feff 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,22 +1,19 @@ @Suppress("ConstPropertyName") object Versions { - const val project = "4.4.9" + const val project = "4.5.0" const val java = 17 const val kotlin = "1.9.23" - const val radarCommons = "1.1.3" + const val radarCommons = "1.2.2" const val radarJersey = "0.12.2" const val postgresql = "42.6.1" - const val ktor = "2.3.11" const val jedis = "5.1.3" - const val slf4j = "2.0.13" const val log4j2 = "2.23.1" const val jersey = "3.1.7" - const val junit = "5.10.2" const val mockitoKotlin = "5.3.1" const val hamcrest = "2.2"