Example #1
0
    def authenticate(self, request):
        if request.META['PATH_INFO'] in settings.SKIP_OAUTH:
            log.debug('Skipping OAuth because of SKIP_OAUTH')
            return (DummyUser(), None)

        auth_header_value = request.META.get('HTTP_AUTHORIZATION', None)
        request.OAUTH_KEY = None
        oauth_server, oauth_request = initialize_oauth_server_request(request)
        try:
            key = get_oauth_consumer_key_from_header(auth_header_value)
            if not key:
                if settings.REQUIRE_OAUTH:
                    log.error(u'No key to: {0}'.format(request.path))
                    return AuthenticationFailed
                return (DummyUser(), None)
            oauth_server.verify_request(oauth_request, Consumer(key), None)
            request.OAUTH_KEY = key
            set_oauth_key(key)
            log.info(u'Access granted for: {0}, to: {1}'.format(
                key, request.path))
            return (DummyUser(), None)

        except KeyError:
            log.error(u'No key to: {0}'.format(request.path))
            return AuthenticationFailed

        except:
            log.error(u'Access failed for: {0}, to: {1}'.format(
                key, request.path),
                      exc_info=True)
            return AuthenticationFailed
Example #2
0
    def is_authenticated(self, request, **kwargs):
        if request.META['PATH_INFO'] in settings.SKIP_OAUTH:
            log.debug('Skipping OAuth because of SKIP_OAUTH')
            return True

        auth_header_value = self._header(request)
        request.OAUTH_KEY = None
        oauth_server, oauth_request = initialize_oauth_server_request(request)
        try:
            key = get_oauth_consumer_key_from_header(auth_header_value)
            if not key:
                if settings.REQUIRE_OAUTH:
                    log.error(u'No key to: {0}'.format(request.path))
                    return False
                return True
            oauth_server.verify_request(oauth_request, Consumer(key), None)
            request.OAUTH_KEY = key
            set_oauth_key(key)
            log.info(u'Access granted for: {0}, to: {1}'.format(
                key, request.path))
            return True

        except KeyError:
            log.error(u'No key to: {0}'.format(request.path))
            return False

        except:
            log.error(u'Access failed for: {0}, to: {1}'.format(
                key, request.path),
                      exc_info=True)
            return False
Example #3
0
    def authenticate(self, request):
        if request.META['PATH_INFO'] in settings.SKIP_OAUTH:
            log.debug('Skipping OAuth because of SKIP_OAUTH')
            return (DummyUser(), None)

        auth_header_value = request.META.get('HTTP_AUTHORIZATION', None)
        request.OAUTH_KEY = None
        oauth_server, oauth_request = initialize_oauth_server_request(request)
        try:
            key = get_oauth_consumer_key_from_header(auth_header_value)
            if not key:
                if settings.REQUIRE_OAUTH:
                    log.error(u'No key to: {0}'.format(request.path))
                    return AuthenticationFailed
                return (DummyUser(), None)
            oauth_server.verify_request(oauth_request, Consumer(key), None)
            request.OAUTH_KEY = key
            set_oauth_key(key)
            # Logging all the nagios hits to /services/request/ is noisy.
            log_level = (log.debug if request.path == '/services/request/'
                         else log.info)
            log_level(u'Access granted for: {0}, to: {1}'
                      .format(key, request.path))
            return (DummyUser(), None)

        except KeyError:
            log.error(u'No key to: {0}'.format(request.path))
            return AuthenticationFailed

        except:
            log.error(u'Access failed for: {0}, to: {1}'
                      .format(key, request.path),
                      exc_info=True)
            return AuthenticationFailed
