mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 19:50:05 -03:30
allow token in get params at stdout endpoint
This commit is contained in:
@@ -90,6 +90,17 @@ class TokenAuthentication(authentication.TokenAuthentication):
|
|||||||
# Return the user object and the token.
|
# Return the user object and the token.
|
||||||
return (token.user, token)
|
return (token.user, token)
|
||||||
|
|
||||||
|
|
||||||
|
class TokenGetAuthentication(TokenAuthentication):
|
||||||
|
|
||||||
|
def authenticate(self, request):
|
||||||
|
if request.method.lower() == 'get':
|
||||||
|
token = request.GET.get('token', None)
|
||||||
|
if token:
|
||||||
|
request.META['HTTP_X_AUTH_TOKEN'] = 'Token %s' % token
|
||||||
|
return super(TokenGetAuthentication, self).authenticate(request)
|
||||||
|
|
||||||
|
|
||||||
class TaskAuthentication(authentication.BaseAuthentication):
|
class TaskAuthentication(authentication.BaseAuthentication):
|
||||||
'''
|
'''
|
||||||
Custom authentication used for views accessed by the inventory and callback
|
Custom authentication used for views accessed by the inventory and callback
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ from awx.main.task_engine import TaskSerializer, TASK_FILE, TEMPORARY_TASK_FILE
|
|||||||
from awx.main.tasks import mongodb_control
|
from awx.main.tasks import mongodb_control
|
||||||
from awx.main.access import get_user_queryset
|
from awx.main.access import get_user_queryset
|
||||||
from awx.main.ha import is_ha_environment
|
from awx.main.ha import is_ha_environment
|
||||||
from awx.api.authentication import TaskAuthentication
|
from awx.api.authentication import TaskAuthentication, TokenGetAuthentication
|
||||||
from awx.api.utils.decorators import paginated
|
from awx.api.utils.decorators import paginated
|
||||||
from awx.api.filters import MongoFilterBackend
|
from awx.api.filters import MongoFilterBackend
|
||||||
from awx.api.generics import get_view_name
|
from awx.api.generics import get_view_name
|
||||||
@@ -2805,6 +2805,7 @@ class UnifiedJobList(ListAPIView):
|
|||||||
|
|
||||||
class UnifiedJobStdout(RetrieveAPIView):
|
class UnifiedJobStdout(RetrieveAPIView):
|
||||||
|
|
||||||
|
authentication_classes = [TokenGetAuthentication] + api_settings.DEFAULT_AUTHENTICATION_CLASSES
|
||||||
serializer_class = UnifiedJobStdoutSerializer
|
serializer_class = UnifiedJobStdoutSerializer
|
||||||
renderer_classes = [BrowsableAPIRenderer, renderers.StaticHTMLRenderer,
|
renderer_classes = [BrowsableAPIRenderer, renderers.StaticHTMLRenderer,
|
||||||
PlainTextRenderer, AnsiTextRenderer,
|
PlainTextRenderer, AnsiTextRenderer,
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ class AuthToken(BaseModel):
|
|||||||
def reason_long(reason):
|
def reason_long(reason):
|
||||||
for x in AuthToken.REASON_CHOICES:
|
for x in AuthToken.REASON_CHOICES:
|
||||||
if x[0] == reason:
|
if x[0] == reason:
|
||||||
return x[1]
|
return unicode(x[1])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user