mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
Merge pull request #457 from chrismeyersfsu/fix-stdout_dl_token
allow token in get params at stdout endpoint
This commit is contained in:
commit
5e7473e101
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user