Validate and store redirect URIs for client.
193736
def redirect_uris(self, value):
        """"""
        if isinstance(value, six.text_type):
            value = value.split("\n")

        value = [v.strip() for v in value]

        for v in value:
            validate_redirect_uri(v)

        self._redirect_uris = "\n".join(value) or ""
1059066
def resolve_redirection(self, request, context):
        """"""
        current_page = context['current_page']
        lang = context['lang']
        if current_page.redirect_to_url:
            return HttpResponsePermanentRedirect(current_page.redirect_to_url)

        if current_page.redirect_to:
            return HttpResponsePermanentRedirect(
                current_page.redirect_to.get_url_path(lang))
363772
def get_redirect_url(self, request, callback, parameters=None):
        """"""
        args = self.get_redirect_args(request, callback=callback)
        additional = parameters or {}
        args.update(additional)
        params = urlencode(args)
        return '{0}?{1}'.format(self.authorization_url, params)
1180590
def _process_redirect(self):
        ''''''
        _logger.debug('Handling redirect.')

        if self._redirect_tracker.exceeded():
            raise ProtocolError('Too many redirects.')

        try:
            url = self._redirect_tracker.next_location()

            if not url:
                raise ProtocolError('Redirect location missing.')

            if self._redirect_tracker.is_repeat():
                _logger.debug('Got redirect is repeat.')

                request = self._original_request.copy()
                request.url = url
            else:
                request = self._request_factory(url)

            request.prepare_for_send()
        except ValueError as error:
            raise ProtocolError('Invalid redirect location.') from error

        self._next_request = request

        _logger.debug('Updated next redirect request to {0}.'.format(request))
886870
def authorization_link(self, redirect_uri):
        '''
        '''
        args = '?client_id=%s&redirect_uri=%s' % (
            self.app_key,
            redirect_uri
        )
        uri = "/".join([BASE_URL, API_VERSION, OAUTH, args])
        return uri
1008890
def get_redirect_target(self, resp):
        """"""
        # Due to the nature of how requests processes redirects this method will
        # be called at least once upon the original response and at least twice
        # on each subsequent redirect response (if any).
        # If a custom mixin is used to handle this logic, it may be advantageous
        # to cache the redirect location onto the response object as a private
        # attribute.
        if resp.is_redirect:
            location = resp.headers['location']
            # Currently the underlying http module on py3 decode headers
            # in latin1, but empirical evidence suggests that latin1 is very
            # rarely used with non-ASCII characters in HTTP headers.
            # It is more likely to get UTF8 header rather than latin1.
            # This causes incorrect handling of UTF8 encoded location headers.
            # To solve this, we re-encode the location in latin1.
            if is_py3:
                location = location.encode('latin1')
            return to_native_string(location, 'utf8')
        return None
939550
private function compareUris($redirect_uri, $clientRedirectUri)
    {
        if (!$redirect_uri || !$clientRedirectUri) {
            return false;
        }

        $wanted = array_fill_keys(['scheme', 'host', 'port', 'path'], true);

        // gets only scheme, host, port, path from uri
        $redirect_uri = array_intersect_key(parse_url($redirect_uri), $wanted);
        $clientRedirectUri = array_intersect_key(parse_url($clientRedirectUri), $wanted);

        return strcmp(implode($redirect_uri), implode($clientRedirectUri)) === 0;
    }
47599
def clean_redirect_uri(self):
        
        redirect_uri = self.cleaned_data.get('redirect_uri')

        if redirect_uri:
            if not redirect_uri == self.client.redirect_uri:
                raise OAuthValidationError({
                    'error': 'invalid_request',
                    'error_description': _("The requested redirect didn't "
                        "match the client settings.")})

        return redirect_uri
693553
def _validateurl(self, url):
        """"""
        parsed = urlparse(url)
        path = parsed.path.strip("/")
        if path:
            parts = path.split("/")
            url_types = ("admin", "manager", "rest")
            if any(i in parts for i in url_types):
                while parts.pop() not in url_types:
                    next
            elif "services" in parts:
                while parts.pop() not in "services":
                    next
            path = "/".join(parts)
        else:
            path = "arcgis"
        self._adminUrl = "%s://%s/%s/admin" % (parsed.scheme, parsed.netloc, path)
        return "%s://%s/%s/rest/services" % (parsed.scheme, parsed.netloc, path)
1106624
def checkURL(cls, trust_root, url):
        """"""
        tr = cls.parse(trust_root)
        return tr is not None and tr.validateURL(url)
226353
def _RedirectToRemoteHelp(self, path):
    """"""
    allowed_chars = set(string.ascii_letters + string.digits + "._-/")
    if not set(path) <= allowed_chars:
      raise RuntimeError("Unusual chars in path %r - "
                         "possible exploit attempt." % path)

    target_path = os.path.join(config.CONFIG["AdminUI.docs_location"], path)

    # We have to redirect via JavaScript to have access to and to preserve the
    # URL hash. We don't know the hash part of the url on the server.
    return werkzeug_wrappers.Response(
        """
<script>
var friendly_hash = window.location.hash;
window.location = '%s' + friendly_hash;
</script>
""" % target_path,
        mimetype="text/html")
1332929
def redirect(url, code=None):
    
    if not code:
        code = 303 if request.get('SERVER_PROTOCOL') == "HTTP/1.1" else 302
    res = response.copy(cls=HTTPResponse)
    res.status = code
    res.body = ""
    res.set_header('Location', urljoin(request.url, url))
    raise res
494381
function redirectToNext(req, res) {
  var redirectTo = req.session.next || '';
  req.session.next = null; // Null it so that we do not use it again.
  res.redirect(redirectTo);
}
1094294
protected function mergeRedirect()
    {
        if (!empty($this->redirect)) {
            $this->data = array_merge_recursive($this->data, array('redirect_uri' => $this->redirect));
        }
    }
178072
function redirect(url, response) {
    const header  = {
        'Location': url
    };
    
    assert(url, 'url could not be empty!');
    assert(response, 'response could not be empty!');
    
    fillHeader(header, response);
    response.statusCode = MOVED_PERMANENTLY;
    response.end();
}
4605
def get_redirect_args(self, request, callback):
        ""
        callback = force_text(request.build_absolute_uri(callback))
        raw_token = self.get_request_token(request, callback)
        token, secret = self.parse_raw_token(raw_token)
        if token is not None and secret is not None:
            request.session[self.session_key] = raw_token
        return {
            'oauth_token': token,
            'oauth_callback': callback,
        }
651336
def resource_redirect(id):
    '''
    
    '''
    resource = get_resource(id)
    return redirect(resource.url.strip()) if resource else abort(404)