🚧 Add logout service
This commit is contained in:
parent
59422e537f
commit
30dc6811c9
24
src/main/java/dev/dinauer/oidcproxy/LogoutService.java
Normal file
24
src/main/java/dev/dinauer/oidcproxy/LogoutService.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package dev.dinauer.oidcproxy;
|
||||||
|
|
||||||
|
import io.vertx.core.http.Cookie;
|
||||||
|
import io.vertx.core.http.HttpServerResponse;
|
||||||
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
|
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||||
|
|
||||||
|
@ApplicationScoped
|
||||||
|
public class LogoutService
|
||||||
|
{
|
||||||
|
private static final String EMPTY = "";
|
||||||
|
|
||||||
|
@ConfigProperty(name = "oidc.proxy.logout.redirect.url")
|
||||||
|
String logoutRedirectUrl;
|
||||||
|
|
||||||
|
public void logout(HttpServerResponse response)
|
||||||
|
{
|
||||||
|
response.addCookie(Cookie.cookie("session", EMPTY).setMaxAge(0).setPath("/").setHttpOnly(true).setSecure(true));
|
||||||
|
response.addCookie(Cookie.cookie("identity", EMPTY).setMaxAge(0).setPath("/").setHttpOnly(false).setSecure(true));
|
||||||
|
response.setStatusCode(302);
|
||||||
|
response.putHeader("Location", logoutRedirectUrl);
|
||||||
|
response.send();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package dev.dinauer.oidcproxy.proxy;
|
package dev.dinauer.oidcproxy.proxy;
|
||||||
|
|
||||||
|
import dev.dinauer.oidcproxy.LogoutService;
|
||||||
import dev.dinauer.oidcproxy.callback.CallbackService;
|
import dev.dinauer.oidcproxy.callback.CallbackService;
|
||||||
import dev.dinauer.oidcproxy.proxy.exception.ProxyHttpException;
|
import dev.dinauer.oidcproxy.proxy.exception.ProxyHttpException;
|
||||||
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
||||||
@ -36,6 +37,9 @@ public class ProxyResource
|
|||||||
@Inject
|
@Inject
|
||||||
CallbackService callbackService;
|
CallbackService callbackService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LogoutService logoutService;
|
||||||
|
|
||||||
@Route(path = "/auth/callback", order = 0)
|
@Route(path = "/auth/callback", order = 0)
|
||||||
@Blocking
|
@Blocking
|
||||||
public void callback(@Context RoutingContext context)
|
public void callback(@Context RoutingContext context)
|
||||||
@ -47,11 +51,7 @@ public class ProxyResource
|
|||||||
@Blocking
|
@Blocking
|
||||||
public void logout(@Context HttpServerResponse response)
|
public void logout(@Context HttpServerResponse response)
|
||||||
{
|
{
|
||||||
response.addCookie(Cookie.cookie("session", "").setMaxAge(0).setPath("/").setHttpOnly(true).setSecure(true));
|
logoutService.logout(response);
|
||||||
response.addCookie(Cookie.cookie("identity", "").setMaxAge(0).setPath("/").setHttpOnly(false).setSecure(true));
|
|
||||||
response.setStatusCode(302);
|
|
||||||
response.putHeader("Location", "http://localhost:3000");
|
|
||||||
response.send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Route(path = "/*", order = 2)
|
@Route(path = "/*", order = 2)
|
||||||
|
|||||||
@ -14,6 +14,8 @@ oidc.proxy.client.redirect=http://localhost:3000
|
|||||||
|
|
||||||
%dev,test.oidc.proxy.crypto.secret=test
|
%dev,test.oidc.proxy.crypto.secret=test
|
||||||
|
|
||||||
|
%dev,test.oidc.proxy.logout.redirect.url=http://localhost:3000
|
||||||
|
|
||||||
%dev,test.quarkus.flyway.clean-at-start=true
|
%dev,test.quarkus.flyway.clean-at-start=true
|
||||||
%dev.quarkus.flyway.locations=db/migration,db/dev
|
%dev.quarkus.flyway.locations=db/migration,db/dev
|
||||||
quarkus.flyway.migrate-at-start=true
|
quarkus.flyway.migrate-at-start=true
|
||||||
Loading…
x
Reference in New Issue
Block a user