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 #56 add configuration folder for the transformation #57

Merged
merged 1 commit into from
Jul 6, 2022
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
106 changes: 106 additions & 0 deletions config/client-proxy-transform/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016 Network New Technologies Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<configuration>
<!-- TODO create logger for audit only.
http://stackoverflow.com/questions/2488558/logback-to-log-different-messages-to-two-files -->
<turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
<Marker>PROFILER</Marker>
<!--<OnMatch>DENY</OnMatch>-->
<OnMatch>NEUTRAL</OnMatch>
</turboFilter>

<!--stdout log-->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %X{sId} %X{cId} %-5level %class{36}:%L %M - %msg%n</pattern>
</encoder>
</appender>

<!--stdout-file log-->
<appender name="stdout-file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/stdout.log.json</file>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp>
<fieldName>timestamp</fieldName>
<pattern>yyyy-MM-dd'T'HH:mm:ss.SSSZ</pattern>
</timestamp>
<pattern>
<pattern>
{
"thread": "%thread",
"level": "%-5level",
"logger": "%logger{64}",
"correlationId": "%X{cId}",
"serviceId": "%X{sId}",
"class": "%F",
"lineNumber": "%class{64}:%L",
"method": "%M",
"logMessage": "#tryJson{%message}"
}
</pattern>
</pattern>
<rootStackTraceElement/>
<stackTrace/>
</providers>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>log/stdout.log.json.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>5</maxIndex> <!-- max number of archived logs that are kept -->
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>200MB
</maxFileSize> <!-- The size of the logfile that triggers a switch to a new logfile, and the current one archived -->
</triggeringPolicy>
</appender>

<!--audit log-->
<appender name="audit" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/schedular-audit.log.json</file> <!-- logfile location -->
<encoder>
<pattern>%msg%n</pattern> <!-- the layout pattern used to format log entries -->
<immediateFlush>true</immediateFlush>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>log/schedular-audit.log.json.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>5</maxIndex> <!-- max number of archived logs that are kept -->
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>200MB
</maxFileSize> <!-- The size of the logfile that triggers a switch to a new logfile, and the current one archived -->
</triggeringPolicy>
</appender>

<root level="debug">
<appender-ref ref="stdout"/>
<appender-ref ref="stdout-file"/>
</root>

<logger name="Audit" level="debug" additivity="false">
<appender-ref ref="audit"/>
</logger>

<logger name="com.networknt" level="trace" additivity="false">
<appender-ref ref="stdout"/>
</logger>

</configuration>
113 changes: 113 additions & 0 deletions config/client-proxy-transform/values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# server.yml
server.httpPort: 9080
server.enableHttp: true
server.enableHttps: false
server.enableHttp2: false
server.serviceId: com.networknt.client-gateway-1.0.0
server.environment: dev

# router.yml
router.maxRequestTime: 30000

# pathPrefixService.yml
pathPrefixService.mapping:
# /gateway/Migration/1.0.0: Migration
/v1/pets: com.networknt.petstore-1.0.0
# service.yml
service.singletons:
- com.networknt.registry.URL:
- com.networknt.registry.URLImpl:
parameters:
# com.networknt.portal.hybrid.query-1.0.0: https://hybrid-query1:8440,https://hybrid-query2:8441,https://hybrid-query3:8442
# com.networknt.portal.hybrid.command-1.0.0: https://hybrid-command:8439
# com.networknt.oauth-key-1.0.0: https://oauth-key:6886
# com.networknt.oauth-token-1.0.0: https://oauth-token:6882
# com.networknt.oauth-code-1.0.0: https://oauth-code:6881
# com.networknt.reference-1.0.0: https://reference:2498
# com.networknt.config-server-1.0.0: https://localhost:8435
# com.networknt.controller-1.0.0: https://controller-node1:8438,https://controller-node2:8437,https://controller-node3:8436
# com.networknt.scheduler-1.0.0: https://scheduler-node1:8401,https://scheduler-node2:8402,https://scheduler-node3:8403
# Migration: https://lightgateway-dev.networknt.com:8443
com.networknt.petstore-1.0.0: https://localhost:9443
- com.networknt.registry.Registry:
- com.networknt.registry.support.DirectRegistry
- com.networknt.balance.LoadBalance:
- com.networknt.balance.RoundRobinLoadBalance
- com.networknt.cluster.Cluster:
- com.networknt.cluster.LightCluster
- com.networknt.utility.Decryptor:
- com.networknt.decrypt.AESDecryptor
- com.networknt.handler.ResponseInterceptorHandler:
- com.networknt.restrans.ResponseTransformerHandler

