|
|
@@ -86,6 +86,30 @@ func ApplicationAuthOnDeviceIdentifer(context martini.Context, params martini.Pa
|
|
|
|
|
|
}
|
|
|
|
|
|
+func ApplicationAuth(context martini.Context, params martini.Params, req *http.Request, r render.Render) {
|
|
|
+ identifier := params["identifier"]
|
|
|
+ key := req.Header.Get("App-Key")
|
|
|
+
|
|
|
+ if identifier == "" || key == "" {
|
|
|
+ r.JSON(http.StatusOK, renderError(ErrDeviceNotFound, errors.New("missing device identifier or app key.")))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ app := &models.Application{}
|
|
|
+ err := server.RPCCallByName(nil, rpcs.RegistryServerName, "Registry.ValidateApplication", key, app)
|
|
|
+ if err != nil {
|
|
|
+ r.JSON(http.StatusOK, renderError(ErrAccessDenied, err))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = checkAppDomain(app.AppDomain, identifier)
|
|
|
+ if err != nil {
|
|
|
+ r.JSON(http.StatusOK, renderError(ErrAccessDenied, err))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
// check if device is online.
|
|
|
func CheckDeviceOnline(context martini.Context, params martini.Params, req *http.Request, r render.Render) {
|
|
|
identifier := params["identifier"]
|