|
@@ -51,6 +51,16 @@ type DeviceAuthArgs struct {
|
|
|
Protocol string `json:"protocol" binding:"required"`
|
|
|
}
|
|
|
|
|
|
+type AccessAuthArgs struct {
|
|
|
+ UserName string `json:"username"`
|
|
|
+ Password string `json:"password"`
|
|
|
+}
|
|
|
+
|
|
|
+type AccessAuthResp struct {
|
|
|
+ Result string `json:"result"` // 可选 "allow" | "deny" | "ignore"
|
|
|
+ IsSuperuser bool `json:"is_superuser"` // false
|
|
|
+}
|
|
|
+
|
|
|
// RegisterDevice 设备激活
|
|
|
func RegisterDevice(args DeviceRegisterArgs, r render.Render) {
|
|
|
server.Log.Printf("ACTION RegisterDevice, args:: %v ", args)
|
|
@@ -80,9 +90,16 @@ func RegisterDevice(args DeviceRegisterArgs, r render.Render) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// DeviceAccessAuth emqx 设备接入认证
|
|
|
+func DeviceAccessAuth(args AccessAuthArgs, r render.Render) {
|
|
|
+ server.Log.Printf("ACTION DeviceAccessAuth, args:: %v", args)
|
|
|
+ result := AccessAuthResp{}
|
|
|
+ result.Result = "allow"
|
|
|
+ r.JSON(http.StatusOK, result)
|
|
|
+}
|
|
|
+
|
|
|
// AuthDevice device auth
|
|
|
func AuthDevice(args DeviceAuthArgs, r render.Render) {
|
|
|
- server.Log.Printf("ACTION AuthDevice, args:: %v", args)
|
|
|
device := &models.Device{}
|
|
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(context.Background(), "AuthDevice")
|