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 #334 update config class to support conversion from string to i… #335

Merged
merged 1 commit into from
Nov 25, 2023
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 @@ -57,8 +57,6 @@ public class OpenApiHandler implements MiddlewareHandler {

public static final String CONFIG_NAME = "openapi";
public static final String SPEC_INJECT = "openapi-inject";
public static final String HANDLER_CONFIG = "handler";

public static final AttachmentKey<Map<String, Object>> DESERIALIZED_QUERY_PARAMETERS = AttachmentKey.create(Map.class);
public static final AttachmentKey<Map<String, Object>> DESERIALIZED_PATH_PARAMETERS = AttachmentKey.create(Map.class);
public static final AttachmentKey<Map<String, Object>> DESERIALIZED_HEADER_PARAMETERS = AttachmentKey.create(Map.class);
Expand Down Expand Up @@ -112,7 +110,7 @@ public OpenApiHandler(OpenApiHandlerConfig cfg) {
if(logger.isTraceEnabled()) logger.trace("multiple specifications loaded.");
} else {
Map<String, Object> openapi = Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME);
handlerConfig = (HandlerConfig) Config.getInstance().getJsonObjectConfig(HANDLER_CONFIG, HandlerConfig.class);
handlerConfig = HandlerConfig.load();

this.validateSpec(openapi, inject, "openapi.yml");

Expand Down Expand Up @@ -309,7 +307,8 @@ public void register() {

@Override
public void reload() {
handlerConfig = (HandlerConfig) Config.getInstance().getJsonObjectConfig(HANDLER_CONFIG, HandlerConfig.class);
config.reload();
ModuleRegistry.registerModule(OpenApiHandlerConfig.CONFIG_NAME, OpenApiHandler.class.getName(), config.getMappedConfig(), null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@
*/
public class JwtVerifyHandler implements MiddlewareHandler, IJwtVerifyHandler {
static final Logger logger = LoggerFactory.getLogger(JwtVerifyHandler.class);

static final String HANDLER_CONFIG = "handler";
static final String OPENAPI_SECURITY_CONFIG = "openapi-security";

static final String STATUS_INVALID_AUTH_TOKEN = "ERR10000";
static final String STATUS_AUTH_TOKEN_EXPIRED = "ERR10001";
static final String STATUS_MISSING_AUTH_TOKEN = "ERR10002";
Expand All @@ -84,7 +81,7 @@ public JwtVerifyHandler() {
config = SecurityConfig.load(OPENAPI_SECURITY_CONFIG);
jwtVerifier = new JwtVerifier(config);
// in case that the specification doesn't exist, get the basePath from the handler.yml for endpoint lookup.
HandlerConfig handlerConfig = (HandlerConfig) Config.getInstance().getJsonObjectConfig(HANDLER_CONFIG, HandlerConfig.class);
HandlerConfig handlerConfig = HandlerConfig.load();
this.basePath = handlerConfig == null ? "/" : handlerConfig.getBasePath();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
public class SwtVerifyHandler implements MiddlewareHandler {
static final Logger logger = LoggerFactory.getLogger(SwtVerifyHandler.class);
static final String OPENAPI_SECURITY_CONFIG = "openapi-security";
static final String HANDLER_CONFIG = "handler";
static final String STATUS_INVALID_AUTH_TOKEN = "ERR10000";
static final String STATUS_AUTH_TOKEN_EXPIRED = "ERR10001";
static final String STATUS_MISSING_AUTH_TOKEN = "ERR10002";
Expand Down Expand Up @@ -429,7 +428,7 @@ public SwtVerifyHandler() {
config = SecurityConfig.load(OPENAPI_SECURITY_CONFIG);
swtVerifier = new SwtVerifier(config);
// in case that the specification doesn't exist, get the basePath from the handler.yml for endpoint lookup.
HandlerConfig handlerConfig = (HandlerConfig) Config.getInstance().getJsonObjectConfig(HANDLER_CONFIG, HandlerConfig.class);
HandlerConfig handlerConfig = HandlerConfig.load();
this.basePath = handlerConfig == null ? "/" : handlerConfig.getBasePath();
}

Expand Down