Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<!-- TOC -->
* [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)
<!-- TOC -->

## Features supported

1. It has one active entity where we store user properties.
Expand Down Expand Up @@ -60,6 +71,10 @@ callback-url: <advertised-url-of-rest-sources-authorizer-app>/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`.
Expand Down
19 changes: 19 additions & 0 deletions authorizer-app-backend/README.md
Original file line number Diff line number Diff line change
@@ -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
```
22 changes: 16 additions & 6 deletions authorizer-app-backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
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 {
mainClass.set("org.radarbase.authorizer.Main")
}

dependencies {
api(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))

implementation("org.radarbase:radar-jersey:${Versions.radarJersey}")
Expand All @@ -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")
Expand All @@ -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)
}
4 changes: 4 additions & 0 deletions authorizer-app-backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
39 changes: 39 additions & 0 deletions authorizer-app-backend/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ /*
~ * Copyright 2024 The Hyve
~ *
~ * Licensed under the Apache License, Version 2.0 (the "License");
~ * you may not use this file except in compliance with the License.
~ * You may obtain a copy of the License at
~ *
~ * http://www.apache.org/licenses/LICENSE-2.0
~ *
~ * Unless required by applicable law or agreed to in writing, software
~ * distributed under the License is distributed on an "AS IS" BASIS,
~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ * See the License for the specific language governing permissions and
~ * limitations under the License.
~ */
-->

<configuration status="INFO">
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
/>
</Console>
<!-- For Sentry to work the DSN must be set via SENTRY_DSN environment variable
When SENTRY_DSN is empty string, the Sentry SDK is disabled -->
<Sentry name="Sentry" debug="false"/>
</appenders>

<loggers>
<root level="${env:LOG4J_LOG_LEVEL:-INFO}">
<appender-ref ref="Console" />
<!-- Note that the Sentry logging threshold is at WARN level by default -->
<appender-ref ref="Sentry" level="${env:SENTRY_LOG_LEVEL:-ERROR}" />
</root>
</loggers>
</configuration>
18 changes: 0 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
}
7 changes: 2 additions & 5 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
Loading