# handler.yml
handler.basePath: /
handler.handlers:
# Light-framework cross-cutting concerns implemented in the microservice
- com.networknt.exception.ExceptionHandler@exception
- com.networknt.metrics.MetricsHandler@metrics
- com.networknt.traceability.TraceabilityHandler@traceability
- com.networknt.correlation.CorrelationHandler@correlation
# Cors handler to handler post/put pre-flight. It is not used in the sidecar but only in the router.
- com.networknt.cors.CorsHttpHandler@cors
- com.networknt.openapi.OpenApiHandler@specification
- com.networknt.openapi.JwtVerifyHandler@security
- com.networknt.body.BodyHandler@body
- com.networknt.audit.AuditHandler@audit
- com.networknt.sanitizer.SanitizerHandler@sanitizer
- com.networknt.openapi.ValidatorHandler@validator
# Header middleware to manipulate request and/or response headers before or after downstream server
- com.networknt.header.HeaderHandler@header
# Rate limit middleware to prevent DDoS attacks externally or throttle requests internally
- com.networknt.limit.LimitHandler@limit
# IP whitelist handler to allow only one or several IPs to connect to the gateway.
# - com.networknt.whitelist.WhitelistHandler@whitelist
# Direct requests to named services based on the request path
# - com.networknt.router.middleware.GatewayServiceDictHandler@path
- com.networknt.router.middleware.PathPrefixServiceHandler@prefix
- com.networknt.router.middleware.GatewaySAMLTokenHandler@saml
- com.networknt.router.GatewayRouterHandler@router
- com.networknt.proxy.LightProxyHandler@proxy
- com.networknt.proxy.ProxyServerInfoHandler@proxyServerInfo
# - com.networknt.resource.VirtualHostHandler@virtual
# Customer business domain specific cross-cutting concerns handlers
# - com.example.validator.CustomizedValidator@custvalidator
# Framework endpoint handlers
# Control Pane middleware handlers and API handler
- com.networknt.chaos.KillappAssaultHandler@killapp
- com.networknt.chaos.LatencyAssaultHandler@latency
- com.networknt.chaos.MemoryAssaultHandler@memory
- com.networknt.chaos.ExceptionAssaultHandler@exchaos
- com.networknt.chaos.ChaosMonkeyGetHandler@chaosget
- com.networknt.chaos.ChaosMonkeyPostHandler@chaospost
- com.networknt.health.HealthGetHandler@health
- com.networknt.info.ServerInfoGetHandler@info
- com.networknt.logging.handler.LoggerGetHandler@getLogger
- com.networknt.logging.handler.LoggerPostHandler@postLogger
- com.networknt.logging.handler.LoggerGetLogContentsHandler@getLogContents
- com.networknt.config.reload.handler.ModuleRegistryGetHandler@modules
- com.networknt.config.reload.handler.ConfigReloadHandler@configReload
- com.networknt.specification.SpecDisplayHandler@spec
- com.networknt.specification.SpecSwaggerUIHandler@swaggerui
- com.networknt.specification.FaviconHandler@favicon
- com.networknt.handler.SinkConduitInjectorHandler@sink

handler.chains.default:
- exception
- metrics
- limit
- traceability
- correlation
- cors
# - stateless
- sink
- header
#- path
#- specification
#- security
#- body
#- audit
#- sanitizer
#- validator
- prefix
- router
26 changes: 10 additions & 16 deletions config/server-proxy-petstore/values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ server.serviceId: com.networknt.server-proxy-1.0.0
# router.maxRequestTime: 3000

# proxy.yml
proxy.host: https://localhost:9443
proxy.hosts: https://localhost:9443

# header.yml
header.enabled: true
Expand Down Expand Up @@ -55,11 +55,11 @@ client.tokenKeyEnableHttp2: true
#client.injectOpenTracing: true

#security.yml
security.enableVerifyJwt: false
security.enableExtractScopeToken: false
security.enableVerifyScope: false
security.keyResolver: JsonWebKeySet
security.bootstrapFromKeyService: true
openapi-security.enableVerifyJwt: false
openapi-security.enableExtractScopeToken: false
openapi-security.enableVerifyScope: false
openapi-security.keyResolver: X509Certificate
openapi-security.bootstrapFromKeyService: false
# okta security end

# service.yml
Expand All @@ -84,8 +84,7 @@ service.singletons:

# pathPrefixService.yml
# pathPrefixService.enabled: true
# pathPrefixService.mapping:
# /router/dev/de-asia-ekyc-service: de-asia-ekyc-service-1.0.0
# pathPrefixService.mapping: {"/v1/pets":"com.networknt.petstore-1.0.0"}

# whitelist.yml
whitelist.enabled: false
Expand Down Expand Up @@ -119,7 +118,7 @@ whitelist.paths:

# handler.yml
handler.enabled: true
handler.basePath: /
handler.basePath: /v1
handler.handlers:
# Light-framework cross-cutting concerns implemented in the microservice
- com.networknt.exception.ExceptionHandler@exception
Expand All @@ -142,11 +141,10 @@ handler.handlers:
# - com.networknt.whitelist.WhitelistHandler@whitelist
# Direct requests to named services based on the request path
# - com.networknt.router.middleware.GatewayServiceDictHandler@path
- com.networknt.router.middleware.PathPrefixServiceHandler@prefix
# - com.networknt.router.middleware.PathPrefixServiceHandler@prefix
# - com.networknt.router.middleware.GatewaySAMLTokenHandler@saml
- com.networknt.router.GatewayRouterHandler@router
# - com.networknt.router.GatewayRouterHandler@router
- com.networknt.proxy.LightProxyHandler@proxy
- com.networknt.proxy.ProxyServerInfoHandler@proxyServerInfo
# - com.networknt.resource.VirtualHostHandler@virtual
# Customer business domain specific cross-cutting concerns handlers
# - com.example.validator.CustomizedValidator@custvalidator
Expand Down Expand Up @@ -180,15 +178,11 @@ handler.chains.default:
- memory
- exchaos
- cors
# - stateless
- header
- body
- specification
- security
- audit
- sanitizer
- validator
# - path
# - prefix
# - router
- proxy
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@
<artifactId>cors</artifactId>
<version>${version.light-4j}</version>
</dependency>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>response-transformer</artifactId>
<version>${version.light-4j}</version>
</dependency>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>request-transformer</artifactId>
<version>${version.light-4j}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down