Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #396 use the handleRequest from abstract handlers for security … #397

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,6 @@ public JwtVerifyHandler() {
this.basePath = handlerConfig == null ? "/" : handlerConfig.getBasePath();
}

@Override
@SuppressWarnings("unchecked")
public void handleRequest(final HttpServerExchange exchange) throws Exception {

if (logger.isDebugEnabled())
logger.debug("JwtVerifyHandler.handleRequest starts.");

String reqPath = exchange.getRequestPath();

// if request path is in the skipPathPrefixes in the config, call the next handler directly to skip the security check.
if (config.getSkipPathPrefixes() != null && config.getSkipPathPrefixes().stream().anyMatch(reqPath::startsWith)) {
if(logger.isTraceEnabled())
logger.trace("Skip request path base on skipPathPrefixes for " + reqPath);
Handler.next(exchange, next);
if (logger.isDebugEnabled())
logger.debug("JwtVerifyHandler.handleRequest ends.");
return;
}
// only UnifiedSecurityHandler will have the jwkServiceIds as the third parameter.
if(handleJwt(exchange, null, reqPath, null)) {
if(logger.isDebugEnabled()) logger.debug("JwtVerifyHandler.handleRequest ends.");
Handler.next(exchange, next);
}
}

@Override
public List<String> getSpecScopes(HttpServerExchange exchange, Map<String, Object> auditInfo) throws Exception {
/* get openapi operation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,6 @@ public SimpleJwtVerifyHandler() {
this.basePath = handlerConfig == null ? "/" : handlerConfig.getBasePath();
}

@Override
@SuppressWarnings("unchecked")
public void handleRequest(final HttpServerExchange exchange) throws Exception {

if (logger.isDebugEnabled())
logger.debug("SimpleJwtVerifyHandler.handleRequest starts.");

String reqPath = exchange.getRequestPath();

// if request path is in the skipPathPrefixes in the config, call the next handler directly to skip the security check.
if (config.getSkipPathPrefixes() != null && config.getSkipPathPrefixes().stream().anyMatch(reqPath::startsWith)) {
if(logger.isTraceEnabled())
logger.trace("Skip request path base on skipPathPrefixes for {}", reqPath);
Handler.next(exchange, next);
if (logger.isDebugEnabled())
logger.debug("SimpleJwtVerifyHandler.handleRequest ends.");
return;
}
// only UnifiedSecurityHandler will have the jwkServiceIds as the third parameter.
if(handleJwt(exchange, null, reqPath, null)) {
if(logger.isDebugEnabled()) logger.debug("SimpleJwtVerifyHandler.handleRequest ends.");
Handler.next(exchange, next);
}
}

@Override
public HttpHandler getNext() {
return next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,6 @@ public void reload() {
ModuleRegistry.registerModule(SecurityConfig.CONFIG_NAME, SwtVerifyHandler.class.getName(), Config.getNoneDecryptedInstance().getJsonMapConfigNoCache(SecurityConfig.CONFIG_NAME), null);
}

@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
if (logger.isDebugEnabled())
logger.debug("SwtVerifyHandler.handleRequest starts.");

String reqPath = exchange.getRequestPath();

// if request path is in the skipPathPrefixes in the config, call the next handler directly to skip the security check.
if (config.getSkipPathPrefixes() != null && config.getSkipPathPrefixes().stream().anyMatch(reqPath::startsWith)) {
if(logger.isTraceEnabled())
logger.trace("Skip request path base on skipPathPrefixes for " + reqPath);
Handler.next(exchange, next);
if (logger.isDebugEnabled())
logger.debug("SwtVerifyHandler.handleRequest ends.");
return;
}
// only UnifiedSecurityHandler will have the jwkServiceIds as the third parameter.
if(handleSwt(exchange, reqPath, null)) {
if(logger.isDebugEnabled()) logger.debug("SwtVerifyHandler.handleRequest ends.");
Handler.next(exchange, next);
}
}


@Override
public List<String> getSpecScopes(HttpServerExchange exchange, Map<String, Object> auditInfo) throws Exception {
/* get openapi operation */
Expand Down