Remove scope code

The scope code is left over from when the project was using Swagger to
create the API. This code is not fully implemented and is not being used
and so can be removed.

Change-Id: Ie61b679eadb8868224a3f2f2bf0a93b57d16e980
This commit is contained in:
git-harry 2017-01-24 12:57:56 +00:00
parent 8065361eb1
commit 90ccf011f3
4 changed files with 1 additions and 65 deletions

View File

@ -2,12 +2,6 @@ from flask import Blueprint
import flask_restful as restful
from craton.api.v1.routes import routes
from craton.api.v1.validators import security
@security.scopes_loader
def current_scopes():
return []
bp = Blueprint('v1', __name__)

View File

@ -2206,33 +2206,3 @@ filters = {
},
},
}
scopes = {
("hosts_id_variables", "PUT"): [],
("hosts_id_variables", "DELETE"): [],
("hosts_id", "PUT"): [],
("hosts_id", "DELETE"): [],
("regions", "GET"): [],
("regions_id_variables", "PUT"): [],
("regions_id_variables", "DELETE"): [],
("hosts", "POST"): [],
("hosts", "GET"): [],
("cells_id", "PUT"): [],
("cells_id", "DELETE"): [],
("cells", "POST"): [],
("cells", "GET"): [],
("regions_id", "PUT"): [],
("cells_id_variables", "PUT"): [],
("cells_id_variables", "DELETE"): [],
("projects", "GET"): [],
("projects_id", "GET"): [],
("projects_id", "DELETE"): [],
("projects", "POST"): [],
("users", "GET"): [],
("users", "POST"): [],
("users_id", "GET"): [],
("network_devices_id_variables", "PUT"): [],
("network_devices_id_variables", "DELETE"): [],
("networks_id_variables", "PUT"): [],
("networks_id_variables", "DELETE"): [],
}

View File

@ -12,7 +12,6 @@ from jsonschema import Draft4Validator
from oslo_log import log
from craton.api.v1.schemas import filters
from craton.api.v1.schemas import scopes
from craton.api.v1.schemas import validators
from craton import db as dbapi
from craton import exceptions
@ -21,24 +20,6 @@ from craton import exceptions
LOG = log.getLogger(__name__)
class Security(object):
def __init__(self):
super(Security, self).__init__()
self._loader = lambda: []
@property
def scopes(self):
return self._loader()
def scopes_loader(self, func):
self._loader = func
return func
security = Security()
def merge_default(schema, value):
# TODO: more types support
type_defaults = {
@ -221,11 +202,6 @@ def request_validate(view):
@wraps(view)
def wrapper(*args, **kwargs):
endpoint = request.endpoint.partition('.')[-1]
# scope
if (endpoint, request.method) in scopes and not set(
scopes[(endpoint,
request.method)]).issubset(set(security.scopes)):
abort(403)
# data
method = request.method
if method == 'HEAD':

View File

@ -1,7 +1,7 @@
import jsonschema
from craton import api
from craton.api.v1.schemas import filters, validators, scopes
from craton.api.v1.schemas import filters, validators
from craton.tests import TestCase
@ -172,10 +172,6 @@ def generate_endpoint_method_validation_functions(cls):
endpoint = "v1.{}".format(_endpoint)
gen_test('filters', endpoint, method)
for (_endpoint, method) in scopes:
endpoint = "v1.{}".format(_endpoint)
gen_test('scopes', endpoint, method)
generate_endpoint_method_validation_functions(TestSchemaLocationInRoute)