allow token in get params at stdout endpoint

This commit is contained in:
Chris Meyers
2015-10-01 13:59:45 -04:00
parent 0bbb294e83
commit 22f0a4b79a
3 changed files with 14 additions and 2 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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