-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove /api/v1 and deprecated credential fields #3413
Changes from all commits
6da445f
2f57a1e
7a0a2fb
5987aaf
51d7de2
6bc5c4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ | |
# AWX | ||
from awx.api.filters import FieldLookupBackend | ||
from awx.main.models import ( | ||
UnifiedJob, UnifiedJobTemplate, User, Role | ||
UnifiedJob, UnifiedJobTemplate, User, Role, Credential | ||
) | ||
from awx.main.access import access_registry | ||
from awx.main.utils import ( | ||
|
@@ -46,7 +46,7 @@ | |
) | ||
from awx.main.utils.db import get_all_field_names | ||
from awx.api.serializers import ResourceAccessListElementSerializer, CopySerializer, UserSerializer | ||
from awx.api.versioning import URLPathVersioning, get_request_version | ||
from awx.api.versioning import URLPathVersioning | ||
from awx.api.metadata import SublistAttachDetatchMetadata, Metadata | ||
|
||
__all__ = ['APIView', 'GenericAPIView', 'ListAPIView', 'SimpleListAPIView', | ||
|
@@ -288,12 +288,6 @@ def get_description(self, request, html=False): | |
template_list.append('api/%s.md' % template_basename) | ||
context = self.get_description_context() | ||
|
||
# "v2" -> 2 | ||
default_version = int(settings.REST_FRAMEWORK['DEFAULT_VERSION'].lstrip('v')) | ||
request_version = get_request_version(self.request) | ||
if request_version is not None and request_version < default_version: | ||
context['deprecated'] = True | ||
|
||
description = render_to_string(template_list, context) | ||
if context.get('deprecated') and context.get('swagger_method') is None: | ||
# render deprecation messages at the very top | ||
|
@@ -842,10 +836,6 @@ class CopyAPIView(GenericAPIView): | |
new_in_330 = True | ||
new_in_api_v2 = True | ||
|
||
def v1_not_allowed(self): | ||
return Response({'detail': 'Action only possible starting with v2 API.'}, | ||
status=status.HTTP_404_NOT_FOUND) | ||
|
||
def _get_copy_return_serializer(self, *args, **kwargs): | ||
if not self.copy_return_serializer_class: | ||
return self.get_serializer(*args, **kwargs) | ||
|
@@ -859,15 +849,15 @@ def _get_copy_return_serializer(self, *args, **kwargs): | |
def _decrypt_model_field_if_needed(obj, field_name, field_val): | ||
if field_name in getattr(type(obj), 'REENCRYPTION_BLACKLIST_AT_COPY', []): | ||
return field_val | ||
if isinstance(field_val, dict): | ||
if isinstance(obj, Credential) and field_name == 'inputs': | ||
for secret in obj.credential_type.secret_fields: | ||
if secret in field_val: | ||
field_val[secret] = decrypt_field(obj, secret) | ||
elif isinstance(field_val, dict): | ||
for sub_field in field_val: | ||
if isinstance(sub_field, str) \ | ||
and isinstance(field_val[sub_field], str): | ||
try: | ||
field_val[sub_field] = decrypt_field(obj, field_name, sub_field) | ||
except AttributeError: | ||
# Catching the corner case with v1 credential fields | ||
field_val[sub_field] = decrypt_field(obj, sub_field) | ||
field_val[sub_field] = decrypt_field(obj, field_name, sub_field) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are some 🐉 s here. Was there really a different means of encryption for credentials created from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🐉🐉🐉🐉🐉 indeed, and this is definitely the type of thing where I'd like to see what falls out to integration. So up until now, we've relied on I can't recall the details now (I wrote this in ~March), but I ended up having to do this as a way to make this work now that It's possible there's a better way to do this, though. |
||
elif isinstance(field_val, str): | ||
try: | ||
field_val = decrypt_field(obj, field_name) | ||
|
@@ -952,8 +942,6 @@ def copy_model_obj(old_parent, new_parent, model, obj, creater, copy_name='', cr | |
return ret | ||
|
||
def get(self, request, *args, **kwargs): | ||
if get_request_version(request) < 2: | ||
return self.v1_not_allowed() | ||
obj = self.get_object() | ||
if not request.user.can_access(obj.__class__, 'read', obj): | ||
raise PermissionDenied() | ||
|
@@ -968,8 +956,6 @@ def get(self, request, *args, **kwargs): | |
return Response({'can_copy': can_copy}) | ||
|
||
def post(self, request, *args, **kwargs): | ||
if get_request_version(request) < 2: | ||
return self.v1_not_allowed() | ||
obj = self.get_object() | ||
create_kwargs = self._build_create_dict(obj) | ||
create_kwargs_check = {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to check that the UI TEMPLATES view isn't showing any of these keys, and it seems that it does not, so good there.