From ce5432914da3826cc101493acbe26d7b07d6da94 Mon Sep 17 00:00:00 2001 From: gsd Date: Thu, 10 Aug 2023 23:24:03 +0300 Subject: [PATCH] steam auth 5 --- .../app/controllers/auth/AuthSteamController.java | 11 ++++++----- src/main/java/app/services/steam/SteamSignIn.java | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/app/controllers/auth/AuthSteamController.java b/src/main/java/app/controllers/auth/AuthSteamController.java index f642813..4344ca3 100644 --- a/src/main/java/app/controllers/auth/AuthSteamController.java +++ b/src/main/java/app/controllers/auth/AuthSteamController.java @@ -37,8 +37,8 @@ public class AuthSteamController { } @GetMapping("login") - public ResponseEntity Login(){ - return steamSignIn.ConstructURLAndRedirect(); + public ResponseEntity Login(@RequestParam(value = "authentication_discord", required = false, defaultValue = "false") boolean authentication_discord){ + return steamSignIn.ConstructURLAndRedirect(authentication_discord); } @GetMapping("logout") @@ -58,8 +58,8 @@ public class AuthSteamController { .build(); } - @GetMapping("processlogin") - public ResponseEntity ProcessLogin(@RequestParam Map auth_result, HttpServletResponse response){ + @GetMapping("processlogin/{after}") + public ResponseEntity ProcessLogin(@RequestParam Map auth_result, HttpServletResponse response, @PathVariable String after){ System.out.println(auth_result); Long steam64 = steamSignIn.ValidateResults(auth_result); if(steam64 == null){ @@ -75,8 +75,9 @@ public class AuthSteamController { cookie_steam64_secured.setDomain("tf2.pblr-nyk.pro"); response.addCookie(cookie_steam64_secured); + String move = after == "disco"?"/authentication_discord.html":"/"; return ResponseEntity.status(HttpStatus.FOUND). - header("Location", "/") + header("Location", move) .build(); } diff --git a/src/main/java/app/services/steam/SteamSignIn.java b/src/main/java/app/services/steam/SteamSignIn.java index 540c706..7dec77c 100644 --- a/src/main/java/app/services/steam/SteamSignIn.java +++ b/src/main/java/app/services/steam/SteamSignIn.java @@ -63,7 +63,7 @@ public class SteamSignIn { } } - public ResponseEntity ConstructURLAndRedirect(){ + public ResponseEntity ConstructURLAndRedirect(boolean authentication_discord){ Matcher result = refinedScripts.matcher(responseURL); if (!result.find() || result.group(0).isEmpty()){ responseURL = String.format("http://%s", responseURL); @@ -72,8 +72,8 @@ public class SteamSignIn { HashMap authParameters = new HashMap<>(); authParameters.put("openid.ns", "http://specs.openid.net/auth/2.0"); authParameters.put("openid.mode", "checkid_setup"); - authParameters.put("openid.return_to", responseURL); - authParameters.put("openid.realm", responseURL); + authParameters.put("openid.return_to", responseURL + "/" + (authentication_discord?"disco":"root")); + authParameters.put("openid.realm", responseURL + "/" + (authentication_discord?"disco":"root")); authParameters.put("openid.identity", "http://specs.openid.net/auth/2.0/identifier_select"); authParameters.put("openid.claimed_id", "http://specs.openid.net/auth/2.0/identifier_select");