Skip to content

Commit

Permalink
Merge branch 'main' into 45-suggestion-add-tests
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/pom.xml
#	pom.xml
  • Loading branch information
bivashy committed Jan 6, 2024
2 parents 835285d + e76544d commit b751c86
Show file tree
Hide file tree
Showing 39 changed files with 890 additions and 347 deletions.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug] "
labels: 'status: needs testing, type: bug'
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Launch '...'
2. Execute '....'
3. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature] "
labels: 'type: enhancement'
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
28 changes: 28 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Pull Request Etiquette

<!--
There are several guidelines you should follow in order for your
Pull Request to be merged.
-->

- [ ] I have checked the PRs for upcoming features/bug fixes.

<!--
It is sometimes better to include more changes in a single commit.
If you find yourself having an overwhelming amount of commits, you
can **rebase** your branch.
-->

### Changes

- [ ] Internal code
- [ ] API (affecting end-user code)
- [ ] Other: \_____ <!-- Insert other type here -->

<!-- Replace "NaN" with an issue number if this is a response to an issue -->

Closes Issue: NaN

## Description

Replace this sentence with general description of what your Pull Request does.
87 changes: 87 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# 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:
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '19 13 * * 6'

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:
actions: read
contents: read
security-events: write

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@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
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


# Cache maven packages
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# Build maven in batch mode, updating snapshots, showing version and errors, skipping tests
- name: Build with Maven
run: mvn --batch-mode --update-snapshots -e -V clean install -DskipTests

# ℹ️ 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@v2
with:
category: "/language:${{matrix.language}}"
41 changes: 1 addition & 40 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,11 @@
<parent>
<groupId>me.mastercapexd.auth</groupId>
<artifactId>main</artifactId>
<version>1.7.12</version>
<version>1.8.0-beta.1</version>
</parent>
<groupId>com.bivashy.auth</groupId>
<artifactId>api</artifactId>

<properties>
<jbcrypt.version>0.4</jbcrypt.version>
<multimessenger.version>1.0.5</multimessenger.version>
<adventure.serializer.version>4.14.0</adventure.serializer.version>
<adventure.platform.version>4.3.0</adventure.platform.version>
<ormlite.version>6.1</ormlite.version>
<google.authenticator.version>1.5.0</google.authenticator.version>
<event-bus.version>1.3</event-bus.version>
<configuration-library.version>4.0.2</configuration-library.version>
<libby.version>2.0.0</libby.version>
</properties>

<repositories>
<repository>
<id>jitpack.io</id>
Expand All @@ -35,101 +23,74 @@
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>${jbcrypt.version}</version>
</dependency>

<!-- MultiMessenger library -->
<dependency>
<groupId>com.github.bivashy.MultiMessenger</groupId>
<artifactId>common</artifactId>
<version>${multimessenger.version}</version>
</dependency>
<dependency>
<groupId>com.github.bivashy.MultiMessenger</groupId>
<artifactId>vk</artifactId>
<version>${multimessenger.version}</version>
</dependency>
<dependency>
<groupId>com.github.bivashy.MultiMessenger</groupId>
<artifactId>telegram</artifactId>
<version>${multimessenger.version}</version>
<exclusions>
<exclusion>
<groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.bivashy.MultiMessenger</groupId>
<artifactId>discord</artifactId>
<version>${multimessenger.version}</version>
<exclusions>
<exclusion>
<artifactId>JDA</artifactId>
<groupId>net.dv8tion</groupId>
</exclusion>
</exclusions>
</dependency>


<!-- Adventure platform -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-api</artifactId>
<version>${adventure.platform.version}</version>
</dependency>

<!-- Adventure serializers -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>${adventure.serializer.version}</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-legacy</artifactId>
<version>${adventure.serializer.version}</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-plain</artifactId>
<version>${adventure.serializer.version}</version>
</dependency>

<!-- ORMLite -->
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-jdbc</artifactId>
<version>${ormlite.version}</version>
</dependency>

<!-- GoogleAuthenticator library -->
<dependency>
<groupId>com.warrenstrange</groupId>
<artifactId>googleauth</artifactId>
<version>${google.authenticator.version}</version>
</dependency>

<!-- Event Bus -->
<dependency>
<groupId>com.github.Revxrsal</groupId>
<artifactId>EventBus</artifactId>
<version>${event-bus.version}</version>
</dependency>

<!-- Configuration library core -->
<dependency>
<groupId>com.github.bivashy.ConfigurationLibrary</groupId>
<artifactId>core</artifactId>
<version>${configuration-library.version}</version>
</dependency>

<!-- Libby runtime dependency management -->
<dependency>
<groupId>com.github.bivashy.libby</groupId>
<artifactId>libby-core</artifactId>
<version>${libby.version}</version>
</dependency>
</dependencies>
</project>
6 changes: 4 additions & 2 deletions api/src/main/java/com/bivashy/auth/api/account/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.bivashy.auth.api.crypto.HashedPassword;
import com.bivashy.auth.api.link.LinkType;
import com.bivashy.auth.api.link.user.LinkUser;
import com.bivashy.auth.api.link.user.LinkUserTemplate;
import com.bivashy.auth.api.link.user.info.LinkUserInfo;
import com.bivashy.auth.api.model.PlayerIdSupplier;
import com.bivashy.auth.api.server.player.ServerPlayer;
Expand All @@ -20,6 +19,9 @@
import com.bivashy.auth.api.type.KickResultType;

public interface Account extends PlayerIdSupplier {

long getDatabaseId();

@Deprecated
default String getId() {
return getPlayerId();
Expand Down Expand Up @@ -73,7 +75,7 @@ default LinkUser findFirstLinkUserOrCreate(Predicate<LinkUser> filter, LinkUser
}

default LinkUser findFirstLinkUserOrNew(Predicate<LinkUser> filter, LinkType linkType) {
return findFirstLinkUserOrCreate(filter, LinkUserTemplate.of(linkType, this, LinkUserInfo.of(linkType.getDefaultIdentificator())));
return findFirstLinkUserOrCreate(filter, LinkUser.of(linkType, this, LinkUserInfo.of(linkType.getDefaultIdentificator())));
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public interface PluginConfig {

boolean isPasswordConfirmationEnabled();

boolean isPasswordInChatEnabled();

int getPasswordMinLength();

int getPasswordMaxLength();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.bivashy.auth.api.event;

import com.bivashy.auth.api.event.base.PlayerEvent;
import io.github.revxrsal.eventbus.gen.Index;

public interface PlayerChatPasswordEvent extends PlayerEvent {
@Index(1)
String getPassword();
}
21 changes: 21 additions & 0 deletions api/src/main/java/com/bivashy/auth/api/link/user/LinkUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
import com.bivashy.auth.api.link.user.info.LinkUserInfo;

public interface LinkUser {

static LinkUser of(LinkType linkType, Account account, LinkUserInfo userInfo) {
return new LinkUser() {
@Override
public LinkType getLinkType() {
return linkType;
}

@Override
public Account getAccount() {
return account;
}

@Override
public LinkUserInfo getLinkUserInfo() {
return userInfo;
}
};
}

/**
* @return link type, for example link type of VK, link type of DISCORD,link
* type of TELEGRAM.
Expand All @@ -29,4 +49,5 @@ default boolean isIdentifierDefaultOrNull() {
.map(identificator -> identificator.equals(getLinkType().getDefaultIdentificator()) || identificator.asString() == null)
.orElse(true);
}

}
Loading

0 comments on commit b751c86

Please sign in to comment.