forked from External/mage
lol cef auth + forejo
This commit is contained in:
parent
0fdb21f17d
commit
35d7d3756a
15 changed files with 114 additions and 118 deletions
23
.forejo/workflows/release.yml
Normal file
23
.forejo/workflows/release.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
example-docker-compose:
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build Mage
|
||||||
|
run: |
|
||||||
|
apk update
|
||||||
|
apk add openjdk8-jdk maven
|
||||||
|
mvn clean install -DskipTests
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: files
|
||||||
|
path: |
|
||||||
|
./Mage.Client/target/mage-client.zip
|
||||||
|
./Mage.Server/target/mage-server.zip
|
||||||
10
.github/dependabot.yml
vendored
10
.github/dependabot.yml
vendored
|
|
@ -1,10 +0,0 @@
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: 'github-actions'
|
|
||||||
directory: '/'
|
|
||||||
schedule:
|
|
||||||
interval: 'weekly'
|
|
||||||
- package-ecosystem: 'maven'
|
|
||||||
directory: '/'
|
|
||||||
schedule:
|
|
||||||
interval: 'weekly'
|
|
||||||
23
.github/labeler.yml
vendored
23
.github/labeler.yml
vendored
|
|
@ -1,23 +0,0 @@
|
||||||
dev:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: [ '*', 'Utils/**', '/.github/**' ]
|
|
||||||
|
|
||||||
engine:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: [ 'Mage/**' ]
|
|
||||||
|
|
||||||
client:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: [ 'Mage.Client/**', 'Mage.Common/**', 'Mage.Plugins/**' ]
|
|
||||||
|
|
||||||
server:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: [ 'Mage.Server*/**' ]
|
|
||||||
|
|
||||||
tests:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: [ 'Mage.Verify/**', 'Mage.Tests/**', 'Mage.Reports/**' ]
|
|
||||||
|
|
||||||
cards:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: [ 'Mage.Sets/**' ]
|
|
||||||
15
.github/workflows/labeler-auto.yml
vendored
15
.github/workflows/labeler-auto.yml
vendored
|
|
@ -1,15 +0,0 @@
|
||||||
name: "Pull Request Labeler (auto)"
|
|
||||||
on:
|
|
||||||
- pull_request_target
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
labeler:
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- id: label-the-PR
|
|
||||||
uses: actions/labeler@v5
|
|
||||||
with:
|
|
||||||
configuration-path: '.github/labeler.yml'
|
|
||||||
24
.github/workflows/labeler-manual.yml
vendored
24
.github/workflows/labeler-manual.yml
vendored
|
|
@ -1,24 +0,0 @@
|
||||||
name: "Pull Request Labeler (manual)"
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
oldPRs:
|
|
||||||
# no multi lines support, so call by single PR only
|
|
||||||
description: 'PR number to process'
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
default: '123'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
labeler:
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- id: label-the-PR
|
|
||||||
uses: actions/labeler@v5
|
|
||||||
with:
|
|
||||||
configuration-path: '.github/labeler.yml'
|
|
||||||
pr-number: |
|
|
||||||
${{ github.event.inputs.oldPRs }}
|
|
||||||
21
.github/workflows/mtg-fetch-cards.yml
vendored
21
.github/workflows/mtg-fetch-cards.yml
vendored
|
|
@ -1,21 +0,0 @@
|
||||||
name: Mtg Card Fetch Bot
|
|
||||||
|
|
||||||
on:
|
|
||||||
issue_comment:
|
|
||||||
types: [created]
|
|
||||||
issues:
|
|
||||||
types: [opened]
|
|
||||||
pull_request_review:
|
|
||||||
types: [submitted]
|
|
||||||
pull_request_review_comment:
|
|
||||||
types: [created]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
fetch-card-references:
|
|
||||||
name: Fetch MTG Card
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
steps:
|
|
||||||
- uses: ldeluigi/mtg-fetch-action@v1
|
|
||||||
|
|
@ -308,14 +308,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
errorDialog.setLocation(100, 100);
|
errorDialog.setLocation(100, 100);
|
||||||
desktopPane.add(errorDialog, errorDialog.isModal() ? JLayeredPane.MODAL_LAYER : JLayeredPane.PALETTE_LAYER);
|
desktopPane.add(errorDialog, errorDialog.isModal() ? JLayeredPane.MODAL_LAYER : JLayeredPane.PALETTE_LAYER);
|
||||||
|
|
||||||
try {
|
|
||||||
this.whatsNewDialog = new WhatsNewDialog();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
// example: JavaFX is not supported on old MacOS with OpenJDK
|
|
||||||
// https://bugs.openjdk.java.net/browse/JDK-8202132
|
|
||||||
LOGGER.error("JavaFX is not supported by your system. What's new page will be disabled.", e);
|
|
||||||
this.whatsNewDialog = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
PING_SENDER_EXECUTOR.scheduleAtFixedRate(SessionHandler::ping, TablesPanel.PING_SERVER_SECS, TablesPanel.PING_SERVER_SECS, TimeUnit.SECONDS);
|
PING_SENDER_EXECUTOR.scheduleAtFixedRate(SessionHandler::ping, TablesPanel.PING_SERVER_SECS, TablesPanel.PING_SERVER_SECS, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
@ -396,11 +388,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
|
|
||||||
setWindowTitle(); // make sure title is actual on startup
|
setWindowTitle(); // make sure title is actual on startup
|
||||||
});
|
});
|
||||||
|
|
||||||
// run what's new checks (loading in background)
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
showWhatsNewDialog(false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bootstrapSetsAndFormats() {
|
private void bootstrapSetsAndFormats() {
|
||||||
|
|
|
||||||
|
|
@ -329,6 +329,7 @@ public class ConnectDialog extends MageDialog {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnFindBeta.setText("BETA");
|
btnFindBeta.setText("BETA");
|
||||||
|
btnFindBeta.setEnabled(false);
|
||||||
btnFindBeta.setToolTipText("Connect to BETA server, AI disabled (use any username without registration)");
|
btnFindBeta.setToolTipText("Connect to BETA server, AI disabled (use any username without registration)");
|
||||||
btnFindBeta.setAlignmentY(0.0F);
|
btnFindBeta.setAlignmentY(0.0F);
|
||||||
btnFindBeta.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
btnFindBeta.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@
|
||||||
mailUser=""
|
mailUser=""
|
||||||
mailPassword=""
|
mailPassword=""
|
||||||
mailFromAddress=""
|
mailFromAddress=""
|
||||||
|
httpAuth="false"
|
||||||
|
authUrl=""
|
||||||
/>
|
/>
|
||||||
<playerTypes>
|
<playerTypes>
|
||||||
<playerType name="Human" jar="mage-player-human-${project.version}.jar" className="mage.player.human.HumanPlayer"/>
|
<playerType name="Human" jar="mage-player-human-${project.version}.jar" className="mage.player.human.HumanPlayer"/>
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ public class AuthorizedUser {
|
||||||
public boolean doCredentialsMatch(String name, String password) {
|
public boolean doCredentialsMatch(String name, String password) {
|
||||||
HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(this.hashAlgorithm);
|
HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(this.hashAlgorithm);
|
||||||
matcher.setHashIterations(this.hashIterations);
|
matcher.setHashIterations(this.hashIterations);
|
||||||
|
|
||||||
AuthenticationToken token = new UsernamePasswordToken(name, password);
|
AuthenticationToken token = new UsernamePasswordToken(name, password);
|
||||||
AuthenticationInfo info = new SimpleAuthenticationInfo(this.name,
|
AuthenticationInfo info = new SimpleAuthenticationInfo(this.name,
|
||||||
ByteSource.Util.bytes(Base64.decode(this.password)),
|
ByteSource.Util.bytes(Base64.decode(this.password)),
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,17 @@ import org.jboss.remoting.callback.Callback;
|
||||||
import org.jboss.remoting.callback.HandleCallbackException;
|
import org.jboss.remoting.callback.HandleCallbackException;
|
||||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
@ -152,8 +163,8 @@ public class Session {
|
||||||
if (userName.length() > config.getMaxUserNameLength()) {
|
if (userName.length() > config.getMaxUserNameLength()) {
|
||||||
return "User name may not be longer than " + config.getMaxUserNameLength() + " characters";
|
return "User name may not be longer than " + config.getMaxUserNameLength() + " characters";
|
||||||
}
|
}
|
||||||
if (userName.length() <= 3) {
|
if (userName.length() <= 1) {
|
||||||
return "User name is too short (3 characters or fewer)";
|
return "User name is too short (1 characters or fewer)";
|
||||||
}
|
}
|
||||||
if (userName.length() >= 500) {
|
if (userName.length() >= 500) {
|
||||||
return "User name is too long (500 characters or more)";
|
return "User name is too long (500 characters or more)";
|
||||||
|
|
@ -242,6 +253,7 @@ public class Session {
|
||||||
|
|
||||||
// find auth user
|
// find auth user
|
||||||
AuthorizedUser authorizedUser = null;
|
AuthorizedUser authorizedUser = null;
|
||||||
|
|
||||||
if (managerFactory.configSettings().isAuthenticationActivated()) {
|
if (managerFactory.configSettings().isAuthenticationActivated()) {
|
||||||
authorizedUser = AuthorizedUserRepository.getInstance().getByName(userName);
|
authorizedUser = AuthorizedUserRepository.getInstance().getByName(userName);
|
||||||
String errorMsg = "Wrong username or password. You must register your account first.";
|
String errorMsg = "Wrong username or password. You must register your account first.";
|
||||||
|
|
@ -267,6 +279,52 @@ public class Session {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (managerFactory.configSettings().isHttpAuth()) {
|
||||||
|
try {
|
||||||
|
JsonObject body = new JsonObject();
|
||||||
|
body.addProperty("passphrase", password);
|
||||||
|
body.addProperty("accountName", userName);
|
||||||
|
|
||||||
|
String json = body.toString();
|
||||||
|
System.out.println(json);
|
||||||
|
|
||||||
|
URL url = new URL(managerFactory.configSettings().getAuthUrl());
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setRequestProperty("Content-Type", "application/json");
|
||||||
|
conn.setRequestProperty("Content-Length", Integer.toString(json.length()));
|
||||||
|
conn.setRequestProperty("User-Agent", "Tainted-Mage/1.0");
|
||||||
|
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
|
||||||
|
|
||||||
|
OutputStream os = conn.getOutputStream();
|
||||||
|
os.write(json.getBytes());
|
||||||
|
os.flush();
|
||||||
|
os.close();
|
||||||
|
|
||||||
|
int responseCode = conn.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||||
|
|
||||||
|
String resp = in.readLine();
|
||||||
|
in.close();
|
||||||
|
JsonElement response = JsonParser.parseString(resp);
|
||||||
|
if (response.isJsonObject() && response.getAsJsonObject().has("success") && response.getAsJsonObject().get("success").getAsBoolean()) {
|
||||||
|
// s'all good, man
|
||||||
|
} else {
|
||||||
|
return "Failed to authenticate";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return "Failed to authenticate: " + Integer.toString(responseCode);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "Error with external authentication. Please try again later.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create new user instance (auth or anon)
|
// create new user instance (auth or anon)
|
||||||
boolean isReconnection = false;
|
boolean isReconnection = false;
|
||||||
|
|
|
||||||
|
|
@ -69,4 +69,8 @@ public interface ConfigSettings {
|
||||||
List<Plugin> getDraftCubes();
|
List<Plugin> getDraftCubes();
|
||||||
|
|
||||||
List<Plugin> getDeckTypes();
|
List<Plugin> getDeckTypes();
|
||||||
|
|
||||||
|
boolean isHttpAuth();
|
||||||
|
|
||||||
|
String getAuthUrl();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,21 @@
|
||||||
<xs:attribute name="serverAddress" type="xs:string" use="required"/>
|
<xs:attribute name="serverAddress" type="xs:string" use="required"/>
|
||||||
<xs:attribute name="serverName" type="xs:string" use="required"/>
|
<xs:attribute name="serverName" type="xs:string" use="required"/>
|
||||||
<xs:attribute name="port" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="port" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="secondaryBindPort" type="xs:integer" use="required"/>
|
<xs:attribute name="secondaryBindPort" type="xs:integer" use="required"/>
|
||||||
<xs:attribute name="backlogSize" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="backlogSize" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="numAcceptThreads" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="numAcceptThreads" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="maxPoolSize" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="maxPoolSize" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="leasePeriod" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="leasePeriod" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="maxGameThreads" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="maxGameThreads" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="maxSecondsIdle" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="maxSecondsIdle" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="minUserNameLength" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="minUserNameLength" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="maxUserNameLength" type="xs:positiveInteger" use="required"/>
|
<xs:attribute name="maxUserNameLength" type="xs:positiveInteger" use="required"/>
|
||||||
<xs:attribute name="userNamePattern" type="xs:string" use="required"/>
|
<xs:attribute name="userNamePattern" type="xs:string" use="required"/>
|
||||||
<xs:attribute name="maxAiOpponents" type="xs:string" use="optional"/>
|
<xs:attribute name="maxAiOpponents" type="xs:string" use="optional"/>
|
||||||
<xs:attribute name="saveGameActivated" type="xs:boolean" use="optional"/>
|
<xs:attribute name="saveGameActivated" type="xs:boolean" use="optional"/>
|
||||||
|
<xs:attribute name="httpAuth" type="xs:boolean" use="optional" />
|
||||||
|
<xs:attribute name="authUrl" type="xs:string" use="optional"/>
|
||||||
|
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,5 +142,13 @@ public class ConfigWrapper implements ConfigSettings {
|
||||||
public List<Plugin> getDeckTypes() {
|
public List<Plugin> getDeckTypes() {
|
||||||
return config.getDeckTypes().getDeckType();
|
return config.getDeckTypes().getDeckType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isHttpAuth() {
|
||||||
|
return config.getServer().isHttpAuth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthUrl() {
|
||||||
|
return config.getServer().getAuthUrl();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@
|
||||||
<xs:attribute name="mailUser" type="xs:string" use="optional"/>
|
<xs:attribute name="mailUser" type="xs:string" use="optional"/>
|
||||||
<xs:attribute name="mailPassword" type="xs:string" use="optional"/>
|
<xs:attribute name="mailPassword" type="xs:string" use="optional"/>
|
||||||
<xs:attribute name="mailFromAddress" type="xs:string" use="optional"/>
|
<xs:attribute name="mailFromAddress" type="xs:string" use="optional"/>
|
||||||
|
<xs:attribute name="httpAuth" type="xs:boolean" use="optional" />
|
||||||
|
<xs:attribute name="authUrl" type="xs:string" use="optional"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue