Skip to content
Merged
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ You can use the current version and give us a feedback about what needs to be ch
## 👥 Contributors

urhatedjack - logo design
[KotreQ](https://github.com/KotreQ) - help with the QR code generation

Thanks to **Discord support team**:
- [Blavez](https://github.com/Blavezz)
Expand Down Expand Up @@ -67,7 +68,7 @@ NavAuth is licensed under the GNU AGPL v3. See the license file for more informa
[![GNU AGPL Logo](https://www.gnu.org/graphics/agplv3-155x51.png)](https://www.gnu.org/licenses/agpl-3.0.en.html)

## 💡 TODO List
More planned features are described in [Documentation](https://navio1430.github.io/NavAuth/offer.html#%F0%9F%9A%80-planned-features)
More planned features are described in [Documentation](https://navio1430.github.io/NavAuth/docs/offer.html#%F0%9F%9A%80-planned-features)
- readme:
- add banner
- github/gh actions:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {

allprojects {
group = "pl.spcode.navauth"
version = "0.1.3-SNAPSHOT"
version = "0.1.4-SNAPSHOT"
}

tasks.register("formatAll") {
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ features:
- icon: ⚡
title: Setup & Run the plugin
details: Go through the detailed description about how to configure and run NavAuth.
link: /setup # todo
link: /setup
- icon: 🚀
title: Migrate now
details: Check how to migrate from other plugins like LibreLogin, AuthMe and FastLogin.
link: /migration/migration
- icon: 🧩
title: Requirements
details: Check the requirements needed to run NavAuth.
link: /requirements # todo
link: /requirements
- icon:
src: https://pngimg.com/d/discord_PNG3.png
title: Need support?
Expand Down
3 changes: 1 addition & 2 deletions docs/docs/navauth-release.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# NavAuth Release

First release of NavAuth is still under development.
Please join our discord server to be notified about version 1.0
NavAuth version 1.0 is still under development. As of now you can use versions **0.X** and give us your feedback on our **Discord** server.
13 changes: 13 additions & 0 deletions docs/docs/requirements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Requirements

## What is required to run NavAuth?
- Velocity (preferably the newest versions)
- Limbo server e.g., NanoLimbo, PicoLimbo
- You can use [PicoLimbo velocity plugin](https://modrinth.com/plugin/picolimbo-java-wrapper) for simplicity.
::: danger
DO NOT USE NORMAL PAPER/LOBBY SERVER AS LIMBO. IT CAN CAUSE A MAJOR SECURITY ISSUE.
:::

## Modern forwarding is required
Please set **Velocity** forwarding to `MODERN`.
All backend servers must support `MODERN` forward too (**1.13.1+ only**).
6 changes: 6 additions & 0 deletions docs/docs/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Setup

Detailed setup tutorial is still under construction.
Follow [Requirements page](/requirements) for requirements details.
If you have basic knowledge of how **Velocity** proxy works, then it shouldn't
be a problem for you to figure it out how to make things work.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ open class AuthSessionService<P : PlayerAdapter> {
fun closeSession(uniqueSessionId: UniqueSessionId): Boolean {
val session = sessionsMap.remove(uniqueSessionId)
if (session != null) {
if (session.playerAdapter.isOnline()) {
session.playerAdapter.disconnect(DisconnectReason.AUTH_SESSION_CLOSED)
}
session.playerAdapter.disconnect(DisconnectReason.AUTH_SESSION_CLOSED)
session.onInvalidate()
logger.debug(
"invalidated auth session (type='{}') with ID {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import pl.spcode.navauth.common.component.TextComponent
open class MessagesConfig : OkaeriConfig() {

var supportFooter =
TextComponent("<br><br><gray>For support please join our discord: https://dc.spcode.pl/")
TextComponent("<br><br><gray>For support please join our discord: https://dc.yourwebsite.net/")

var invalidUsernameError = TextComponent("<red>Invalid username.")

var usernameRequiredError =
TextComponent(
Expand All @@ -59,21 +61,50 @@ open class MessagesConfig : OkaeriConfig() {
var registerTimeExceededError =
TextComponent("<red>You've exceeded register time, please try again</red>")

var loginTooManyAttemptsError =
TextComponent("<red>Too many login attempts. Please try again later.")

var adminCopyPasswordText =
"<aqua><bold><click:copy_to_clipboard:%PASSWORD%>CLICK HERE TO COPY</click>"

var yourAccountDataHasBeenMigrated =
TextComponent("<green>Your account data has been migrated to '%USERNAME%'.")

@Comment(
"Notifications which use multification library.",
"Here you can use chat messages, action bars, sounds etc. combined.",
"To learn more about multification please read https://navio1430.github.io/NavAuth/configuration/multification.html",
"To learn more about multification please read https://navio1430.github.io/NavAuth/docs/configuration/multification.html",
)
var multification = NoticesConfig()

class NoticesConfig : OkaeriConfig() {

var passwordRequiredError: Notice = Notice.chat("<red>Please provide your current password.")
var twoFactorAlreadyEnabledError: Notice =
Notice.chat("<red>Your account has 2FA enabled already!")

var missingPermissionError: Notice =
Notice.chat("<red>You don't have permission to execute this command.")
var invalidUsageError: Notice = Notice.chat("<red>Invalid command usage!")
@Comment("Invalid usage scheme line (single text component only).")
var invalidUsageLine: TextComponent = TextComponent("<gray> • %SCHEME%")

var cantUseThisCommandNowError: Notice = Notice.chat("<red>Can't use this command right now.")
var commandPasswordNotSetForAccountError: Notice =
Notice.chat("<red>Can't execute this command right now: your account has no password set.")
var commandNoPremiumAccountWithUsername: Notice =
Notice.chat(
"<red>Can't set this account as premium because there's no premium account with username '%USERNAME%'."
)
var accountAlreadyPremiumError: Notice =
Notice.chat("<red>Account is already set as a premium one.")

var registerPasswordInvalidError: Notice =
Notice.chat(
"<red>The password is invalid. It must be at least 5 characters long and contain at least one uppercase letter and one digit."
)
var registerPasswordsMustMatchError: Notice = Notice.chat("<red>Both passwords must match.")

var loginPasswordOnlyInstruction: Notice =
Notice.chat("<green>Please login using \"/login <password>\" command.</green>")
var loginTwoFactorOnlyInstruction: Notice =
Expand All @@ -86,11 +117,26 @@ open class MessagesConfig : OkaeriConfig() {

var loginSuccess: Notice =
Notice.chat("<green>You have been authenticated successfully.</green>")

var registerSuccess: Notice = Notice.chat("<green>Successfully registered</green>")

var premiumAuthSuccess: Notice = Notice.chat("<green>Auto-logged in</green>")

var accountMigrationSuccess: Notice = Notice.chat("<green>Account migrated successfully!")
var newPasswordSetSuccess: Notice = Notice.chat("<green>Success! New password set.")

var wrongCredentialsError: Notice = Notice.chat("<red>Wrong credentials provided!")

var twoFactorDisabledSuccess: Notice = Notice.chat("<green>2FA is now disabled!")
var twoFactorEnabledSuccess: Notice = Notice.chat("<green>2FA is now enabled!")
var twoFactorCodeRequiredError: Notice =
Notice.chat("<red>Please provide two-factor authentication code.")
var twoFactorSessionNotFound: Notice =
Notice.chat(
"<red>2FA setup session not found. Please try again using /setup2fa command first."
)
var twoFactorWrongCodeError: Notice = Notice.chat("<red>Wrong 2FA code!")
var twoFactorAlreadyDisabledError: Notice =
Notice.chat("<red>Your account has 2FA disabled already.")

var twoFactorSetupInstruction: Notice =
Notice.chat(
"""
Expand All @@ -112,6 +158,39 @@ open class MessagesConfig : OkaeriConfig() {
"""
.trimIndent()
)

var adminCmdUsernameIsInvalid: Notice =
Notice.chat("<red>Provided username '%USERNAME%' is invalid.")
var adminCmdAccountIsPremiumError: Notice =
Notice.chat("<red>Can't execute the command! Account '%USERNAME%' is set to premium mode.")
var adminCmdAccountIsAlreadyNonPremiumError: Notice =
Notice.chat("<red>Account '%USERNAME%' is already a non-premium account.")
var adminCmdUseForceCrackedFirst: Notice = Notice.chat("<red>Use /forcecracked command first.")
var adminCmdCantMigrateToExistingPremiumAccount: Notice =
Notice.chat(
"<red>Provided username '%USERNAME%' is found as Mojang premium profile. Can't migrate to premium account."
)
var adminCmdUsernameAlreadyTakenError: Notice =
Notice.chat(
"<red>Username '%USERNAME%' is already taken. Please try again with a different username."
)
var adminCmdUsernameNotPremiumError: Notice =
Notice.chat(
"<red>Can't find '%USERNAME%' user in Mojang database. This player can't be migrated to premium mode."
)

var adminCmdPasswordSetSuccess: Notice =
Notice.chat("<green>Success! User '%USERNAME%' password was set.")
var adminCmdAccountMigratedToNonPremiumSuccess: Notice =
Notice.chat(
"<green>User '%USERNAME%' has been successfully migrated to non-premium mode. Their new password is: %PASSWORD_TEXT%"
)
var adminCmdUserDataMigratedSuccess: Notice =
Notice.chat(
"<green>Success! User '%OLD_USERNAME%' data has been migrated to '%NEW_USERNAME%'."
)
var adminCmdUserPremiumMigrationSuccess: Notice =
Notice.chat("<green>User '%USERNAME%' successfully migrated to premium mode.")
}

@Variable("CONFIG_VERSION")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import pl.spcode.navauth.common.migrate.MigrationOriginPluginType
@Header(
"Database migration config",
"This file contains database migration settings.",
"Check https://navio1430.github.io/NavAuth/migration/migration.html for more information",
"Check https://navio1430.github.io/NavAuth/docs/migration/migration.html for more information",
)
class MigrationConfig : OkaeriConfig() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ open class LoginAuthSession<T : PlayerAdapter>(

override fun onInvalidate() {}

open fun onTooManyLoginAttempts() {
playerAdapter.disconnect(DisconnectReason.TOO_MANY_LOGIN_ATTEMPTS)
}

/**
* Authenticates a user using a combination of password and two-factor authentication code if
* required.
Expand All @@ -58,7 +62,7 @@ open class LoginAuthSession<T : PlayerAdapter>(
if (!result) {
attemptsLeft -= 1
if (attemptsLeft <= 0) {
playerAdapter.disconnect(DisconnectReason.TOO_MANY_LOGIN_ATTEMPTS)
onTooManyLoginAttempts()
}
}
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package pl.spcode.navauth.common.shared.data
package pl.spcode.navauth.common.infra.persistence.ormlite

import com.j256.ormlite.dao.Dao

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package pl.spcode.navauth.common.shared.data
package pl.spcode.navauth.common.infra.persistence.ormlite

import com.j256.ormlite.dao.Dao
import com.j256.ormlite.stmt.DeleteBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import pl.spcode.navauth.common.domain.user.User
import pl.spcode.navauth.common.infra.database.DatabaseManager
import pl.spcode.navauth.common.infra.persistence.mapper.toDomain
import pl.spcode.navauth.common.infra.persistence.mapper.toRecord
import pl.spcode.navauth.common.shared.data.OrmLiteCrudRepositoryImpl
import pl.spcode.navauth.common.infra.persistence.ormlite.OrmLiteCrudRepositoryImpl

class UserCredentialsRepositoryImpl @Inject constructor(databaseManager: DatabaseManager) :
OrmLiteCrudRepositoryImpl<UserCredentialsRecord, UUID>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import pl.spcode.navauth.common.infra.database.DatabaseManager
import pl.spcode.navauth.common.infra.persistence.Paginator
import pl.spcode.navauth.common.infra.persistence.mapper.toDomain
import pl.spcode.navauth.common.infra.persistence.mapper.toRecord
import pl.spcode.navauth.common.shared.data.OrmLiteCrudRepositoryImpl
import pl.spcode.navauth.common.infra.persistence.ormlite.OrmLiteCrudRepositoryImpl

class UserActivitySessionRepositoryImpl @Inject constructor(databaseManager: DatabaseManager) :
OrmLiteCrudRepositoryImpl<UserActivitySessionRecord, UUID>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import pl.spcode.navauth.common.domain.user.UserUuid
import pl.spcode.navauth.common.infra.database.DatabaseManager
import pl.spcode.navauth.common.infra.persistence.mapper.toDomain
import pl.spcode.navauth.common.infra.persistence.mapper.toRecord
import pl.spcode.navauth.common.shared.data.OrmLiteCrudRepositoryImpl
import pl.spcode.navauth.common.infra.persistence.ormlite.OrmLiteCrudRepositoryImpl

class UserRepositoryImpl @Inject constructor(databaseManager: DatabaseManager) :
OrmLiteCrudRepositoryImpl<UserRecord, UUID>(databaseManager, UserRecord::class), UserRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ import dev.rollczi.litecommands.annotations.command.Command
import dev.rollczi.litecommands.annotations.context.Context
import dev.rollczi.litecommands.annotations.execute.Execute
import dev.rollczi.litecommands.annotations.permission.Permission
import net.kyori.adventure.text.Component
import pl.spcode.navauth.common.annotation.Description
import pl.spcode.navauth.common.application.credentials.UserCredentialsService
import pl.spcode.navauth.common.application.user.UserService
import pl.spcode.navauth.common.command.user.UserArgumentResolver
import pl.spcode.navauth.common.command.user.UsernameOrUuidRaw
import pl.spcode.navauth.common.component.TextColors
import pl.spcode.navauth.velocity.command.Permissions
import pl.spcode.navauth.velocity.multification.VelocityMultification

@Command(name = "forcesetpassword")
@Permission(Permissions.ADMIN_FORCE_SET_PASSWORD)
Expand All @@ -43,6 +42,7 @@ constructor(
val userService: UserService,
val userCredentialsService: UserCredentialsService,
val userArgumentResolver: UserArgumentResolver,
val multification: VelocityMultification,
) {

@Async
Expand All @@ -58,18 +58,17 @@ constructor(
val user = userArgumentResolver.resolve(usernameOrUuidRaw)

if (user.isPremium) {
sender.sendMessage(
Component.text(
"Can't execute the command! Account '${user.username}' is set to premium mode.",
TextColors.RED,
)
)
multification
.create(sender) { it.multification.adminCmdAccountIsPremiumError }
.placeholder("%USERNAME%", user.username.value)
.send()
return
}

userCredentialsService.updatePassword(user, password)
sender.sendMessage(
Component.text("Success! User '${user.username}' credentials set.", TextColors.GREEN)
)
multification
.create(sender) { it.multification.adminCmdPasswordSetSuccess }
.placeholder("%USERNAME%", user.username.value)
.send()
}
}
Loading