类 UserControllerV3
java.lang.Object
com.alibaba.nacos.plugin.auth.impl.controller.v3.UserControllerV3
Controller for handling HTTP requests related to user operations.
- 作者:
- zhangyukun on:2024/8/16
-
字段概要
字段修饰符和类型字段说明private final AuthConfigsprivate final IAuthenticationManagerprivate final TokenManagerDelegateprivate final NacosRoleServiceprivate static final Stringprivate final NacosUserService -
构造器概要
构造器构造器说明UserControllerV3(NacosUserService userDetailsService, NacosRoleService roleService, AuthConfigs authConfigs, IAuthenticationManager iAuthenticationManager, TokenManagerDelegate jwtTokenManager) Constructs a new UserInnerHandler with the provided dependencies. -
方法概要
修饰符和类型方法说明com.alibaba.nacos.api.model.v2.Result<User> createAdminUser(String password) Create a admin user only not exist admin user can use.com.alibaba.nacos.api.model.v2.Result<String> createUser(String username, String password) Create a new user.com.alibaba.nacos.api.model.v2.Result<String> deleteUser(String username) Delete an existed user.com.alibaba.nacos.api.model.v2.Result<com.alibaba.nacos.api.model.Page<User>> getUserList(int pageNo, int pageSize, String username, String search) Get paged users with the option for accurate or fuzzy search.getUserListByUsername(String username) Fuzzy matching username.private booleanhasPermission(String username, jakarta.servlet.http.HttpServletRequest request) login(jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.http.HttpServletRequest request) Login to Nacoscom.alibaba.nacos.api.model.v2.Result<String> updateUser(String username, String newPassword, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.http.HttpServletRequest request) Update an user.
-
字段详细资料
-
userDetailsService
-
roleService
-
authConfigs
-
iAuthenticationManager
-
jwtTokenManager
-
SEARCH_TYPE_BLUR
- 另请参阅:
-
-
构造器详细资料
-
UserControllerV3
public UserControllerV3(NacosUserService userDetailsService, NacosRoleService roleService, AuthConfigs authConfigs, IAuthenticationManager iAuthenticationManager, TokenManagerDelegate jwtTokenManager) Constructs a new UserInnerHandler with the provided dependencies.- 参数:
userDetailsService- the service for user details operationsroleService- the service for role operationsauthConfigs- the authentication configurationiAuthenticationManager- the authentication manager interfacejwtTokenManager- the JWT token manager
-
-
方法详细资料
-
createUser
@PostMapping public com.alibaba.nacos.api.model.v2.Result<String> createUser(@RequestParam String username, @RequestParam String password) Create a new user.- 参数:
username- usernamepassword- password- 返回:
- ok if create succeed
- 抛出:
IllegalArgumentException- if user already exist- 从以下版本开始:
- 1.2.0
-
createAdminUser
@PostMapping("/admin") public com.alibaba.nacos.api.model.v2.Result<User> createAdminUser(@RequestParam(required=false) String password) Create a admin user only not exist admin user can use. -
deleteUser
@DeleteMapping public com.alibaba.nacos.api.model.v2.Result<String> deleteUser(@RequestParam String username) Delete an existed user.- 参数:
username- username of user- 返回:
- ok if deleted succeed, keep silent if user not exist
- 从以下版本开始:
- 1.2.0
-
updateUser
@PutMapping public com.alibaba.nacos.api.model.v2.Result<String> 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
-
getUserList
@GetMapping("/list") public com.alibaba.nacos.api.model.v2.Result<com.alibaba.nacos.api.model.Page<User>> getUserList(@RequestParam int pageNo, @RequestParam int pageSize, @RequestParam(name="username",required=false,defaultValue="") String username, @RequestParam(name="search",required=false,defaultValue="accurate") String search) Get paged users with the option for accurate or fuzzy search.- 参数:
pageNo- number index of pagepageSize- size of pageusername- the username to search for, can be an empty stringsearch- the type of search: "accurate" for exact match, "blur" for fuzzy match- 返回:
- A collection of users, empty set if no user is found
- 从以下版本开始:
- 1.2.0
-
getUserListByUsername
@GetMapping("/search") public com.alibaba.nacos.api.model.v2.Result<List<String>> getUserListByUsername(@RequestParam String username) Fuzzy matching username.- 参数:
username- username- 返回:
- Matched username
-
login
@PostMapping("/login") public Object login(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.
- 参数:
response- http responserequest- http request- 返回:
- new token of the user
- 抛出:
AccessException- if user info is incorrectIOException
-