diff --git a/arm/ui/jobs/jobs.py b/arm/ui/jobs/jobs.py
index d977ea313..597d3b26c 100644
--- a/arm/ui/jobs/jobs.py
+++ b/arm/ui/jobs/jobs.py
@@ -13,7 +13,7 @@
"""
import json
-from flask_login import LoginManager, login_required # noqa: F401
+from flask_login import LoginManager, login_required, current_user # noqa: F401
from flask import render_template, request, Blueprint, flash, redirect, url_for
from werkzeug.routing import ValidationError
@@ -219,7 +219,6 @@ def list_titles():
@route_jobs.route('/json', methods=['GET'])
-@login_required
def feed_json():
"""
json mini API
@@ -228,41 +227,56 @@ def feed_json():
is your call
You can then add a function inside utils to deal with the request
"""
+ # Check if users is authenticated
+ # Return data when authenticated, but allow basic job info when not
+ authenticated = current_user.is_authenticated
mode = str(request.args.get('mode'))
return_json = {'mode': mode, 'success': False}
- # Hold valid data (post/get data) we might receive from pages - not in here ? it's going to throw a key error
- valid_data = {
- 'j_id': request.args.get('job'),
- 'searchq': request.args.get('q'),
- 'logpath': cfg.arm_config['LOGPATH'],
- 'fail': 'fail',
- 'success': 'success',
- 'joblist': 'joblist',
- 'mode': mode,
- 'config_id': request.args.get('config_id'),
- 'notify_id': request.args.get('notify_id'),
- 'notify_timeout': {'funct': json_api.get_notify_timeout, 'args': ('notify_timeout',)},
- 'restart': {'funct': json_api.restart_ui, 'args': ()},
- }
- # Valid modes that should trigger functions
- valid_modes = {
- 'delete': {'funct': json_api.delete_job, 'args': ('j_id', 'mode')},
- 'abandon': {'funct': json_api.abandon_job, 'args': ('j_id',)},
- 'full': {'funct': json_api.generate_log, 'args': ('logpath', 'j_id')},
- 'search': {'funct': json_api.search, 'args': ('searchq',)},
- 'getfailed': {'funct': json_api.get_x_jobs, 'args': ('fail',)},
- 'getsuccessful': {'funct': json_api.get_x_jobs, 'args': ('success',)},
- 'fixperms': {'funct': ui_utils.fix_permissions, 'args': ('j_id',)},
- 'joblist': {'funct': json_api.get_x_jobs, 'args': ('joblist',)},
- 'send_item': {'funct': ui_utils.send_to_remote_db, 'args': ('j_id',)},
- 'change_job_params': {'funct': json_api.change_job_params, 'args': ('config_id',)},
- 'read_notification': {'funct': json_api.read_notification, 'args': ('notify_id',)},
- 'notify_timeout': {'funct': json_api.get_notify_timeout, 'args': ('notify_timeout',)}
- }
+
+ if authenticated:
+ # Hold valid data (post/get data) we might receive from pages - not in here ? it's going to throw a key error
+ valid_data = {
+ 'j_id': request.args.get('job'),
+ 'searchq': request.args.get('q'),
+ 'logpath': cfg.arm_config['LOGPATH'],
+ 'fail': 'fail',
+ 'success': 'success',
+ 'joblist': 'joblist',
+ 'mode': mode,
+ 'config_id': request.args.get('config_id'),
+ 'notify_id': request.args.get('notify_id'),
+ 'notify_timeout': {'funct': json_api.get_notify_timeout, 'args': ('notify_timeout',)},
+ 'restart': {'funct': json_api.restart_ui, 'args': ()},
+ }
+ # Valid modes that should trigger functions
+ valid_modes = {
+ 'delete': {'funct': json_api.delete_job, 'args': ('j_id', 'mode')},
+ 'abandon': {'funct': json_api.abandon_job, 'args': ('j_id',)},
+ 'full': {'funct': json_api.generate_log, 'args': ('logpath', 'j_id')},
+ 'search': {'funct': json_api.search, 'args': ('searchq',)},
+ 'getfailed': {'funct': json_api.get_x_jobs, 'args': ('fail',)},
+ 'getsuccessful': {'funct': json_api.get_x_jobs, 'args': ('success',)},
+ 'fixperms': {'funct': ui_utils.fix_permissions, 'args': ('j_id',)},
+ 'joblist': {'funct': json_api.get_x_jobs, 'args': ('joblist',)},
+ 'send_item': {'funct': ui_utils.send_to_remote_db, 'args': ('j_id',)},
+ 'change_job_params': {'funct': json_api.change_job_params, 'args': ('config_id',)},
+ 'read_notification': {'funct': json_api.read_notification, 'args': ('notify_id',)},
+ 'notify_timeout': {'funct': json_api.get_notify_timeout, 'args': ('notify_timeout',)}
+ }
+ else:
+ valid_data = {
+ 'joblist': 'joblist',
+ }
+ valid_modes = {
+ 'joblist': {'funct': json_api.get_x_jobs, 'args': ('joblist',)},
+ }
+ # prepare JSON data
if mode in valid_modes:
args = [valid_data[x] for x in valid_modes[mode]['args']]
return_json = valid_modes[mode]['funct'](*args)
return_json['notes'] = json_api.get_notifications()
+
+ # return JSON data
return app.response_class(response=json.dumps(return_json, indent=4, sort_keys=True),
status=200,
mimetype=constants.JSON_TYPE)
diff --git a/arm/ui/json_api.py b/arm/ui/json_api.py
index f76585cb0..61a016aa7 100755
--- a/arm/ui/json_api.py
+++ b/arm/ui/json_api.py
@@ -10,6 +10,7 @@
import datetime
import psutil
from flask import request
+from flask_login import current_user
import arm.config.config as cfg
from arm.models.config import Config
@@ -64,8 +65,11 @@ def get_x_jobs(job_status):
if jobs:
app.logger.debug("jobs - we have " + str(len(job_results)) + " jobs")
success = True
- return {"success": success, "mode": job_status,
- "results": job_results, "arm_name": cfg.arm_config['ARM_NAME']}
+ return {"success": success,
+ "mode": job_status,
+ "results": job_results,
+ "arm_name": cfg.arm_config['ARM_NAME'],
+ "authenticated": current_user.is_authenticated}
def process_logfile(logfile, job, job_results):
diff --git a/arm/ui/routes.py b/arm/ui/routes.py
index 05350303a..df61216b3 100644
--- a/arm/ui/routes.py
+++ b/arm/ui/routes.py
@@ -45,7 +45,6 @@
@app.route('/')
@app.route('/index.html')
@app.route('/index')
-@login_required
def home():
"""
The main homepage showing current rips and server stats
@@ -82,7 +81,9 @@ def home():
else:
jobs = {}
- return render_template("index.html", jobs=jobs,
+ return render_template("index.html",
+ authenticated=current_user.is_authenticated,
+ jobs=jobs,
children=cfg.arm_config['ARM_CHILDREN'],
server=server, serverutil=serverutil,
arm_path=arm_path, media_path=media_path, stats=stats)
diff --git a/arm/ui/static/js/common.js b/arm/ui/static/js/common.js
index 621ff8443..b79b1567c 100755
--- a/arm/ui/static/js/common.js
+++ b/arm/ui/static/js/common.js
@@ -28,7 +28,7 @@ function getRipperName(job, idsplit) {
return ripperName;
}
-function addJobItem(job) {
+function addJobItem(job, authenticated) {
// Local server or remote
const idsplit = job.job_id.split("_");
console.log(`${idsplit[1]} - ${idsplit[0]}`)
@@ -44,7 +44,7 @@ function addJobItem(job) {
}
// Section 2 (Middle) Contains Job info (status, type, device, start time, progress)
x += buildMiddleSection(job);
- x += buildRightSection(job, idsplit);
+ x += buildRightSection(job, idsplit, authenticated);
// Close Job.card
x += "
";
return x;
@@ -118,7 +118,7 @@ function buildMiddleSection(job) {
return x;
}
-function buildRightSection(job, idsplit) {
+function buildRightSection(job, idsplit, authenticated) {
let x;
// idsplit[1] should only be undefined on the /database page
if (idsplit[1] === undefined) {
@@ -137,13 +137,19 @@ function buildRightSection(job, idsplit) {
x += `
Max Length: ${job.config.MAXLENGTH}
`;
x += "";
// Section 3 (Right Bottom) Contains Buttons for arm json api
- x += `
-
- View logfile`;
- x += musicCheck(job, idsplit);
- x += ``;
+ // Only show when authenticated
+ x += `
`;
+ if (authenticated === true) {
+ x += `
+
+ View logfile`;
+ x += musicCheck(job, idsplit);
+ x += ``;
+ x += `