🚧 Bugfix with HTTP Client
This commit is contained in:
parent
0e4fab6995
commit
7216a2f346
@ -6,6 +6,7 @@ import dev.dinauer.oidcproxy.proxy.ForwardService;
|
|||||||
import dev.dinauer.oidcproxy.proxy.ResponseHandler;
|
import dev.dinauer.oidcproxy.proxy.ResponseHandler;
|
||||||
import dev.dinauer.oidcproxy.proxy.TimedHttpResponse;
|
import dev.dinauer.oidcproxy.proxy.TimedHttpResponse;
|
||||||
import dev.dinauer.oidcproxy.proxy.exception.ProxyHttpException;
|
import dev.dinauer.oidcproxy.proxy.exception.ProxyHttpException;
|
||||||
|
import dev.dinauer.oidcproxy.proxy.exception.SessionNotFoundException;
|
||||||
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
||||||
import dev.dinauer.oidcproxy.startup.PathConverter;
|
import dev.dinauer.oidcproxy.startup.PathConverter;
|
||||||
import dev.dinauer.oidcproxy.startup.ProxyRoute;
|
import dev.dinauer.oidcproxy.startup.ProxyRoute;
|
||||||
@ -89,9 +90,9 @@ public class Resource
|
|||||||
accessLog.log(AccessLog.Type.ERROR, context, PathConverter.toPath(requestSegments), route.target(), e.getStatusCode(), e.getTime());
|
accessLog.log(AccessLog.Type.ERROR, context, PathConverter.toPath(requestSegments), route.target(), e.getStatusCode(), e.getTime());
|
||||||
ResponseHandler.error(context, e.getStatusCode());
|
ResponseHandler.error(context, e.getStatusCode());
|
||||||
}
|
}
|
||||||
catch (TokenNotFoundException e)
|
catch (TokenNotFoundException | SessionNotFoundException e)
|
||||||
{
|
{
|
||||||
LOG.error("Token not found.", e);
|
LOG.error("Token / Session not found.", e);
|
||||||
ResponseHandler.error(context, 401);
|
ResponseHandler.error(context, 401);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package dev.dinauer.oidcproxy.proxy;
|
package dev.dinauer.oidcproxy.proxy;
|
||||||
|
|
||||||
import dev.dinauer.oidcproxy.proxy.exception.ProxyHttpException;
|
import dev.dinauer.oidcproxy.proxy.exception.ProxyHttpException;
|
||||||
|
import dev.dinauer.oidcproxy.proxy.exception.SessionNotFoundException;
|
||||||
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
||||||
import dev.dinauer.oidcproxy.session.SessionCache;
|
import dev.dinauer.oidcproxy.session.SessionCache;
|
||||||
import dev.dinauer.oidcproxy.proxy.header.HeaderFilter;
|
import dev.dinauer.oidcproxy.proxy.header.HeaderFilter;
|
||||||
@ -23,7 +24,7 @@ public class ForwardService
|
|||||||
@Inject
|
@Inject
|
||||||
HeaderFilter headerFilter;
|
HeaderFilter headerFilter;
|
||||||
|
|
||||||
public TimedHttpResponse<byte[]> send(RoutingContext context, String route, String strategy) throws IOException, InterruptedException, ProxyHttpException, TokenNotFoundException
|
public TimedHttpResponse<byte[]> send(RoutingContext context, String route, String strategy) throws IOException, InterruptedException, ProxyHttpException, TokenNotFoundException, SessionNotFoundException
|
||||||
{
|
{
|
||||||
HttpRequestBuilder builder = HttpRequestBuilder.create();
|
HttpRequestBuilder builder = HttpRequestBuilder.create();
|
||||||
builder.setUri(route);
|
builder.setUri(route);
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package dev.dinauer.oidcproxy.proxy.exception;
|
||||||
|
|
||||||
|
public class SessionNotFoundException extends Exception
|
||||||
|
{
|
||||||
|
public SessionNotFoundException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package dev.dinauer.oidcproxy.proxy.header;
|
package dev.dinauer.oidcproxy.proxy.header;
|
||||||
|
|
||||||
|
import dev.dinauer.oidcproxy.proxy.exception.SessionNotFoundException;
|
||||||
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
||||||
import dev.dinauer.oidcproxy.proxy.header.strategy.OidcStrategy;
|
import dev.dinauer.oidcproxy.proxy.header.strategy.OidcStrategy;
|
||||||
import dev.dinauer.oidcproxy.session.SessionCache;
|
import dev.dinauer.oidcproxy.session.SessionCache;
|
||||||
@ -21,7 +22,7 @@ public class HeaderFilter
|
|||||||
@Inject
|
@Inject
|
||||||
OidcStrategy oidcStrategy;
|
OidcStrategy oidcStrategy;
|
||||||
|
|
||||||
public List<Map.Entry<String, String>> filter(HttpServerRequest request, String strategy) throws TokenNotFoundException
|
public List<Map.Entry<String, String>> filter(HttpServerRequest request, String strategy) throws TokenNotFoundException, SessionNotFoundException
|
||||||
{
|
{
|
||||||
List<Map.Entry<String, String>> headers = filterHop2HopHeaders(request.headers().entries());
|
List<Map.Entry<String, String>> headers = filterHop2HopHeaders(request.headers().entries());
|
||||||
if ("OIDC".equals(strategy))
|
if ("OIDC".equals(strategy))
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package dev.dinauer.oidcproxy.proxy.header.strategy;
|
package dev.dinauer.oidcproxy.proxy.header.strategy;
|
||||||
|
|
||||||
|
import dev.dinauer.oidcproxy.proxy.exception.SessionNotFoundException;
|
||||||
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
|
||||||
import dev.dinauer.oidcproxy.session.SessionCache;
|
import dev.dinauer.oidcproxy.session.SessionCache;
|
||||||
import io.quarkus.security.UnauthorizedException;
|
import io.quarkus.security.UnauthorizedException;
|
||||||
@ -21,7 +22,7 @@ public class OidcStrategy
|
|||||||
@Inject
|
@Inject
|
||||||
SessionCache sessionCache;
|
SessionCache sessionCache;
|
||||||
|
|
||||||
public List<Map.Entry<String, String>> filter(HttpServerRequest request, List<Map.Entry<String, String>> input) throws TokenNotFoundException
|
public List<Map.Entry<String, String>> filter(HttpServerRequest request, List<Map.Entry<String, String>> input) throws TokenNotFoundException, SessionNotFoundException
|
||||||
{
|
{
|
||||||
if (!hasAuthHeader(input))
|
if (!hasAuthHeader(input))
|
||||||
{
|
{
|
||||||
@ -30,7 +31,7 @@ public class OidcStrategy
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAccessToken(HttpServerRequest request) throws TokenNotFoundException
|
private String getAccessToken(HttpServerRequest request) throws TokenNotFoundException, SessionNotFoundException
|
||||||
{
|
{
|
||||||
for (Cookie cookie : request.cookies())
|
for (Cookie cookie : request.cookies())
|
||||||
{
|
{
|
||||||
@ -40,7 +41,7 @@ public class OidcStrategy
|
|||||||
return sessionCache.get(session);
|
return sessionCache.get(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new UnauthorizedException();
|
throw new SessionNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasAuthHeader(List<Map.Entry<String, String>> input)
|
private boolean hasAuthHeader(List<Map.Entry<String, String>> input)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user