mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-18 18:01:22 +02:00
commit
5b4a0d8aa9
@ -75,7 +75,7 @@ AuthMe Reloaded prevents players who aren't logged in from actions like placing
|
|||||||
</li><li>Possible to use without a Permissions plugin
|
</li><li>Possible to use without a Permissions plugin
|
||||||
</li><li><strong>Spoutcraft Login GUI</strong>
|
</li><li><strong>Spoutcraft Login GUI</strong>
|
||||||
</li><li>Automatic backup system of all your user password data
|
</li><li>Automatic backup system of all your user password data
|
||||||
</li><li>Default Language Style: en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, nl ( feel free to send new translations )
|
</li><li>Default Language Style: en, de, br, cz, pl, fr, it, ru, hu, sk, es, zhtw, fi, zhcn, nl ( feel free to send new translations )
|
||||||
</li><li>Convert the FlatFile auths.db to an usefull authme.sql that you can use on a MySQL database !
|
</li><li>Convert the FlatFile auths.db to an usefull authme.sql that you can use on a MySQL database !
|
||||||
</li><li>Import your database from Rakamak, xAuth, CrazyLogin, RoyalAuth, vAuth !
|
</li><li>Import your database from Rakamak, xAuth, CrazyLogin, RoyalAuth, vAuth !
|
||||||
</li></ul>
|
</li></ul>
|
||||||
|
30
pom.xml
30
pom.xml
@ -79,6 +79,29 @@
|
|||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>2.3</version>
|
||||||
|
<configuration>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>com.maxmind.geoip:*</include>
|
||||||
|
<include>com.sun.mail:*</include>
|
||||||
|
<include>javax.mail:*</include>
|
||||||
|
<include>com.comphenix.attribute:*</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -169,12 +192,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.mail</groupId>
|
<groupId>com.sun.mail</groupId>
|
||||||
<artifactId>javax.mail</artifactId>
|
<artifactId>javax.mail</artifactId>
|
||||||
<version>1.5.3</version>
|
<version>1.5.4</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.mail</groupId>
|
|
||||||
<artifactId>mail</artifactId>
|
|
||||||
<version>1.5.0-b01</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Maxmind GeoIp API -->
|
<!-- Maxmind GeoIp API -->
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package fr.xephi.authme;
|
package fr.xephi.authme;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.ArrayList;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Random;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -12,10 +10,10 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import fr.xephi.authme.api.API;
|
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||||
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
@ -24,6 +22,7 @@ public class Utils {
|
|||||||
private static Utils singleton;
|
private static Utils singleton;
|
||||||
int id;
|
int id;
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
|
private static List<String> tokens = new ArrayList<String>();
|
||||||
|
|
||||||
public Utils(AuthMe plugin) {
|
public Utils(AuthMe plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -167,19 +166,18 @@ public class Utils {
|
|||||||
* Random Token for passpartu
|
* Random Token for passpartu
|
||||||
*/
|
*/
|
||||||
public boolean obtainToken() {
|
public boolean obtainToken() {
|
||||||
File file = new File("plugins" + File.separator + "AuthMe" + File.separator + "passpartu.token");
|
|
||||||
if (file.exists())
|
|
||||||
file.delete();
|
|
||||||
|
|
||||||
FileWriter writer = null;
|
|
||||||
try {
|
try {
|
||||||
file.createNewFile();
|
final String token = new RandomString(10).nextString();
|
||||||
writer = new FileWriter(file);
|
tokens.add(token);
|
||||||
String token = generateToken();
|
|
||||||
writer.write(token + ":" + System.currentTimeMillis() / 1000 + API.newline);
|
|
||||||
writer.flush();
|
|
||||||
ConsoleLogger.info("[AuthMe] Security passpartu token: " + token);
|
ConsoleLogger.info("[AuthMe] Security passpartu token: " + token);
|
||||||
writer.close();
|
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
tokens.remove(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 600);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -191,46 +189,11 @@ public class Utils {
|
|||||||
* Read Token
|
* Read Token
|
||||||
*/
|
*/
|
||||||
public boolean readToken(String inputToken) {
|
public boolean readToken(String inputToken) {
|
||||||
File file = new File("plugins" + File.separator + "AuthMe" + File.separator + "passpartu.token");
|
boolean ret = false;
|
||||||
|
if (tokens.contains(inputToken))
|
||||||
if (!file.exists())
|
ret = true;
|
||||||
return false;
|
tokens.remove(inputToken);
|
||||||
|
return (ret);
|
||||||
if (inputToken.isEmpty())
|
|
||||||
return false;
|
|
||||||
Scanner reader = null;
|
|
||||||
try {
|
|
||||||
reader = new Scanner(file);
|
|
||||||
while (reader.hasNextLine()) {
|
|
||||||
final String line = reader.nextLine();
|
|
||||||
if (line.contains(":")) {
|
|
||||||
String[] tokenInfo = line.split(":");
|
|
||||||
if (tokenInfo[0].equals(inputToken) && System.currentTimeMillis() / 1000 - 30 <= Integer.parseInt(tokenInfo[1])) {
|
|
||||||
file.delete();
|
|
||||||
reader.close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generate Random Token
|
|
||||||
*/
|
|
||||||
private String generateToken() {
|
|
||||||
// obtain new random token
|
|
||||||
Random rnd = new Random();
|
|
||||||
char[] arr = new char[5];
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
int n = rnd.nextInt(36);
|
|
||||||
arr[i] = (char) (n < 10 ? '0' + n : 'a' + n - 10);
|
|
||||||
}
|
|
||||||
return new String(arr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -73,6 +73,7 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
sender.sendMessage("/authme getemail <playername> - Get player email");
|
sender.sendMessage("/authme getemail <playername> - Get player email");
|
||||||
sender.sendMessage("/authme purgelastpos <playername> - Purge last position for a player");
|
sender.sendMessage("/authme purgelastpos <playername> - Purge last position for a player");
|
||||||
sender.sendMessage("/authme switchantibot on/off - Enable/Disable antibot method");
|
sender.sendMessage("/authme switchantibot on/off - Enable/Disable antibot method");
|
||||||
|
sender.sendMessage("/authme forcelogin <playername>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,6 +553,26 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
database.updateQuitLoc(auth);
|
database.updateQuitLoc(auth);
|
||||||
sender.sendMessage("[AuthMe] Successfully reset position for " + auth.getNickname());
|
sender.sendMessage("[AuthMe] Successfully reset position for " + auth.getNickname());
|
||||||
return true;
|
return true;
|
||||||
|
} else if (args[0].equalsIgnoreCase("forcelogin")) {
|
||||||
|
if (args.length < 2) {
|
||||||
|
sender.sendMessage("Usage : /authme forcelogin <playerName>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Player player = Bukkit.getPlayer(args[1]);
|
||||||
|
if (player == null || !player.isOnline()) {
|
||||||
|
sender.sendMessage("Online player only !");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!plugin.authmePermissible(player, "authme.canbeforced")) {
|
||||||
|
sender.sendMessage("You cannot force login for this player!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
plugin.management.performLogin(player, "dontneed", true);
|
||||||
|
sender.sendMessage("Force Login performed !");
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.sendMessage("An error occured while trying to get that player!");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername");
|
sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername");
|
||||||
}
|
}
|
||||||
|
@ -54,14 +54,20 @@ public class ChangePasswordCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String lowpass = args[1].toLowerCase();
|
String lowpass = args[1].toLowerCase();
|
||||||
if ((lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null")) || !lowpass.matches(Settings.getPassRegex)) {
|
if ((lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null")) || !lowpass.matches(Settings.getPassRegex) || lowpass.equalsIgnoreCase(name)) {
|
||||||
m.send(player, "password_error");
|
m.send(player, "password_error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (lowpass.equalsIgnoreCase(name)) {
|
if (lowpass.length() < Settings.getPasswordMinLen || lowpass.length() > Settings.passwordMaxLength) {
|
||||||
|
m.send(player, "pass_len");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!Settings.unsafePasswords.isEmpty()) {
|
||||||
|
if (Settings.unsafePasswords.contains(lowpass)) {
|
||||||
m.send(player, "password_error");
|
m.send(player, "password_error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, args[1], name);
|
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, args[1], name);
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public class AsyncronousJoin {
|
|||||||
long timeout = Settings.getSessionTimeout * 60000;
|
long timeout = Settings.getSessionTimeout * 60000;
|
||||||
long lastLogin = auth.getLastLogin();
|
long lastLogin = auth.getLastLogin();
|
||||||
long cur = new Date().getTime();
|
long cur = new Date().getTime();
|
||||||
if ((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1")) {
|
if ((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().matches("198.168.(0|1).1")) {
|
||||||
if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip)) {
|
if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip)) {
|
||||||
if (PlayerCache.getInstance().getAuth(name) != null) {
|
if (PlayerCache.getInstance().getAuth(name) != null) {
|
||||||
PlayerCache.getInstance().updatePlayer(auth);
|
PlayerCache.getInstance().updatePlayer(auth);
|
||||||
|
@ -151,6 +151,12 @@ public class AsyncronousLogin {
|
|||||||
|
|
||||||
displayOtherAccounts(auth, player);
|
displayOtherAccounts(auth, player);
|
||||||
|
|
||||||
|
if (Settings.recallEmail) {
|
||||||
|
if (email == null || email.isEmpty() || email.equalsIgnoreCase("your@email.com"))
|
||||||
|
m.send(player, "add_email");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!Settings.noConsoleSpam)
|
if (!Settings.noConsoleSpam)
|
||||||
ConsoleLogger.info(player.getName() + " logged in!");
|
ConsoleLogger.info(player.getName() + " logged in!");
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ permissions:
|
|||||||
authme.admin.getip: true
|
authme.admin.getip: true
|
||||||
authme.admin.converter: true
|
authme.admin.converter: true
|
||||||
authme.admin.resetposition: true
|
authme.admin.resetposition: true
|
||||||
|
authme.admin.forcelogin: true
|
||||||
authme.register:
|
authme.register:
|
||||||
description: Register an account
|
description: Register an account
|
||||||
default: true
|
default: true
|
||||||
@ -165,3 +166,9 @@ permissions:
|
|||||||
authme.admin.resetposition:
|
authme.admin.resetposition:
|
||||||
description: Reset last position for a player
|
description: Reset last position for a player
|
||||||
default: op
|
default: op
|
||||||
|
authme.admin.forcelogin:
|
||||||
|
description: Force login for that player
|
||||||
|
default: op
|
||||||
|
authme.canbeforced:
|
||||||
|
description: Can this player be forced to login
|
||||||
|
default: true
|
Loading…
Reference in New Issue
Block a user