mirror of
https://github.com/ansible/awx.git
synced 2026-02-03 18:48:12 -03:30
* Remove oauth provider This removes the oauth provider functionality from awx. The oauth2_provider app and all references to it have been removed. Migrations to delete the two tables that locally overwrote oauth2_provider tables are included. This change does not include migrations to delete the tables provided by the oauth2_provider app. Also not included here are changes to awxkit, awx_collection or the ui. * Fix linters * Update migrations after rebase * Update collection tests for auth changes The changes in https://github.com/ansible/awx/pull/15554 will cause a few collection tests to fail, depending on what the test configuration is. This changes the tests to look for a specific warning rather than counting the number of warnings emitted. * Update migration * Removed unused oauth_scopes references --------- Co-authored-by: Mike Graves <mgraves@redhat.com> Co-authored-by: Alan Rominger <arominge@redhat.com>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
# Copyright (c) 2015 Ansible, Inc.
|
|
# All Rights Reserved.
|
|
|
|
# Python
|
|
import logging
|
|
|
|
# Django
|
|
from django.conf import settings
|
|
from django.utils.encoding import smart_str
|
|
|
|
# Django REST Framework
|
|
from rest_framework import authentication
|
|
|
|
logger = logging.getLogger('awx.api.authentication')
|
|
|
|
|
|
class LoggedBasicAuthentication(authentication.BasicAuthentication):
|
|
def authenticate(self, request):
|
|
if not settings.AUTH_BASIC_ENABLED:
|
|
return
|
|
ret = super(LoggedBasicAuthentication, self).authenticate(request)
|
|
if ret:
|
|
username = ret[0].username if ret[0] else '<none>'
|
|
logger.info(smart_str(u"User {} performed a {} to {} through the API".format(username, request.method, request.path)))
|
|
return ret
|
|
|
|
def authenticate_header(self, request):
|
|
if not settings.AUTH_BASIC_ENABLED:
|
|
return
|
|
return super(LoggedBasicAuthentication, self).authenticate_header(request)
|
|
|
|
|
|
class SessionAuthentication(authentication.SessionAuthentication):
|
|
def authenticate_header(self, request):
|
|
return 'Session'
|