mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-06-26 10:04:58 +08:00
Compare commits
No commits in common. "138c4369821fd313f7efe02c4564bc28dd4abc3d" and "b0aa294c26834ee9c2dce4c38a04a1a09c4f3f12" have entirely different histories.
138c436982
...
b0aa294c26
@ -60,12 +60,6 @@ public interface AuthenticationSystem {
|
||||
*/
|
||||
ExternalAuthenticator getExternalAuthenticator();
|
||||
|
||||
/**
|
||||
* This is the authenticator used for handling OAuth authentication requests.
|
||||
* @return An authenticator.
|
||||
*/
|
||||
OAuthAuthenticator getOAuthAuthenticator();
|
||||
|
||||
/**
|
||||
* A data container that holds relevant data for authenticating a client.
|
||||
*/
|
||||
@ -131,16 +125,4 @@ public interface AuthenticationSystem {
|
||||
return AuthenticationRequest.builder().request(request)
|
||||
.response(response).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates an authentication request from a {@link Response} object.
|
||||
* @param request The Express request.
|
||||
* @param jsonData The JSON data.
|
||||
* @return An authentication request.
|
||||
*/
|
||||
static AuthenticationRequest fromOAuthRequest(Request request, Response response) {
|
||||
return AuthenticationRequest.builder().request(request)
|
||||
.response(response).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ public final class DefaultAuthentication implements AuthenticationSystem {
|
||||
private final Authenticator<LoginResultJson> tokenAuthenticator = new TokenAuthenticator();
|
||||
private final Authenticator<ComboTokenResJson> sessionKeyAuthenticator = new SessionKeyAuthenticator();
|
||||
private final ExternalAuthenticator externalAuthenticator = new ExternalAuthentication();
|
||||
private final OAuthAuthenticator oAuthAuthenticator = new OAuthAuthentication();
|
||||
|
||||
@Override
|
||||
public void createAccount(String username, String password) {
|
||||
@ -54,9 +53,4 @@ public final class DefaultAuthentication implements AuthenticationSystem {
|
||||
public ExternalAuthenticator getExternalAuthenticator() {
|
||||
return this.externalAuthenticator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuthAuthenticator getOAuthAuthenticator() {
|
||||
return this.oAuthAuthenticator;
|
||||
}
|
||||
}
|
||||
|
@ -174,29 +174,4 @@ public final class DefaultAuthenticators {
|
||||
request.getResponse().send("Authentication is not available with the default authentication method.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles authentication requests from OAuth sources.
|
||||
*/
|
||||
public static class OAuthAuthentication implements OAuthAuthenticator {
|
||||
@Override public void handleLogin(AuthenticationRequest request) {
|
||||
assert request.getResponse() != null;
|
||||
request.getResponse().send("Authentication is not available with the default authentication method.");
|
||||
}
|
||||
|
||||
@Override public void handleDesktopRedirection(AuthenticationRequest request) {
|
||||
assert request.getResponse() != null;
|
||||
request.getResponse().send("Authentication is not available with the default authentication method.");
|
||||
}
|
||||
|
||||
@Override public void handleMobileRedirection(AuthenticationRequest request) {
|
||||
assert request.getResponse() != null;
|
||||
request.getResponse().send("Authentication is not available with the default authentication method.");
|
||||
}
|
||||
|
||||
@Override public void handleTokenProcess(AuthenticationRequest request) {
|
||||
assert request.getResponse() != null;
|
||||
request.getResponse().send("Authentication is not available with the default authentication method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package emu.grasscutter.auth;
|
||||
|
||||
import emu.grasscutter.auth.AuthenticationSystem.AuthenticationRequest;
|
||||
|
||||
/**
|
||||
* Handles authentication via OAuth routes.
|
||||
*/
|
||||
public interface OAuthAuthenticator {
|
||||
|
||||
/**
|
||||
* Called when an OAuth login request is made.
|
||||
* @param request The authentication request.
|
||||
*/
|
||||
void handleLogin(AuthenticationRequest request);
|
||||
|
||||
/**
|
||||
* Called when an client requests to redirect to login page.
|
||||
* @param request The authentication request.
|
||||
*/
|
||||
void handleDesktopRedirection(AuthenticationRequest request);
|
||||
void handleMobileRedirection(AuthenticationRequest request);
|
||||
|
||||
/**
|
||||
* Called when an OAuth login requests callback.
|
||||
* @param request The authentication request.
|
||||
*/
|
||||
void handleTokenProcess(AuthenticationRequest request);
|
||||
}
|
@ -2,8 +2,6 @@ package emu.grasscutter.command;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.event.game.CommandResponseEvent;
|
||||
import emu.grasscutter.server.event.types.ServerEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -21,8 +19,6 @@ public interface CommandHandler {
|
||||
} else {
|
||||
player.dropMessage(message);
|
||||
}
|
||||
CommandResponseEvent event = new CommandResponseEvent(ServerEvent.Type.GAME,player, message);
|
||||
event.call();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,24 +0,0 @@
|
||||
package emu.grasscutter.server.event.game;
|
||||
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.event.types.GameEvent;
|
||||
import emu.grasscutter.server.event.types.ServerEvent;
|
||||
|
||||
public class CommandResponseEvent extends ServerEvent {
|
||||
private String message;
|
||||
private Player player;
|
||||
|
||||
public CommandResponseEvent(Type type, Player player,String message) {
|
||||
super(type);
|
||||
this.message = message;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
@ -33,14 +33,6 @@ public final class DispatchHandler implements Router {
|
||||
.handleAccountCreation(AuthenticationSystem.fromExternalRequest(request, response)));
|
||||
express.post("/authentication/change_password", (request, response) -> Grasscutter.getAuthenticationSystem().getExternalAuthenticator()
|
||||
.handlePasswordReset(AuthenticationSystem.fromExternalRequest(request, response)));
|
||||
|
||||
// OAuth login
|
||||
express.post("/hk4e_global/mdk/shield/api/loginByThirdparty", (request, response) -> Grasscutter.getAuthenticationSystem().getOAuthAuthenticator().handleLogin(AuthenticationSystem.fromOAuthRequest(request, response)));
|
||||
// OAuth querystring convert redirection
|
||||
express.get("/authentication/openid/redirect", (request, response) -> Grasscutter.getAuthenticationSystem().getOAuthAuthenticator().handleTokenProcess(AuthenticationSystem.fromOAuthRequest(request, response)));
|
||||
// OAuth redirection
|
||||
express.get("/Api/twitter_login", (request, response) -> Grasscutter.getAuthenticationSystem().getOAuthAuthenticator().handleDesktopRedirection(AuthenticationSystem.fromOAuthRequest(request, response)));
|
||||
express.get("/sdkTwitterLogin.html", (request, response) -> Grasscutter.getAuthenticationSystem().getOAuthAuthenticator().handleMobileRedirection(AuthenticationSystem.fromOAuthRequest(request, response)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user