Skip to content

Commit b1c46db

Browse files
committed
Redirect back to application after authorizing.
1 parent 8cf919c commit b1c46db

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

oauth/src/main/java/ch/cyberduck/core/oauth/LoopbackOAuth2AuthorizationCodeProvider.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@
2727

2828
import org.apache.commons.io.IOUtils;
2929
import org.apache.commons.lang3.StringUtils;
30+
import org.apache.http.HttpHeaders;
3031
import org.apache.http.NameValuePair;
3132
import org.apache.http.client.utils.URLEncodedUtils;
3233
import org.apache.logging.log4j.LogManager;
3334
import org.apache.logging.log4j.Logger;
3435

3536
import java.io.IOException;
36-
import java.io.OutputStream;
3737
import java.net.InetSocketAddress;
3838
import java.net.URI;
3939
import java.nio.charset.Charset;
40-
import java.nio.charset.StandardCharsets;
4140
import java.util.List;
4241
import java.util.concurrent.CountDownLatch;
4342
import java.util.concurrent.Executors;
@@ -87,12 +86,8 @@ public void handle(final HttpExchange exchange) throws IOException {
8786
}
8887
final OAuth2TokenListenerRegistry oauth = OAuth2TokenListenerRegistry.get();
8988
if(oauth.notify(state, code)) {
90-
final String response = "<!DOCTYPE html><html><body><script>window.close();</script></body></html>";
91-
exchange.getResponseHeaders().add("Content-Type", "text/html; charset=UTF-8");
92-
exchange.sendResponseHeaders(200, response.getBytes(StandardCharsets.UTF_8).length);
93-
try(final OutputStream os = exchange.getResponseBody()) {
94-
os.write(response.getBytes(StandardCharsets.UTF_8));
95-
}
89+
exchange.getResponseHeaders().add(HttpHeaders.LOCATION, OAuth2AuthorizationService.CYBERDUCK_REDIRECT_URI);
90+
exchange.sendResponseHeaders(302, 0L);
9691
}
9792
else {
9893
exchange.sendResponseHeaders(400, 0);

0 commit comments

Comments
 (0)