From b69be52c8588395ddefb3fa8226c73fe4da02b02 Mon Sep 17 00:00:00 2001 From: Nlkomaru Date: Mon, 20 May 2024 19:10:07 +0900 Subject: [PATCH] Add GitHub actions --- .github/workflows/check_pull_request.yml | 7 ++++- .github/workflows/deploy_docs.yml | 15 ++++++++++ .github/workflows/release.yml | 5 +++- .github/workflows/upload.yml | 8 +++--- api/build.gradle.kts | 28 +++++++++++++++++++ .../party/morino/mineauth/api/MineAuthAPI.kt | 7 +++++ .../morino/mineauth/api/RegisterHandler.kt | 7 +++++ .../morino/mineauth/api/annotations/Parms.kt | 6 ++++ build.gradle.kts | 5 +--- {mineauth-core => core}/build.gradle.kts | 9 ++++-- .../party/morino/mineauth/core/MineAuth.kt | 5 ++++ .../mineauth/core/commands/HelpCommand.kt | 0 .../mineauth/core/commands/RegisterCommand.kt | 0 .../mineauth/core/commands/ReloadCommand.kt | 0 .../mineauth/core/database/UserAuthData.kt | 0 .../mineauth/core/file/data/JWTConfigData.kt | 0 .../core/file/data/OAuthConfigData.kt | 0 .../core/file/data/WebServerConfigData.kt | 0 .../core/file/load/FileLoaderInterface.kt | 0 .../mineauth/core/file/load/FileUtils.kt | 0 .../file/load/config/AbstractConfigLoader.kt | 0 .../file/load/config/OAuthConfigLoader.kt | 0 .../core/file/load/config/WebConfigLoader.kt | 0 .../load/resources/AssetsResourceLoader.kt | 0 .../resources/TemplatePageResourceLoader.kt | 0 .../mineauth/core/file/utils/KeyUtils.kt | 0 .../morino/mineauth/core/utils/PlayerUtils.kt | 0 .../morino/mineauth/core/utils/Serializer.kt | 0 .../coroutines/AsyncCoroutineDispatcher.kt | 0 .../utils/coroutines/DispatcherContainer.kt | 0 .../MinecraftCoroutineDispatcher.kt | 0 .../coroutines/MinecraftCoroutineUtil.kt | 0 .../morino/mineauth/core/web/WebServer.kt | 18 +++++++++++- .../mineauth/core/web/data/AuthorizedData.kt | 0 .../mineauth/core/web/data/ClientData.kt | 0 .../mineauth/core/web/data/OIDCConfigData.kt | 0 .../mineauth/core/web/data/TokenData.kt | 0 .../core/web/router/auth/AuthRouter.kt | 0 .../core/web/router/auth/LoginRouter.kt | 0 .../core/web/router/auth/WellKnownRouter.kt | 0 .../web/router/auth/oauth/AuthorizeRouter.kt | 0 .../core/web/router/auth/oauth/OAuthRouter.kt | 0 .../web/router/auth/oauth/ProfileRouter.kt | 0 .../core/web/router/auth/oauth/TokenRouter.kt | 0 .../core/web/router/common/CommonRouter.kt | 0 .../core/web/router/common/ServerRouter.kt | 0 .../core/web/router/common/UserRouter.kt | 0 .../web/router/common/data/ProfileData.kt | 0 .../web/router/common/server/PlayersRouter.kt | 0 .../core/web/router/plugin/PluginRouter.kt | 8 +++--- .../web/router/plugin/vault/VaultRouter.kt | 13 +++++++++ .../src/main/resources/assets/lock.svg | 0 .../main/resources/openapi/documentation.yaml | 22 ++++++++++++++- .../src/main/resources/psw4j.properties | 0 .../src/main/resources/templates/authorize.vm | 0 docs/CNAME | 1 + docs/docs/assets/documentation.yaml | 16 +++++++++++ gradle.properties | 3 -- gradle/libs.versions.toml | 2 +- mineauth-api/build.gradle.kts | 17 ----------- .../party.morino.mineauth.api/MineAuthAPI.kt | 3 -- settings.gradle.kts | 8 +++--- 62 files changed, 166 insertions(+), 47 deletions(-) create mode 100644 api/build.gradle.kts create mode 100644 api/src/main/kotlin/party/morino/mineauth/api/MineAuthAPI.kt create mode 100644 api/src/main/kotlin/party/morino/mineauth/api/RegisterHandler.kt create mode 100644 api/src/main/kotlin/party/morino/mineauth/api/annotations/Parms.kt rename {mineauth-core => core}/build.gradle.kts (92%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/MineAuth.kt (91%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/commands/HelpCommand.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/commands/RegisterCommand.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/commands/ReloadCommand.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/database/UserAuthData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/data/JWTConfigData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/data/OAuthConfigData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/data/WebServerConfigData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/load/FileLoaderInterface.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/load/FileUtils.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/load/config/AbstractConfigLoader.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/load/config/OAuthConfigLoader.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/load/config/WebConfigLoader.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/load/resources/AssetsResourceLoader.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/load/resources/TemplatePageResourceLoader.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/file/utils/KeyUtils.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/utils/PlayerUtils.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/utils/Serializer.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/AsyncCoroutineDispatcher.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/DispatcherContainer.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineDispatcher.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineUtil.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/WebServer.kt (92%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/data/AuthorizedData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/data/ClientData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/data/OIDCConfigData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/data/TokenData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/auth/AuthRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/auth/LoginRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/auth/WellKnownRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/AuthorizeRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/OAuthRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/ProfileRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/TokenRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/common/CommonRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/common/ServerRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/common/UserRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/common/data/ProfileData.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/common/server/PlayersRouter.kt (100%) rename {mineauth-core => core}/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/PluginRouter.kt (57%) create mode 100644 core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/vault/VaultRouter.kt rename {mineauth-core => core}/src/main/resources/assets/lock.svg (100%) rename {mineauth-core => core}/src/main/resources/openapi/documentation.yaml (60%) rename {mineauth-core => core}/src/main/resources/psw4j.properties (100%) rename {mineauth-core => core}/src/main/resources/templates/authorize.vm (100%) create mode 100644 docs/CNAME delete mode 100644 mineauth-api/build.gradle.kts delete mode 100644 mineauth-api/src/main/kotlin/party.morino.mineauth.api/MineAuthAPI.kt diff --git a/.github/workflows/check_pull_request.yml b/.github/workflows/check_pull_request.yml index b2dda98..6f0c3fe 100644 --- a/.github/workflows/check_pull_request.yml +++ b/.github/workflows/check_pull_request.yml @@ -17,16 +17,21 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} status: pending context: Check pull request + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17' + java-version: '21' cache: 'gradle' + - name: Change wrapper permissions run: chmod +x ./gradlew + - name: Build with Gradle run: ./gradlew build -x test + - name: Set final commit status uses: myrotvorets/set-commit-status-action@master if: always() diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 8f788b8..27203b6 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -22,4 +22,19 @@ jobs: pip install mkdocs-static-i18n[material] pip install mkdocs-render-swagger-plugin - run: git pull + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '21' + cache: 'gradle' + + - name: Change wrapper permissions + run: chmod +x ./gradlew + + - name: Build with Gradle + run: ./gradlew :api:dokkaHtml + + - name: Copy dokkaHtml to docs + run: cp -r ./api/build/dokka/html ./docs/docs/dokka + - run: mkdocs gh-deploy --config-file ./docs/mkdocs.yml \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4beac2a..046eb25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,12 +21,15 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17' + java-version: '21' cache: 'gradle' - name: Change wrapper permissions run: chmod +x ./gradlew + - name: Build with Gradle + run: ./gradlew build -x test + - uses: release-drafter/release-drafter@v5 id: release-drafter with: diff --git a/.github/workflows/upload.yml b/.github/workflows/upload.yml index a4b4b14..61ee1a7 100644 --- a/.github/workflows/upload.yml +++ b/.github/workflows/upload.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17' + java-version: '21' cache: 'gradle' - name: Change wrapper permissions @@ -27,7 +27,7 @@ jobs: sed -i -e "s/minecraft_plugin_version/$after/i" './gradle.properties' - name: Build with Gradle - run: ./gradlew build -x test + run: ./gradlew :core:build -x test - name: Upload release uses: actions/upload-release-asset@v1 @@ -35,8 +35,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} - asset_path: ./mineauth-core/build/libs/MineAuth-${{ github.event.release.tag_name }}.jar - asset_name: MineAuth_${{ github.event.release.tag_name }}.jar + asset_path: ./core/build/libs/core-${{ github.event.release.tag_name }}.jar + asset_name: MineAuth-core_${{ github.event.release.tag_name }}.jar asset_content_type: application/jar diff --git a/api/build.gradle.kts b/api/build.gradle.kts new file mode 100644 index 0000000..abf1858 --- /dev/null +++ b/api/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + alias(libs.plugins.kotlin.jvm) +} + +dependencies { + compileOnly(libs.paper.api) + implementation(kotlin("stdlib-jdk8")) +} + +group = project.group +version = project.version.toString() + +kotlin { + jvmToolchain { + (this).languageVersion.set(JavaLanguageVersion.of(21)) + } + jvmToolchain(21) +} + +tasks { + compileKotlin { + kotlinOptions.jvmTarget = "21" + kotlinOptions.javaParameters = true + } +} +repositories { + mavenCentral() +} \ No newline at end of file diff --git a/api/src/main/kotlin/party/morino/mineauth/api/MineAuthAPI.kt b/api/src/main/kotlin/party/morino/mineauth/api/MineAuthAPI.kt new file mode 100644 index 0000000..42e6501 --- /dev/null +++ b/api/src/main/kotlin/party/morino/mineauth/api/MineAuthAPI.kt @@ -0,0 +1,7 @@ +package party.morino.mineauth.api + +import org.bukkit.plugin.java.JavaPlugin + +interface MineAuthAPI { + abstract fun createHandler(plugin : JavaPlugin): RegisterHandler +} \ No newline at end of file diff --git a/api/src/main/kotlin/party/morino/mineauth/api/RegisterHandler.kt b/api/src/main/kotlin/party/morino/mineauth/api/RegisterHandler.kt new file mode 100644 index 0000000..653334e --- /dev/null +++ b/api/src/main/kotlin/party/morino/mineauth/api/RegisterHandler.kt @@ -0,0 +1,7 @@ +package party.morino.mineauth.api + + +interface RegisterHandler { + fun register(vararg endpoints: Any): RegisterHandler + +} diff --git a/api/src/main/kotlin/party/morino/mineauth/api/annotations/Parms.kt b/api/src/main/kotlin/party/morino/mineauth/api/annotations/Parms.kt new file mode 100644 index 0000000..e38865d --- /dev/null +++ b/api/src/main/kotlin/party/morino/mineauth/api/annotations/Parms.kt @@ -0,0 +1,6 @@ +package party.morino.mineauth.api.annotations + +@Target(AnnotationTarget.VALUE_PARAMETER) +annotation class Parms( + val value: Array +) diff --git a/build.gradle.kts b/build.gradle.kts index b772d6d..82a6e16 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat plugins { java alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.dokka) } val projectVersion: String by project @@ -13,10 +14,6 @@ buildscript { repositories { mavenCentral() } - dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10") - classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.5.31") - } } subprojects { diff --git a/mineauth-core/build.gradle.kts b/core/build.gradle.kts similarity index 92% rename from mineauth-core/build.gradle.kts rename to core/build.gradle.kts index 64672f6..0f16fae 100644 --- a/mineauth-core/build.gradle.kts +++ b/core/build.gradle.kts @@ -18,11 +18,11 @@ repositories { maven("https://repo.codemc.io/repository/maven-public/") } -group = "party.morino" -version = "1.0-SNAPSHOT" +group = project.group +version = project.version.toString() dependencies { - implementation(project(":mineauth-api")) + implementation(project(":api")) compileOnly(libs.paper.api) implementation(libs.bundles.commands) @@ -39,12 +39,14 @@ dependencies { implementation(libs.bundles.exposed) implementation(libs.koin.core) + implementation(kotlin("stdlib-jdk8")) } kotlin { jvmToolchain { (this).languageVersion.set(JavaLanguageVersion.of(17)) } + jvmToolchain(17) } tasks { @@ -77,6 +79,7 @@ sourceSets.main { main = "$group.mineauth.core.MineAuth" apiVersion = "1.20" libraries = libs.bundles.coroutines.asString() + softDepend = listOf("Vault") } } } diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/MineAuth.kt b/core/src/main/kotlin/party/morino/mineauth/core/MineAuth.kt similarity index 91% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/MineAuth.kt rename to core/src/main/kotlin/party/morino/mineauth/core/MineAuth.kt index ca761f8..db2d696 100644 --- a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/MineAuth.kt +++ b/core/src/main/kotlin/party/morino/mineauth/core/MineAuth.kt @@ -2,9 +2,11 @@ package party.morino.mineauth.core import com.github.shynixn.mccoroutine.bukkit.SuspendingJavaPlugin import org.bukkit.Bukkit +import org.bukkit.plugin.java.JavaPlugin import org.koin.core.context.GlobalContext import org.koin.dsl.module import party.morino.mineauth.api.MineAuthAPI +import party.morino.mineauth.api.RegisterHandler import party.morino.mineauth.core.commands.HelpCommand import party.morino.mineauth.core.commands.RegisterCommand import party.morino.mineauth.core.commands.ReloadCommand @@ -66,5 +68,8 @@ open class MineAuth: SuspendingJavaPlugin() , MineAuthAPI { } } + override fun createHandler(plugin: JavaPlugin): RegisterHandler { + TODO("Not yet implemented") + } } \ No newline at end of file diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/commands/HelpCommand.kt b/core/src/main/kotlin/party/morino/mineauth/core/commands/HelpCommand.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/commands/HelpCommand.kt rename to core/src/main/kotlin/party/morino/mineauth/core/commands/HelpCommand.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/commands/RegisterCommand.kt b/core/src/main/kotlin/party/morino/mineauth/core/commands/RegisterCommand.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/commands/RegisterCommand.kt rename to core/src/main/kotlin/party/morino/mineauth/core/commands/RegisterCommand.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/commands/ReloadCommand.kt b/core/src/main/kotlin/party/morino/mineauth/core/commands/ReloadCommand.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/commands/ReloadCommand.kt rename to core/src/main/kotlin/party/morino/mineauth/core/commands/ReloadCommand.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/database/UserAuthData.kt b/core/src/main/kotlin/party/morino/mineauth/core/database/UserAuthData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/database/UserAuthData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/database/UserAuthData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/data/JWTConfigData.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/data/JWTConfigData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/data/JWTConfigData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/data/JWTConfigData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/data/OAuthConfigData.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/data/OAuthConfigData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/data/OAuthConfigData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/data/OAuthConfigData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/data/WebServerConfigData.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/data/WebServerConfigData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/data/WebServerConfigData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/data/WebServerConfigData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/FileLoaderInterface.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/load/FileLoaderInterface.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/FileLoaderInterface.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/load/FileLoaderInterface.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/FileUtils.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/load/FileUtils.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/FileUtils.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/load/FileUtils.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/config/AbstractConfigLoader.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/load/config/AbstractConfigLoader.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/config/AbstractConfigLoader.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/load/config/AbstractConfigLoader.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/config/OAuthConfigLoader.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/load/config/OAuthConfigLoader.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/config/OAuthConfigLoader.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/load/config/OAuthConfigLoader.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/config/WebConfigLoader.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/load/config/WebConfigLoader.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/config/WebConfigLoader.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/load/config/WebConfigLoader.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/resources/AssetsResourceLoader.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/load/resources/AssetsResourceLoader.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/resources/AssetsResourceLoader.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/load/resources/AssetsResourceLoader.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/resources/TemplatePageResourceLoader.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/load/resources/TemplatePageResourceLoader.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/load/resources/TemplatePageResourceLoader.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/load/resources/TemplatePageResourceLoader.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/utils/KeyUtils.kt b/core/src/main/kotlin/party/morino/mineauth/core/file/utils/KeyUtils.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/file/utils/KeyUtils.kt rename to core/src/main/kotlin/party/morino/mineauth/core/file/utils/KeyUtils.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/PlayerUtils.kt b/core/src/main/kotlin/party/morino/mineauth/core/utils/PlayerUtils.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/PlayerUtils.kt rename to core/src/main/kotlin/party/morino/mineauth/core/utils/PlayerUtils.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/Serializer.kt b/core/src/main/kotlin/party/morino/mineauth/core/utils/Serializer.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/Serializer.kt rename to core/src/main/kotlin/party/morino/mineauth/core/utils/Serializer.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/AsyncCoroutineDispatcher.kt b/core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/AsyncCoroutineDispatcher.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/AsyncCoroutineDispatcher.kt rename to core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/AsyncCoroutineDispatcher.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/DispatcherContainer.kt b/core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/DispatcherContainer.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/DispatcherContainer.kt rename to core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/DispatcherContainer.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineDispatcher.kt b/core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineDispatcher.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineDispatcher.kt rename to core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineDispatcher.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineUtil.kt b/core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineUtil.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineUtil.kt rename to core/src/main/kotlin/party/morino/mineauth/core/utils/coroutines/MinecraftCoroutineUtil.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/WebServer.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/WebServer.kt similarity index 92% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/WebServer.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/WebServer.kt index cf80eb4..aa9ff15 100644 --- a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/WebServer.kt +++ b/core/src/main/kotlin/party/morino/mineauth/core/web/WebServer.kt @@ -69,7 +69,6 @@ object WebServer: KoinComponent { private fun Application.module() { val plugin: MineAuth by inject(MineAuth::class.java) - val webServerConfigData: WebServerConfigData = get(WebServerConfigData::class.java) val jwtConfigData: JWTConfigData = get(JWTConfigData::class.java) install(ContentNegotiation) { json() @@ -110,6 +109,14 @@ private fun Application.module() { call.respondText("Hello World!") } } + route("/list") { + get { + val list = getRoutes(this@routing).map { it.toString() } + call.respond( + list + ) + } + } staticFiles("assets", plugin.dataFolder.resolve("assets")) authRouter() @@ -134,3 +141,12 @@ private fun Application.module() { } // openAPI(path = "openapi", swaggerFile = "openapi/documentation.yaml") {} } } + +private fun getRoutes(route: Route): List { + val list = mutableListOf() + route.children.forEach { + list.addAll(getRoutes(it)) + } + list.add(route) + return list +} diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/data/AuthorizedData.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/data/AuthorizedData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/data/AuthorizedData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/data/AuthorizedData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/data/ClientData.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/data/ClientData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/data/ClientData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/data/ClientData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/data/OIDCConfigData.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/data/OIDCConfigData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/data/OIDCConfigData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/data/OIDCConfigData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/data/TokenData.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/data/TokenData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/data/TokenData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/data/TokenData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/AuthRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/AuthRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/AuthRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/AuthRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/LoginRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/LoginRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/LoginRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/LoginRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/WellKnownRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/WellKnownRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/WellKnownRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/WellKnownRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/AuthorizeRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/AuthorizeRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/AuthorizeRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/AuthorizeRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/OAuthRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/OAuthRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/OAuthRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/OAuthRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/ProfileRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/ProfileRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/ProfileRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/ProfileRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/TokenRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/TokenRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/TokenRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/auth/oauth/TokenRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/CommonRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/common/CommonRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/CommonRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/common/CommonRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/ServerRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/common/ServerRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/ServerRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/common/ServerRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/UserRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/common/UserRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/UserRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/common/UserRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/data/ProfileData.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/common/data/ProfileData.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/data/ProfileData.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/common/data/ProfileData.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/server/PlayersRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/common/server/PlayersRouter.kt similarity index 100% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/common/server/PlayersRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/common/server/PlayersRouter.kt diff --git a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/PluginRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/PluginRouter.kt similarity index 57% rename from mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/PluginRouter.kt rename to core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/PluginRouter.kt index e84d758..9f98b39 100644 --- a/mineauth-core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/PluginRouter.kt +++ b/core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/PluginRouter.kt @@ -3,13 +3,13 @@ package party.morino.mineauth.core.web.router.plugin import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* +import party.morino.mineauth.core.web.router.plugin.vault.VaultRouter.vaultRouter object PluginRouter { fun Route.pluginRouter() { - route("/plugin") { - get { - call.respondText("Hello, plugin!") - } + get { + call.respondText("Hello, plugin!") } + vaultRouter() } } \ No newline at end of file diff --git a/core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/vault/VaultRouter.kt b/core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/vault/VaultRouter.kt new file mode 100644 index 0000000..b09d43a --- /dev/null +++ b/core/src/main/kotlin/party/morino/mineauth/core/web/router/plugin/vault/VaultRouter.kt @@ -0,0 +1,13 @@ +package party.morino.mineauth.core.web.router.plugin.vault + +import io.ktor.server.routing.* + +object VaultRouter { + fun Route.vaultRouter() { + route("/vault") { + get { + this@route + } + } + } +} \ No newline at end of file diff --git a/mineauth-core/src/main/resources/assets/lock.svg b/core/src/main/resources/assets/lock.svg similarity index 100% rename from mineauth-core/src/main/resources/assets/lock.svg rename to core/src/main/resources/assets/lock.svg diff --git a/mineauth-core/src/main/resources/openapi/documentation.yaml b/core/src/main/resources/openapi/documentation.yaml similarity index 60% rename from mineauth-core/src/main/resources/openapi/documentation.yaml rename to core/src/main/resources/openapi/documentation.yaml index f224de2..32ad8dd 100644 --- a/mineauth-core/src/main/resources/openapi/documentation.yaml +++ b/core/src/main/resources/openapi/documentation.yaml @@ -31,8 +31,28 @@ security: - oauth2: [ read.*, write.* ] paths: - /oauth2/userinfo: + - /oauth2/userinfo: get: summary: Get user information security: - oauth2: [ read ] + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + id: + type: string + description: The user UUID + username: + type: string + description: The user name + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Not Found diff --git a/mineauth-core/src/main/resources/psw4j.properties b/core/src/main/resources/psw4j.properties similarity index 100% rename from mineauth-core/src/main/resources/psw4j.properties rename to core/src/main/resources/psw4j.properties diff --git a/mineauth-core/src/main/resources/templates/authorize.vm b/core/src/main/resources/templates/authorize.vm similarity index 100% rename from mineauth-core/src/main/resources/templates/authorize.vm rename to core/src/main/resources/templates/authorize.vm diff --git a/docs/CNAME b/docs/CNAME new file mode 100644 index 0000000..5fedaa0 --- /dev/null +++ b/docs/CNAME @@ -0,0 +1 @@ +mineauth-docs.morino.party \ No newline at end of file diff --git a/docs/docs/assets/documentation.yaml b/docs/docs/assets/documentation.yaml index e6846dc..0127655 100644 --- a/docs/docs/assets/documentation.yaml +++ b/docs/docs/assets/documentation.yaml @@ -37,6 +37,22 @@ paths: summary: Get user information security: - oauth2: [ profile ] + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + id: + type: string + example: "069a79f4-44e9-4726-a5be-fca90e38aaf5" + description: The user UUID + username: + type: string + example: "Notch" + description: The user name /oauth2/revoke: post: summary: Revoke access token diff --git a/gradle.properties b/gradle.properties index 1d5faef..778b4ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,5 @@ xyz.jpenilla.run-paper.updateCheckFrequency=12h projectVersion=1.0-SNAPSHOT - -sourceCompatibility = 17 -targetCompatibility = 17 # Gradle Properties org.gradle.caching=true org.gradle.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index de0bf1f..99c824a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -48,7 +48,7 @@ koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koinV run-paper = { id = "xyz.jpenilla.run-paper", version = "2.2.3" } resource-factory = { id = "xyz.jpenilla.resource-factory", version = "1.1.1" } shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" } -kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "1.9.23" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "1.9.24" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version = "1.9.23" } dokka = { id = "org.jetbrains.dokka", version = "1.9.20" } diff --git a/mineauth-api/build.gradle.kts b/mineauth-api/build.gradle.kts deleted file mode 100644 index 38a0a54..0000000 --- a/mineauth-api/build.gradle.kts +++ /dev/null @@ -1,17 +0,0 @@ -dependencies {} - -kotlin { - jvmToolchain { - (this).languageVersion.set(JavaLanguageVersion.of(17)) - } -} - -tasks { - compileKotlin { - kotlinOptions.jvmTarget = "17" - kotlinOptions.javaParameters = true - } - compileTestKotlin { - kotlinOptions.jvmTarget = "17" - } -} \ No newline at end of file diff --git a/mineauth-api/src/main/kotlin/party.morino.mineauth.api/MineAuthAPI.kt b/mineauth-api/src/main/kotlin/party.morino.mineauth.api/MineAuthAPI.kt deleted file mode 100644 index 4c9c06e..0000000 --- a/mineauth-api/src/main/kotlin/party.morino.mineauth.api/MineAuthAPI.kt +++ /dev/null @@ -1,3 +0,0 @@ -package party.morino.mineauth.api - -interface MineAuthAPI {} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index db64491..62ebeb1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,15 +1,15 @@ rootProject.name = "MineAuth" -include("mineauth-core", "mineauth-sample", "mineauth-api") pluginManagement { repositories { gradlePluginPortal() + mavenCentral() maven("https://papermc.io/repo/repository/maven-public/") } - plugins { - kotlin("jvm") version "1.9.23" - } } plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" } + +include("core") +include("api")