|
20 | 20 |
|
21 | 21 | import org.springframework.web.servlet.ModelAndView; |
22 | 22 |
|
| 23 | +import java.net.URI; |
23 | 24 | import java.net.URISyntaxException; |
24 | 25 | import java.util.HashSet; |
25 | 26 | import java.util.Map; |
@@ -139,14 +140,24 @@ protected ModelAndView redirectToApproveView(final JEEContext context, final Osf |
139 | 140 | */ |
140 | 141 | protected String getCallbackUrl(final JEEContext context) throws URISyntaxException { |
141 | 142 | val callbackUrl = context.getFullRequestURL(); |
| 143 | + val serverPrefix = casProperties.getServer().getPrefix(); |
| 144 | + if (!callbackUrl.startsWith(serverPrefix)) { |
| 145 | + LOGGER.warn("[OAuth ConsentApproval] callback URL [{}] doesn't have the correct server prefix [{}]", callbackUrl, serverPrefix); |
| 146 | + } else { |
| 147 | + LOGGER.info("[OAuth ConsentApproval] callback URL [{}] uses the correct server prefix [{}]", callbackUrl, serverPrefix); |
| 148 | + } |
| 149 | + val serverPrefixUrl = new URI(serverPrefix); |
142 | 150 | val url = new URIBuilder(callbackUrl); |
| 151 | + url.setScheme(serverPrefixUrl.getScheme()); |
| 152 | + url.setHost(serverPrefixUrl.getHost()); |
| 153 | + url.setPort(-1); |
143 | 154 | // APPROVAL_PROMPT can be set to any value. It does not have any effect since BYPASS_APPROVAL_PROMPT is present. |
144 | 155 | // However, setting it to EMPTY is preferred so that it is different from its original values "auto" or "force". |
145 | 156 | url.setParameter(OsfCasOAuth20Constants.APPROVAL_PROMPT, StringUtils.EMPTY); |
146 | 157 | url.setParameter(OAuth20Constants.BYPASS_APPROVAL_PROMPT, Boolean.TRUE.toString()); |
147 | | - LOGGER.debug("Callback URL for approval submit action: [{}]", callbackUrl); |
148 | | - return url.toString(); |
149 | | - |
| 158 | + val approvalCallbackUrl = url.toString(); |
| 159 | + LOGGER.info("[OAuth ConsentApproval] modified approval callback URL [{}]", approvalCallbackUrl); |
| 160 | + return approvalCallbackUrl; |
150 | 161 | } |
151 | 162 |
|
152 | 163 | /** |
|
0 commit comments