RewriteRule в apache httpd-vhosts.conf не работает для приложения Grails - PullRequest
0 голосов
/ 14 февраля 2020

Нам нужно было добавить правило перезаписи для URL-адресов аутентификации этого проекта grails при локальной настройке -

ServerName dev.app.com





 RewriteEngine on

        RewriteRule   "^/service/um/(.+)"  "https://sandboxapp.com/service/um/$1"  [L,R=307]

Это работает нормально, как проверено с помощью команды curl -

curl --location --request POST 'http://dev.app.com/oauth/token' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'client_id=<clientID>' --data-urlencode 'client_secret=<clientSecret>' --data-urlencode 'grant_type=implicit'

Однако, когда тот же API вызывается через приложение, появляется пустой ответ. Предоставлено подробности ниже.

Следующее есть в наших ресурсах. groovy -

oauthHttpClient(wslite.http.HTTPClient) {
    connectTimeout = 30000
    readTimeout = 30000
    useCaches = false
    followRedirects = true
    sslTrustAllCerts = true
}
oauthRestClient(wslite.rest.RESTClient) {
    println Holders.config."$Holders.config.project.env".oAuth.baseURL
    url =  Holders.config."$Holders.config.project.env".oAuth.baseURL 
    httpClient = ref('oauthHttpClient')
}

Этот параметр URL настроен на http://dev.app.com/ во внешнем файле конфигурации. groovy файл хранится в каталоге .grails.

Вызов API выглядит следующим образом -

authResponse = restClient.post(path: "oauth/token") {
                charset "UTF-8"
                urlenc(
                        client_id: Holders.config."$Holders.config.project.env".oAuthMemberInfo?.client_id,
                        client_secret: Holders.config."$Holders.config.project.env".oAuthMemberInfo?.client_secret,
                        grant_type: "implicit"
                )

Однако, когда тот же API вызывается через, application, атрибуты authResponse равны нулю (ожидается access_token param ) и сам authResponse печатает -

<wslite.rest.Response@3af22827 expiration=Thu Jan 01 05:30:00 IST 1970 statusMessage=Temporary Redirect charset=iso-8859-1 date=Fri Feb 14 17:50:36 IST 2020 contentLength=256 lastModified=Thu Jan 01 05:30:00 IST 1970 url=http://dev.app.com/oauth/token statusCode=307 headers={=HTTP/1.1 307 Temporary Redirect, Connection=close, Content-Length=256, Content-Type=text/html; charset=iso-8859-1, Date=Fri, 14 Feb 2020 12:20:36 GMT, Location=https://sandboxapp.com/oauth/token, Server=Apache/2.4.34 (Unix)} contentEncoding=null contentType=text/html request=<wslite.http.HTTPRequest@18ef84c3 sslTrustAllCerts=false proxy=null useCaches=false followRedirects=true sslTrustStoreFile=null url=http://dev.app.com/oauth/token headers={Content-Type=application/x-www-form-urlencoded; charset=UTF-8} readTimeout=0 connectTimeout=0 method=POST>>

Я вижу тот же журнал перенаправления 307 в журнале apache, как это происходит при выполнении команды curl для dev.app.com.

...