diff --git a/.editorconfig b/.editorconfig index 96b4507..c2db456 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,6 +17,10 @@ tab_width = 2 [*.bat] end_of_line = crlf +[*.{cer,pem}] +max_line_length = 64 +insert_final_newline = false + # noinspection EditorConfigKeyCorrectness [*.{kt,kts}] ij_kotlin_packages_to_use_import_on_demand = unset diff --git a/.gitignore b/.gitignore index 5a979af..004b1eb 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ out/ ### Kotlin ### .kotlin + +#### Hlæja ### +/cert/ diff --git a/README.md b/README.md index bb5a164..269ddd0 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ In realms of connectedness, where devices roam free, A nexus of management, harm | name | required | info | |------------------------|:--------:|-------------------------| | spring.profiles.active | ✓ | Spring Boot environment | +| jwt.public-key | ✓ | JWT public key file | *Required: ✓ can be stored as text, and ✗ need to be stored as secret.* @@ -16,6 +17,12 @@ Run `release.sh` script from `master` branch. ## Development Information +### Public RSA Key + +This service uses the public key from **[Hlæja Account Register](https://github.com/swordsteel/hlaeja-account-registry)** to identify users. To set up user identification for local development, copy the `public_key.pem` file from the `./cert` directory in **Hlæja Account Register** into the `./cert` directory of this project. + +*Note: For more information on generating RSA keys, please refer to our [generate RSA key](https://github.com/swordsteel/hlaeja-development/blob/master/doc/rsa_key.md) documentation.* + ### Global Setting The following global settings are used in Hlaeja Device Registry. You can configure these settings using either Gradle properties or alternatively environment variables. diff --git a/build.gradle.kts b/build.gradle.kts index 9165ecf..a4fcda2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { alias(hlaeja.plugins.kotlin.jvm) alias(hlaeja.plugins.kotlin.spring) + alias(hlaeja.plugins.ltd.hlaeja.plugin.certificate) alias(hlaeja.plugins.ltd.hlaeja.plugin.service) alias(hlaeja.plugins.spring.dependency.management) alias(hlaeja.plugins.springframework.boot) @@ -8,9 +9,11 @@ plugins { dependencies { implementation(hlaeja.fasterxml.jackson.module.kotlin) + implementation(hlaeja.jjwt.api) implementation(hlaeja.kotlin.logging) implementation(hlaeja.kotlin.reflect) implementation(hlaeja.kotlinx.coroutines) + implementation(hlaeja.library.hlaeja.jwt) implementation(hlaeja.projectreactor.kotlin.reactor.extensions) implementation(hlaeja.springboot.starter.actuator) implementation(hlaeja.springboot.starter.security) @@ -28,3 +31,9 @@ dependencies { } group = "ltd.lulz" + +tasks { + named("processResources") { + dependsOn("copyCertificates") + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 682eba1..b593733 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -23,6 +23,9 @@ management: info: enabled: true +jwt: + public-key: cert/public_key.pem + --- ############################### ### Development environment ### diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 0000000..ba1905e --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,2 @@ +jwt: + public-key: cert/valid-public-key.pem diff --git a/src/test/resources/cert/valid-public-key.pem b/src/test/resources/cert/valid-public-key.pem new file mode 100644 index 0000000..cdb4982 --- /dev/null +++ b/src/test/resources/cert/valid-public-key.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3ZdlbISX729m5Ur1pVhg +XIvazcgUt0T0G32ML0tfwQ4aWTfwPII0SQRThaN6eiiBMRa0V8JMih1LT8JmGgst +dEx2nhMbVs/Osu8MhmP86c+HB/jPa1+0IR1TZKXoZoF52D2ZtoVf+mOWggAcm1R+ +V0Fj2cR/pgLkVt3GKUE2OokFC1iFUQFjThd1EzKcOv53TUek8FY8t66npQ4t3unD +bXZKoGXMuXCqZVykMbGTUQFRuT3NAOXRrJP+UDeY2uM2Yk98J+8FtLDYD6jpmyi0 +ghv6k8pK1w1n5NI3atVv5ZMUeQZ36AXL8SZi1105mamhLVQ0e0JixoMOPh7ziFyv +uwIDAQAB +-----END PUBLIC KEY-----