Skip to content

Commit

Permalink
Merge branch 'main' into release-0.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Bdegraaf1234 authored Mar 18, 2024
2 parents 7d87908 + 390a33a commit 76915cf
Show file tree
Hide file tree
Showing 130 changed files with 2,611 additions and 2,305 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
# Change these settings to your own preference
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{json,yaml,yml}]
indent_size = 2
89 changes: 89 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]
schedule:
- cron: '24 21 * * 0'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
language: [ 'java-kotlin' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Continuous integration, including test and integration test
name: CI

# Run in master and dev branches and in all pull requests to those branches
# Run in main and dev branches and in all pull requests to those branches
on:
push:
branches: [ master, dev ]
branches: [ main, dev ]
pull_request:
branches: [ master, dev ]
branches: [ main, dev ]

jobs:
# Build and test the code
Expand All @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/publish_snapshots.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Continuous integration, including test and integration test
name: Publish snapshots

# Run in master and dev branches and in all pull requests to those branches
# Run in main and dev branches and in all pull requests to those branches
on:
push:
branches: [ dev ]
Expand All @@ -17,18 +17,19 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Has SNAPSHOT version
id: is-snapshot
run: grep 'version = ".*-SNAPSHOT"' build.gradle.kts

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Has SNAPSHOT version
id: is-snapshot
run: |
./gradlew properties | grep 'version: .*-SNAPSHOT'
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Compile code
- name: Compile code
run: ./gradlew assemble
run: ./gradlew assemble collectLicenses

# Upload it to GitHub
- name: Upload to GitHub
uses: AButler/[email protected]
uses: AButler/[email protected].2
with:
files: 'radar-jersey/build/libs/*;radar-jersey-hibernate/build/libs/*'
files: 'radar-jersey/build/libs/*;radar-jersey-hibernate/build/libs/*;radar-jersey*/build/reports/*.tar.gz'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install gpg secret key
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scheduled_snyk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
- cron: '0 2 * * 1'
push:
branches:
- master
- main

jobs:
security:
Expand All @@ -21,7 +21,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/snyk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Snyk test
on:
pull_request:
branches:
- master
- main

jobs:
security:
Expand All @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand All @@ -29,4 +29,5 @@ jobs:
--all-sub-projects
--configuration-matching='^runtimeClasspath$'
--org=radar-base
--policy-path=$PWD/.snyk
--policy-path=.snyk
--severity-threshold=high
1 change: 1 addition & 0 deletions .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ignore:
expires: 2023-14-30T10:58:31.820Z
created: 2022-10-31T10:58:31.828Z
patch: {}
severityThreshold: high
66 changes: 53 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}
dependencies {
api("org.radarbase:radar-jersey:0.9.2")
api("org.radarbase:radar-jersey:0.11.0")
}
```

Expand All @@ -21,27 +21,62 @@ Any path or resource that should be authenticated against the ManagementPortal,
@Path("/projects")
@Authenticated
class Users(
@Context projectService: MyProjectService
@Context private val projectService: MyProjectService,
@Context private val asyncService: AsyncCoroutineService,
@Context private val authService: AuthService,
) {
// Most services can be run as coroutines with
// asynchronous handling
@GET
@NeedsPermission(PROJECT, READ)
fun getProjects(@Context auth: Auth): List<Project> {
return projectService.read()
.filter { auth.token.hasPermissionOnProject(PROJECT_READ, it.name) }
@NeedsPermission(Permission.PROJECT_READ)
fun getProjects(
@Suspended asyncResponse: AsyncResponse,
) = asyncService.runAsCoroutine(asyncResponse) {
projectService.read()
.filter { authService.hasPermission(PROJECT_READ, entityDetails { project(it.name) }) }
}

@POST
@Path("/{projectId}")
@NeedsPermission(PROJECT, UPDATE, "projectId")
fun updateProject(@PathParam("projectId") projectId: String, project: Project) {
return projectService.update(projectId, project)
@NeedsPermission(Permission.PROJECT_UPDATE, "projectId")
fun updateProject(
@PathParam("projectId") projectId: String,
project: Project,
@Suspended asyncResponse: AsyncResponse,
) = asyncService.runAsCoroutine(asyncResponse) {
projectService.update(projectId, project)
}

@GET
@Path("/{projectId}/users/{userId}")
@NeedsPermission(SUBJECT, READ, "projectId", "userId")
fun getUsers(@PathParam("projectId") projectId: String, @PathParam("userId") userId: String) {
return projectService.readUser(projectId, userId)
@NeedsPermission(Permission.SUBJECT_READ, "projectId", "userId")
fun getUsers(
@PathParam("projectId") projectId: String,
@PathParam("userId") userId: String,
@Suspended asyncResponse: AsyncResponse,
) = asyncService.runAsCoroutine(asyncResponse) {
projectService.readUser(projectId, userId)
}

// Simple responses can be handled without context switches
@GET
@Path("/{projectId}/settings")
@NeedsPermission(Permission.PROJECT_READ, "projectId")
fun getProjectSettings(
@PathParam("projectId") projectId: String,
): ProjectSettingsDto {
return ProjectSettingsDto(projectId = projectId)
}

// Simple coroutine responses can also handled without context switches
@GET
@Path("/{projectId}/users/{userId}/settings")
@NeedsPermission(Permission.SUBJECT_READ, "projectId", "userId")
fun getProjectSettings(
@PathParam("projectId") projectId: String,
@PathParam("userId") userId: String,
) = asyncService.runBlocking {
UserSettingsDto(projectId = projectId, userId = userId)
}
}
```
Expand Down Expand Up @@ -69,12 +104,14 @@ class MyEnhancerFactory(private val config: MyConfigClass): EnhancerFactory {
}

class MyResourceEnhancer: JerseyResourceEnhancer {
// only classes used directly by Jersey, cannot inject them in user code
override val classes: Array<Class<*>> = arrayOf(
Filters.logResponse,
Filters.cors,
Filters.cache,
)

// only classes used directly by Jersey, cannot inject them in user code
override val packages = arrayOf(
"com.example.app.resources",
)
Expand All @@ -83,7 +120,10 @@ class MyEnhancerFactory(private val config: MyConfigClass): EnhancerFactory {
bind(config)
.to(MyConfigClass::class.java)
bind(MyService::class.java)
.to(MyService::class.java)
.to(MyServiceInterface::class.java)
.`in`(Singleton::class.java)
bindFactory(OtherServiceFactory::class.java)
.to(OtherServiceInterface::class.java)
.`in`(Singleton::class.java)
}
}
Expand Down
Loading

0 comments on commit 76915cf

Please sign in to comment.