类 UserControllerV3

java.lang.Object
com.alibaba.nacos.plugin.auth.impl.controller.v3.UserControllerV3

@RestController @RequestMapping("/v3/auth/user") public class UserControllerV3 extends Object
Controller for handling HTTP requests related to user operations.
作者:
zhangyukun on:2024/8/16
  • 字段详细资料

  • 构造器详细资料

    • 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 operations
      roleService - the service for role operations
      authConfigs - the authentication configuration
      iAuthenticationManager - the authentication manager interface
      jwtTokenManager - 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 - username
      password - 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 user
      newPassword - new password of user
      response - http response
      request - http request
      返回:
      ok if update succeed
      抛出:
      IllegalArgumentException - if user not exist or oldPassword is incorrect
      IOException
      从以下版本开始:
      1.2.0
    • hasPermission

      private boolean hasPermission(String username, jakarta.servlet.http.HttpServletRequest request) throws org.springframework.web.HttpSessionRequiredException, AccessException
      抛出:
      org.springframework.web.HttpSessionRequiredException
      AccessException
    • 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 page
      pageSize - size of page
      username - the username to search for, can be an empty string
      search - 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 Nacos

      This methods uses username and password to require a new token.

      参数:
      response - http response
      request - http request
      返回:
      new token of the user
      抛出:
      AccessException - if user info is incorrect
      IOException