Example #4
0
    def is_authenticated(self, request, **kwargs):
        if request.META['PATH_INFO'] in settings.SKIP_OAUTH:
            log.debug('Skipping OAuth because of SKIP_OAUTH')
            return True

        auth_header_value = self._header(request)
        request.OAUTH_KEY = None
        oauth_server, oauth_request = initialize_oauth_server_request(request)
        try:
            key = get_oauth_consumer_key_from_header(auth_header_value)
            if not key:
                if settings.REQUIRE_OAUTH:
                    log.error(u'No key to: {0}'.format(request.path))
                    return False
                return True
            oauth_server.verify_request(oauth_request, Consumer(key), None)
            request.OAUTH_KEY = key
            set_oauth_key(key)
            log.info(u'Access granted for: {0}, to: {1}'
                     .format(key, request.path))
            return True

        except KeyError:
            log.error(u'No key to: {0}'.format(request.path))
            return False

        except:
            log.error(u'Access failed for: {0}, to: {1}'
                      .format(key, request.path),
                      exc_info=True)
            return False
Example #5
0
    def authenticate(self, request):
        auth_header_value = request.META.get('HTTP_AUTHORIZATION', None)
        request.OAUTH_KEY = None
        oauth_server, oauth_request = initialize_oauth_server_request(request)
        try:
            key = get_oauth_consumer_key_from_header(auth_header_value)
            if not key:
                if settings.REQUIRE_OAUTH:
                    log.error(u'No key.')
                    return None
                return (DummyUser(), None)
            oauth_server.verify_request(oauth_request, Consumer(key), None)
            request.OAUTH_KEY = key
            set_oauth_key(key)
            log.info(u'Access granted: %s' % key)
            return (DummyUser(), None)

        except KeyError:
            log.error(u'No key: %s' % key)
            return AuthenticationFailed

        except:
            log.error(u'Access failed: %s' % key, exc_info=True)
            return AuthenticationFailed
Example #6
0
    def is_authenticated(self, request, **kwargs):
        auth_header_value = self._header(request)
        request.OAUTH_KEY = None
        oauth_server, oauth_request = initialize_oauth_server_request(request)
        try:
            key = get_oauth_consumer_key_from_header(auth_header_value)
            if not key:
                if settings.REQUIRE_OAUTH:
                    log.error(u'No key.')
                    return False
                return True
            oauth_server.verify_request(oauth_request, Consumer(key), None)
            request.OAUTH_KEY = key
            set_oauth_key(key)
            log.info(u'Access granted: %s' % key)
            return True

        except KeyError:
            log.error(u'No key: %s' % key)
            return False

        except:
            log.error(u'Access failed: %s' % key, exc_info=True)
            return False
Example #7
0
    def authenticate(self, request):
        auth_header_value = request.META.get('HTTP_AUTHORIZATION', None)
        request.OAUTH_KEY = None
        oauth_server, oauth_request = initialize_oauth_server_request(request)
        try:
            key = get_oauth_consumer_key_from_header(auth_header_value)
            if not key:
                if settings.REQUIRE_OAUTH:
                    log.error(u'No key.')
                    return None
                return (DummyUser(), None)
            oauth_server.verify_request(oauth_request, Consumer(key), None)
            request.OAUTH_KEY = key
            set_oauth_key(key)
            log.info(u'Access granted: %s' % key)
            return (DummyUser(), None)

        except KeyError:
            log.error(u'No key: %s' % key)
            return AuthenticationFailed

        except:
            log.error(u'Access failed: %s' % key, exc_info=True)
            return AuthenticationFailed
Example #8
0
    def is_authenticated(self, request, **kwargs):
        auth_header_value = self._header(request)
        request.OAUTH_KEY = None
        oauth_server, oauth_request = initialize_oauth_server_request(request)
        try:
            key = get_oauth_consumer_key_from_header(auth_header_value)
            if not key:
                if settings.REQUIRE_OAUTH:
                    log.error(u'No key.')
                    return False
                return True
            oauth_server.verify_request(oauth_request, Consumer(key), None)
            request.OAUTH_KEY = key
            set_oauth_key(key)
            log.info(u'Access granted: %s' % key)
            return True

        except KeyError:
            log.error(u'No key: %s' % key)
            return False

        except:
            log.error(u'Access failed: %s' % key, exc_info=True)
            return False