@api_app.before_request def check_valid_login(): # Allow access to root, login and swagger documentation without authentication if request.path == '/' or request.path.startswith('/auth/login') or \ request.path.startswith('/auth/logout') or request.path.startswith('/swagger') or \ request.method == 'OPTIONS': return if not current_user.is_authenticated: return current_app.login_manager.unauthorized() # API Authentication and Authorization auth_api = api.namespace('auth', description='Authentication') login_api_schema = api.schema('auth.login', { 'type': 'object', 'properties': { 'username': {'type': 'string'}, 'password': {'type': 'string'} }, 'required': ['username', 'password'], 'additionalProperties': False }) login_parser = api.parser() login_parser.add_argument('remember', type=inputs.boolean, required=False, default=False, help='Remember login (sets persistent session cookies)')
return session.query(User).filter(User.name == username).first() @api_app.before_request def check_valid_login(): # Allow access to root, login and swagger documentation without authentication if request.path == '/' or request.path.startswith('/auth/login') or \ request.path.startswith('/auth/logout') or request.path.startswith('/swagger'): return if not current_user.is_authenticated: return current_app.login_manager.unauthorized() # API Authentication and Authorization auth_api = api.namespace('auth', description='Authentication') login_api_schema = api.schema('auth.login', { 'type': 'object', 'properties': { 'username': {'type': 'string'}, 'password': {'type': 'string'} }, 'required': ['username', 'password'], 'additionalProperties': False }) login_parser = api.parser() login_parser.add_argument('remember', type=inputs.boolean, required=False, default=False, help='Remember login (sets persistent session cookies)')
import logging from datetime import datetime, timedelta from math import ceil from flask import jsonify, request from flask_restplus import inputs from flexget.api.app import NotFoundError, etag, pagination_headers, api, APIResource from flexget.api.core.tasks import tasks_api from sqlalchemy.orm.exc import NoResultFound from . import db log = logging.getLogger('status_api') status_api = api.namespace('status', description='View and manage task execution status') class ObjectsContainer(object): task_status_execution_schema = { 'type': 'object', 'properties': { 'abort_reason': { 'type': ['string', 'null'] }, 'accepted': { 'type': 'integer' }, 'end': { 'type': 'string', 'format': 'date-time'
from builtins import * # noqa pylint: disable=unused-import, redefined-builtin import logging from datetime import datetime, timedelta from math import ceil from flask import jsonify, request from flask_restplus import inputs from flexget.api.app import NotFoundError, etag, pagination_headers, api, APIResource from flexget.api.core.tasks import tasks_api from flexget.plugins.operate.status import StatusTask, TaskExecution, get_executions_by_task_id, get_status_tasks from sqlalchemy.orm.exc import NoResultFound log = logging.getLogger('status_api') status_api = api.namespace('status', description='View and manage task execution status') class ObjectsContainer(object): task_status_execution_schema = { 'type': 'object', 'properties': { 'abort_reason': {'type': ['string', 'null']}, 'accepted': {'type': 'integer'}, 'end': {'type': 'string', 'format': 'date-time'}, 'failed': {'type': 'integer'}, 'id': {'type': 'integer'}, 'produced': {'type': 'integer'}, 'rejected': {'type': 'integer'}, 'start': {'type': 'string', 'format': 'date-time'}, 'succeeded': {'type': 'boolean'},