类 UserController
java.lang.Object
com.alibaba.nacos.plugin.auth.impl.controller.UserController
@RestController
@RequestMapping({"/v1/auth","/v1/auth/users"})
public class UserController
extends Object
User related methods entry.
- 作者:
- wfnuser, nkorange
-
字段概要
字段修饰符和类型字段说明private final AuthConfigsprivate final org.springframework.security.authentication.AuthenticationManager已过时。private final IAuthenticationManagerprivate final TokenManagerDelegateprivate final NacosRoleServiceprivate final NacosUserService -
构造器概要
构造器构造器说明UserController(TokenManagerDelegate jwtTokenManager, NacosUserService userDetailsService, NacosRoleService roleService, AuthConfigs authConfigs, IAuthenticationManager iAuthenticationManager, org.springframework.security.authentication.AuthenticationManager authenticationManager) -
方法概要
修饰符和类型方法说明createAdminUser(String password) Create a admin user only not exist admin user can use.createUser(String username, String password) Create a new user.deleteUser(String username) Delete an existed user.com.alibaba.nacos.api.model.Page<User> fuzzySearchUser(int pageNo, int pageSize, String username) com.alibaba.nacos.api.model.Page<User> Get paged users.private booleanhasPermission(String username, jakarta.servlet.http.HttpServletRequest request) login(String username, String password, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.http.HttpServletRequest request) Login to NacossearchUsersLikeUsername(String username) Fuzzy matching username.updateUser(String username, String newPassword, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.http.HttpServletRequest request) Update an user.
-
字段详细资料
-
jwtTokenManager
-
userDetailsService
-
roleService
-
authConfigs
-
iAuthenticationManager
-
authenticationManager
@Deprecated private final org.springframework.security.authentication.AuthenticationManager authenticationManager已过时。
-
-
构造器详细资料
-
UserController
public UserController(TokenManagerDelegate jwtTokenManager, NacosUserService userDetailsService, NacosRoleService roleService, AuthConfigs authConfigs, IAuthenticationManager iAuthenticationManager, org.springframework.security.authentication.AuthenticationManager authenticationManager)
-
-
方法详细资料
-
createUser
Create a new user.- 参数:
username- usernamepassword- password- 返回:
- ok if create succeed
- 抛出:
IllegalArgumentException- if user already exist- 从以下版本开始:
- 1.2.0
-
createAdminUser
Create a admin user only not exist admin user can use. -
deleteUser
Delete an existed user.- 参数:
username- username of user- 返回:
- ok if deleted succeed, keep silent if user not exist
- 从以下版本开始:
- 1.2.0
-
updateUser
@PutMapping public Object updateUser(@RequestParam String username, @RequestParam String newPassword, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.http.HttpServletRequest request) throws IOException Update an user.- 参数:
username- username of usernewPassword- new password of userresponse- http responserequest- http request- 返回:
- ok if update succeed
- 抛出:
IllegalArgumentException- if user not exist or oldPassword is incorrectIOException- 从以下版本开始:
- 1.2.0
-
hasPermission
private boolean hasPermission(String username, jakarta.servlet.http.HttpServletRequest request) throws org.springframework.web.HttpSessionRequiredException, AccessException - 抛出:
org.springframework.web.HttpSessionRequiredExceptionAccessException
-
getUsers
@GetMapping(params="search=accurate") public com.alibaba.nacos.api.model.Page<User> getUsers(@RequestParam int pageNo, @RequestParam int pageSize, @RequestParam(name="username",required=false,defaultValue="") String username) Get paged users.- 参数:
pageNo- number index of pagepageSize- size of page- 返回:
- A collection of users, empty set if no user is found
- 从以下版本开始:
- 1.2.0
-
fuzzySearchUser
-
login
@PostMapping("/login") public Object login(@RequestParam String username, @RequestParam String password, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.http.HttpServletRequest request) throws AccessException, IOException Login to NacosThis methods uses username and password to require a new token.
- 参数:
username- username of userpassword- passwordresponse- http responserequest- http request- 返回:
- new token of the user
- 抛出:
AccessException- if user info is incorrectIOException
-
searchUsersLikeUsername
Fuzzy matching username.- 参数:
username- username- 返回:
- Matched username
-