Commit a12d0415 by gdj

增加游客登录接口。

parent cdea3aba
...@@ -30,6 +30,8 @@ public class GlobalMVCConfigurer implements WebMvcConfigurer { ...@@ -30,6 +30,8 @@ public class GlobalMVCConfigurer implements WebMvcConfigurer {
// Exclude the login interface. // Exclude the login interface.
excludePaths.add("/" + managePrefix + manageVersion + "/login"); excludePaths.add("/" + managePrefix + manageVersion + "/login");
excludePaths.add("/" + managePrefix + manageVersion + "/token/refresh"); excludePaths.add("/" + managePrefix + manageVersion + "/token/refresh");
// 放行游客登录接口
excludePaths.add("/" + managePrefix + manageVersion + "/visitorLogin");
excludePaths.add("/swagger-ui.html"); excludePaths.add("/swagger-ui.html");
excludePaths.add("/swagger-ui/**"); excludePaths.add("/swagger-ui/**");
excludePaths.add("/v3/**"); excludePaths.add("/v3/**");
......
package com.dji.sample.manage.controller; package com.dji.sample.manage.controller;
import com.aliyun.oss.internal.SignUtils;
import com.dji.sample.common.error.CommonErrorEnum; import com.dji.sample.common.error.CommonErrorEnum;
import com.dji.sample.manage.model.dto.UserDTO; import com.dji.sample.manage.model.dto.UserDTO;
import com.dji.sample.manage.model.dto.UserLoginDTO; import com.dji.sample.manage.model.dto.UserLoginDTO;
...@@ -7,6 +8,7 @@ import com.dji.sample.manage.service.IUserService; ...@@ -7,6 +8,7 @@ import com.dji.sample.manage.service.IUserService;
import com.dji.sdk.common.HttpResultResponse; import com.dji.sdk.common.HttpResultResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -57,4 +59,42 @@ public class LoginController { ...@@ -57,4 +59,42 @@ public class LoginController {
return HttpResultResponse.success(user.get()); return HttpResultResponse.success(user.get());
} }
/**
* 游客登录
* @param loginDTO
* @return
*/
@PostMapping("/visitorLogin")
public HttpResultResponse visitorLogin(@RequestBody UserLoginDTO loginDTO) {
String timestamp = loginDTO.getTimestamp();
String sign = loginDTO.getSign();
String nonce = loginDTO.getNonce();
String appKey = loginDTO.getAppKey();
// 验证不通过
// if (ObjectUtils.isEmpty(loginDTO)) {
// return new HttpResultResponse()
// .setCode(HttpStatus.UNAUTHORIZED.value())
// .setMessage("invalid visitor login");
// }
// 2️⃣ 时间戳校验
// response.sendError(401, "Timestamp expired");
// 3️⃣ nonce 防重放
// response.sendError(401, "Duplicate nonce");
// 4️⃣ 获取 secret(你自己实现)
// 5️⃣ 服务端重新算 sign
// 目前默认游客登录账号为admin
loginDTO.setUsername("admin");
loginDTO.setPassword("Geoair#123");
return userService.userLogin(loginDTO);
}
} }
...@@ -27,4 +27,21 @@ public class UserLoginDTO { ...@@ -27,4 +27,21 @@ public class UserLoginDTO {
private String orgName; private String orgName;
/**
* 游客登录时间戳
*/
private String timestamp;
/**
* 游客登录时间戳加盐
*/
private String sign;
private String appKey;
/**
* 随机字符串
*/
private String nonce;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment