Skip to content

Commit 7b56174

Browse files
Fixed fatal problem for session.
1 parent 9f55966 commit 7b56174

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MioVerify
22

3-
![Static Badge](https://img.shields.io/badge/version-v1.1.0--BETA-blue) ![Static Badge](https://img.shields.io/badge/java-17-purple) ![Static Badge](https://img.shields.io/badge/developer-Fuzihara_Yukina-orange) ![Static Badge](https://img.shields.io/badge/for-Minecraft_Java_Edition-green)
3+
![Static Badge](https://img.shields.io/badge/version-v1.2.0--BETA-blue) ![Static Badge](https://img.shields.io/badge/java-17-purple) ![Static Badge](https://img.shields.io/badge/developer-Fuzihara_Yukina-orange) ![Static Badge](https://img.shields.io/badge/for-Minecraft_Java_Edition-green)
44

55
MioVerify是一个根据 *[Yggdrasil 服务端技术规范](https://github.com/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83)* 实现的MC身份验证服务器。
66

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>org.miowing</groupId>
1212
<artifactId>MioVerify</artifactId>
13-
<version>1.1.0-BETA</version>
13+
<version>1.2.0-BETA</version>
1414
<name>MioVerify</name>
1515
<description>A Minecraft verification server implementing Yggdrasil API</description>
1616
<properties>

src/main/java/org/miowing/mioverify/controller/SessionController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public ResponseEntity<?> join(@RequestBody JoinReq req) {
4646
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
4747
}
4848
@GetMapping("/hasJoined")
49-
public ProfileShow hasJoined(String username, String serverId) {
49+
public ProfileShow hasJoined(String username /*in fact profileName*/, String serverId) {
5050
return util.profileToShow(sessionUtil.verifySession(serverId, username), true);
5151
}
5252
@GetMapping("/profile/{uuid}")

src/main/java/org/miowing/mioverify/util/SessionUtil.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.miowing.mioverify.exception.InvalidSessionException;
44
import org.miowing.mioverify.exception.InvalidTokenException;
5+
import org.miowing.mioverify.exception.ProfileNotFoundException;
56
import org.miowing.mioverify.exception.UserMismatchException;
67
import org.miowing.mioverify.pojo.AToken;
78
import org.miowing.mioverify.pojo.Profile;
@@ -22,7 +23,7 @@ public class SessionUtil {
2223
private StringRedisTemplate redisTemplate;
2324
@Autowired
2425
private ProfileService profileService;
25-
public Profile verifySession(String serverId, String username) {
26+
public Profile verifySession(String serverId, String profileName) {
2627
if (Boolean.FALSE.equals(redisTemplate.hasKey(SESSION_PREF + serverId))) {
2728
throw new InvalidSessionException();
2829
}
@@ -31,7 +32,11 @@ public Profile verifySession(String serverId, String username) {
3132
if (aToken == null) {
3233
throw new InvalidTokenException();
3334
}
34-
if (!username.equals(aToken.name())) {
35+
Profile profile = profileService.getById(aToken.bindProfile());
36+
if (profile == null) {
37+
throw new ProfileNotFoundException();
38+
}
39+
if (!profileName.equals(profile.getName())) {
3540
throw new UserMismatchException();
3641
}
3742
return profileService.getById(aToken.bindProfile());

0 commit comments

Comments
 (0)