|
1 | 1 | package com.networknt.security;
|
2 | 2 |
|
3 |
| -import com.networknt.config.Config; |
4 | 3 | import com.networknt.exception.ExpiredTokenException;
|
5 | 4 | import com.networknt.handler.Handler;
|
6 | 5 | import com.networknt.handler.MiddlewareHandler;
|
7 |
| -import com.networknt.handler.config.HandlerConfig; |
8 | 6 | import com.networknt.httpstring.AttachmentConstants;
|
9 | 7 | import com.networknt.httpstring.HttpStringConstants;
|
10 | 8 | import com.networknt.utility.Constants;
|
11 |
| -import com.networknt.utility.ModuleRegistry; |
12 | 9 | import io.undertow.Handlers;
|
13 | 10 | import io.undertow.server.HttpHandler;
|
14 | 11 | import io.undertow.server.HttpServerExchange;
|
|
26 | 23 |
|
27 | 24 | public abstract class AbstractSimpleJwtVerifyHandler extends UndertowVerifyHandler implements MiddlewareHandler, IJwtVerifyHandler {
|
28 | 25 | static final Logger logger = LoggerFactory.getLogger(AbstractSimpleJwtVerifyHandler.class);
|
29 |
| - static final String SECURITY_CONFIG = "security"; |
30 | 26 | static final String STATUS_INVALID_AUTH_TOKEN = "ERR10000";
|
31 | 27 | static final String STATUS_AUTH_TOKEN_EXPIRED = "ERR10001";
|
32 | 28 | static final String STATUS_MISSING_AUTH_TOKEN = "ERR10002";
|
33 | 29 | static final String STATUS_METHOD_NOT_ALLOWED = "ERR10008";
|
34 | 30 |
|
35 |
| - static SecurityConfig config; |
| 31 | + public static SecurityConfig config; |
36 | 32 |
|
37 | 33 | // make this static variable public so that it can be accessed from the server-info module
|
38 | 34 | public static JwtVerifier jwtVerifier;
|
39 | 35 |
|
40 |
| - String basePath; |
41 |
| - |
42 |
| - private volatile HttpHandler next; |
43 |
| - |
44 |
| - public AbstractSimpleJwtVerifyHandler() { |
45 |
| - // at this moment, we assume that the OpenApiHandler is fully loaded with a single spec or multiple specs. |
46 |
| - // And the basePath is the correct one from the OpenApiHandler helper or helperMap if multiple is used. |
47 |
| - config = SecurityConfig.load(SECURITY_CONFIG); |
48 |
| - jwtVerifier = new JwtVerifier(config); |
49 |
| - // in case that the specification doesn't exist, get the basePath from the handler.yml for endpoint lookup. |
50 |
| - HandlerConfig handlerConfig = HandlerConfig.load(); |
51 |
| - this.basePath = handlerConfig == null ? "/" : handlerConfig.getBasePath(); |
52 |
| - } |
| 36 | + public volatile HttpHandler next; |
53 | 37 |
|
54 | 38 | @Override
|
55 | 39 | @SuppressWarnings("unchecked")
|
@@ -238,18 +222,6 @@ public boolean isEnabled() {
|
238 | 222 | return config.isEnableVerifyJwt();
|
239 | 223 | }
|
240 | 224 |
|
241 |
| - @Override |
242 |
| - public void register() { |
243 |
| - ModuleRegistry.registerModule(SECURITY_CONFIG, AbstractSimpleJwtVerifyHandler.class.getName(), Config.getNoneDecryptedInstance().getJsonMapConfigNoCache(SECURITY_CONFIG), null); |
244 |
| - } |
245 |
| - |
246 |
| - @Override |
247 |
| - public void reload() { |
248 |
| - config.reload(SECURITY_CONFIG); |
249 |
| - jwtVerifier = new JwtVerifier(config); |
250 |
| - ModuleRegistry.registerModule(SECURITY_CONFIG, AbstractSimpleJwtVerifyHandler.class.getName(), Config.getNoneDecryptedInstance().getJsonMapConfigNoCache(SECURITY_CONFIG), null); |
251 |
| - } |
252 |
| - |
253 | 225 | @Override
|
254 | 226 | public JwtVerifier getJwtVerifier() {
|
255 | 227 | return jwtVerifier;
|
|
0 commit comments