Merge pull request #457 from chrismeyersfsu/fix-stdout_dl_token

allow token in get params at stdout endpoint
This commit is contained in:
Chris Meyers 2015-10-02 08:59:07 -04:00
commit 5e7473e101
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 (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):
'''
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.access import get_user_queryset
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.filters import MongoFilterBackend
from awx.api.generics import get_view_name
@ -2805,6 +2805,7 @@ class UnifiedJobList(ListAPIView):
class UnifiedJobStdout(RetrieveAPIView):
authentication_classes = [TokenGetAuthentication] + api_settings.DEFAULT_AUTHENTICATION_CLASSES
serializer_class = UnifiedJobStdoutSerializer
renderer_classes = [BrowsableAPIRenderer, renderers.StaticHTMLRenderer,
PlainTextRenderer, AnsiTextRenderer,

View File

@ -210,7 +210,7 @@ class AuthToken(BaseModel):
def reason_long(reason):
for x in AuthToken.REASON_CHOICES:
if x[0] == reason:
return x[1]
return unicode(x[1])
return None
@classmethod