|
@@ -1,6 +1,7 @@
|
|
|
package org.hswebframework.web.authorization.basic.web;
|
|
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.hswebframework.web.authorization.Authentication;
|
|
|
import org.hswebframework.web.authorization.ReactiveAuthenticationManager;
|
|
|
import org.hswebframework.web.authorization.annotation.Authorize;
|
|
@@ -24,6 +25,7 @@ import reactor.core.publisher.Mono;
|
|
|
@RequestMapping
|
|
|
@Authorize
|
|
|
@Resource(id = "user-token", name = "用户令牌信息管理")
|
|
|
+@Tag(name = "用户令牌管理")
|
|
|
public class ReactiveUserTokenController {
|
|
|
private UserTokenManager userTokenManager;
|
|
|
|
|
@@ -43,7 +45,7 @@ public class ReactiveUserTokenController {
|
|
|
|
|
|
@GetMapping("/user-token/reset")
|
|
|
@Authorize(merge = false)
|
|
|
- @ApiOperation("重置当前用户的令牌")
|
|
|
+ @Operation(summary = "重置当前用户的令牌")
|
|
|
public Mono<Boolean> resetToken() {
|
|
|
return ContextUtils.reactiveContext()
|
|
|
.map(context -> context.get(ContextKey.of(ParsedToken.class)).orElseThrow(UnAuthorizedException::new))
|
|
@@ -52,7 +54,7 @@ public class ReactiveUserTokenController {
|
|
|
}
|
|
|
|
|
|
@PutMapping("/user-token/check")
|
|
|
- @ApiOperation("检查所有已过期的token并移除")
|
|
|
+ @Operation(summary = "检查所有已过期的token并移除")
|
|
|
@SaveAction
|
|
|
public Mono<Boolean> checkExpiredToken() {
|
|
|
return userTokenManager
|
|
@@ -61,63 +63,63 @@ public class ReactiveUserTokenController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/user-token/token/{token}")
|
|
|
- @ApiOperation("根据token获取令牌信息")
|
|
|
+ @Operation(summary = "根据token获取令牌信息")
|
|
|
@QueryAction
|
|
|
public Mono<UserToken> getByToken(@PathVariable String token) {
|
|
|
return userTokenManager.getByToken(token);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/user-token/user/{userId}")
|
|
|
- @ApiOperation("根据用户ID获取全部令牌信息")
|
|
|
+ @Operation(summary = "根据用户ID获取全部令牌信息")
|
|
|
@QueryAction
|
|
|
public Flux<UserToken> getByUserId(@PathVariable String userId) {
|
|
|
return userTokenManager.getByUserId(userId);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/user-token/user/{userId}/logged")
|
|
|
- @ApiOperation("根据用户ID判断用户是否已经登录")
|
|
|
+ @Operation(summary = "根据用户ID判断用户是否已经登录")
|
|
|
@QueryAction
|
|
|
public Mono<Boolean> userIsLoggedIn(@PathVariable String userId) {
|
|
|
return userTokenManager.userIsLoggedIn(userId);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/user-token/token/{token}/logged")
|
|
|
- @ApiOperation("根据令牌判断用户是否已经登录")
|
|
|
+ @Operation(summary = "根据令牌判断用户是否已经登录")
|
|
|
@QueryAction
|
|
|
public Mono<Boolean> tokenIsLoggedIn(@PathVariable String token) {
|
|
|
return userTokenManager.tokenIsLoggedIn(token);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/user-token/user/total")
|
|
|
- @ApiOperation("获取当前已经登录的用户数量")
|
|
|
+ @Operation(summary = "获取当前已经登录的用户数量")
|
|
|
@Authorize(merge = false)
|
|
|
public Mono<Integer> totalUser() {
|
|
|
return userTokenManager.totalUser();
|
|
|
}
|
|
|
|
|
|
@GetMapping("/user-token/token/total")
|
|
|
- @ApiOperation("获取当前已经登录的令牌数量")
|
|
|
+ @Operation(summary = "获取当前已经登录的令牌数量")
|
|
|
@Authorize(merge = false)
|
|
|
public Mono<Integer> totalToken() {
|
|
|
return userTokenManager.totalToken();
|
|
|
}
|
|
|
|
|
|
@GetMapping("/user-token")
|
|
|
- @ApiOperation("获取全部用户令牌信息")
|
|
|
+ @Operation(summary = "获取全部用户令牌信息")
|
|
|
@QueryAction
|
|
|
public Flux<UserToken> allLoggedUser() {
|
|
|
return userTokenManager.allLoggedUser();
|
|
|
}
|
|
|
|
|
|
@DeleteMapping("/user-token/user/{userId}")
|
|
|
- @ApiOperation("根据用户id将用户踢下线")
|
|
|
+ @Operation(summary = "根据用户id将用户踢下线")
|
|
|
@SaveAction
|
|
|
public Mono<Void> signOutByUserId(@PathVariable String userId) {
|
|
|
return userTokenManager.signOutByUserId(userId);
|
|
|
}
|
|
|
|
|
|
@DeleteMapping("/user-token/token/{token}")
|
|
|
- @ApiOperation("根据令牌将用户踢下线")
|
|
|
+ @Operation(summary = "根据令牌将用户踢下线")
|
|
|
@SaveAction
|
|
|
public Mono<Void> signOutByToken(@PathVariable String token) {
|
|
|
return userTokenManager.signOutByToken(token);
|
|
@@ -126,35 +128,35 @@ public class ReactiveUserTokenController {
|
|
|
|
|
|
@SaveAction
|
|
|
@PutMapping("/user-token/user/{userId}/{state}")
|
|
|
- @ApiOperation("根据用户id更新用户令牌状态")
|
|
|
+ @Operation(summary = "根据用户id更新用户令牌状态")
|
|
|
public Mono<Void> changeUserState(@PathVariable String userId, @PathVariable TokenState state) {
|
|
|
|
|
|
return userTokenManager.changeUserState(userId, state);
|
|
|
}
|
|
|
|
|
|
@PutMapping("/user-token/token/{token}/{state}")
|
|
|
- @ApiOperation("根据令牌更新用户令牌状态")
|
|
|
+ @Operation(summary = "根据令牌更新用户令牌状态")
|
|
|
@SaveAction
|
|
|
public Mono<Void> changeTokenState(@PathVariable String token, @PathVariable TokenState state) {
|
|
|
return userTokenManager.changeTokenState(token, state);
|
|
|
}
|
|
|
-
|
|
|
- @PostMapping("/user-token/{token}/{type}/{userId}/{maxInactiveInterval}")
|
|
|
- @ApiOperation("将用户设置为登录")
|
|
|
- @SaveAction
|
|
|
- public Mono<UserToken> signIn(@PathVariable String token, @PathVariable String type, @PathVariable String userId, @PathVariable long maxInactiveInterval) {
|
|
|
- return userTokenManager.signIn(token, type, userId, maxInactiveInterval);
|
|
|
- }
|
|
|
+//
|
|
|
+// @PostMapping("/user-token/{token}/{type}/{userId}/{maxInactiveInterval}")
|
|
|
+// @Operation(summary = "将用户设置为登录")
|
|
|
+// @SaveAction
|
|
|
+// public Mono<UserToken> signIn(@PathVariable String token, @PathVariable String type, @PathVariable String userId, @PathVariable long maxInactiveInterval) {
|
|
|
+// return userTokenManager.signIn(token, type, userId, maxInactiveInterval);
|
|
|
+// }
|
|
|
|
|
|
@GetMapping("/user-token/{token}/touch")
|
|
|
- @ApiOperation("更新token有效期")
|
|
|
+ @Operation(summary = "更新token有效期")
|
|
|
@SaveAction
|
|
|
public Mono<Void> touch(@PathVariable String token) {
|
|
|
return userTokenManager.touch(token);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/user-auth/{userId}")
|
|
|
- @ApiOperation("根据用户id获取用户的权限信息")
|
|
|
+ @Operation(summary = "根据用户id获取权限信息")
|
|
|
@SaveAction
|
|
|
public Mono<Authentication> userAuthInfo(@PathVariable String userId) {
|
|
|
return authenticationManager.getByUserId(userId);
|