Skip to content

Commit

Permalink
chore: upgrade and clean up (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikAoJk authored Aug 28, 2024
1 parent 741dacd commit c73f558
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 61 deletions.
1 change: 1 addition & 0 deletions .nais/naiserator-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spec:
databases:
- name: padm2-db
diskAutoresize: true
tier: db-f1-micro
accessPolicy:
inbound:
rules:
Expand Down
1 change: 1 addition & 0 deletions .nais/naiserator-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spec:
databases:
- name: padm2-db
diskAutoresize: true
tier: db-custom-1-3840
accessPolicy:
inbound:
rules:
Expand Down
48 changes: 10 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,19 @@ at behandleren som har sendt meldingen er suspendert: https://navno.sharepoint.c
* Kotlin
* Ktor
* Gradle
* JDK 17
* JDK 21
* Spek
* Jackson
* Kafka

#### Requirements

* JDK 17
* JDK 21

### Getting github-package-registry packages NAV-IT
Some packages used in this repo is uploaded to the Github Package Registry which requires authentication. It can, for example, be solved like this in Gradle:
```
val githubUser: String by project
val githubPassword: String by project
repositories {
maven {
credentials {
username = githubUser
password = githubPassword
}
setUrl("https://maven.pkg.github.com/navikt/padm-common")
}
}
```

`githubUser` and `githubPassword` can be put into a separate file `~/.gradle/gradle.properties` with the following content:

```
githubUser=x-access-token
githubPassword=[token]
```

Replace `[token]` with a personal access token with scope `read:packages`.

Alternatively, the variables can be configured via environment variables:

* `ORG_GRADLE_PROJECT_githubUser`
* `ORG_GRADLE_PROJECT_githubPassword`

or the command line:

```
./gradlew -PgithubUser=x-access-token -PgithubPassword=[token]
```

### Access to the Postgres database

For utfyllende dokumentasjon se [Postgres i NAV](https://doc.nais.io/persistence/postgres/)
For additional documentation see [Postgres i NAV](https://doc.nais.io/persistence/postgres/)

### Kafka

Expand Down Expand Up @@ -113,6 +78,13 @@ Creating a docker image should be as simple as `docker build -t padm2 .`
#### Running a docker image
`docker run --rm -it -p 8080:8080 padm2`

### Upgrading the gradle wrapper
Find the newest version of gradle here: https://gradle.org/releases/ Then run this command:

``` bash
./gradlew wrapper --gradle-version $gradleVersjon
```

## Contact

### For NAV employees
Expand Down
32 changes: 13 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.apache.tools.ant.taskdefs.condition.Os

group = "no.nav.syfo"
Expand Down Expand Up @@ -35,27 +34,21 @@ val postgresEmbedded = if (Os.isFamily(Os.FAMILY_MAC)) "1.0.0" else "0.13.4"
val postgresVersion = "42.7.2"
val scala = "2.13.9"
val spek = "2.0.19"
val commonsCompressVersion = "1.27.0"

plugins {
java
kotlin("jvm") version "2.0.10"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.gradleup.shadow") version "8.3.0"
id("org.jlleitschuh.gradle.ktlint") version "11.4.2"
}

val githubUser: String by project
val githubPassword: String by project

repositories {
mavenCentral()
maven(url = "https://packages.confluent.io/maven/")
maven(url = "https://jitpack.io")
maven {
url = uri("https://maven.pkg.github.com/navikt/syfo-xml-codegen")
credentials {
username = githubUser
password = githubPassword
}
url = uri("https://github-package-registry-mirror.gc.nav.no/cached/maven-release")
}
}

Expand Down Expand Up @@ -135,6 +128,11 @@ dependencies {
testImplementation("io.mockk:mockk:$mockkVersion")
testImplementation("io.ktor:ktor-client-mock:$ktorVersion")
testImplementation("com.opentable.components:otj-pg-embedded:$postgresEmbedded")
constraints {
testImplementation("org.apache.commons:commons-compress:$commonsCompressVersion") {
because("overrides vulnerable dependency from com.opentable.components:otj-pg-embedded")
}
}
testImplementation("io.ktor:ktor-server-test-host:$ktorVersion")
testImplementation("org.spekframework.spek2:spek-dsl-jvm:$spek") {
exclude(group = "org.jetbrains.kotlin")
Expand All @@ -150,28 +148,24 @@ kotlin {
}

tasks {
withType<Jar> {
manifest.attributes["Main-Class"] = "no.nav.syfo.BootstrapKt"
}

create("printVersion") {
doLast {
println(project.version)
}
jar {
manifest.attributes["Main-Class"] = "no.nav.syfo.BootstrapKt"
}

withType<ShadowJar> {
shadowJar {
archiveBaseName.set("app")
archiveClassifier.set("")
archiveVersion.set("")
}

withType<Test> {
test {
useJUnitPlatform {
includeEngines("spek2", "junit-vintage")
}
testLogging {
showStandardStreams = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
kotlin.code.style=official
kotlin.code.style=official
kotlin.daemon.jvmargs=-Xmx1024m
1 change: 1 addition & 0 deletions src/main/kotlin/no/nav/syfo/application/BackgroundTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory

private val log: Logger = LoggerFactory.getLogger("no.nav.syfo.application")

@OptIn(DelicateCoroutinesApi::class)
fun launchBackgroundTask(
applicationState: ApplicationState,
action: suspend CoroutineScope.() -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import io.ktor.server.auth.jwt.*
import net.logstash.logback.argument.StructuredArguments
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.net.URL
import java.net.URI
import java.time.Duration
import java.util.concurrent.TimeUnit

private val log: Logger = LoggerFactory.getLogger("no.nav.syfo.application.api.authentication")
Expand All @@ -27,8 +28,8 @@ fun Application.installJwtAuthentication(
fun AuthenticationConfig.configureJwt(
jwtIssuer: JwtIssuer,
) {
val jwkProvider = JwkProviderBuilder(URL(jwtIssuer.wellKnown.jwksUri))
.cached(10, 24, TimeUnit.HOURS)
val jwkProvider = JwkProviderBuilder(URI.create(jwtIssuer.wellKnown.jwksUri).toURL())
.cached(10, Duration.ofHours(24))
.rateLimited(10, 1, TimeUnit.MINUTES)
.build()
jwt(name = jwtIssuer.jwtIssuerType.name) {
Expand Down

0 comments on commit c73f558

Please sign in to comment.