Merge pull request #379 from openziti/use.xweb

use xweb, changelog, ziti cmd updates
This commit is contained in:
Andrew
2021-05-09 10:57:18 -04:00
committed by GitHub
9 changed files with 652 additions and 81 deletions
+460 -3
View File
@@ -4,6 +4,463 @@
* Fix bug in router/tunneler where only first 10 services would get picked up for intercepting/hosting
* Fix bug in router/tunneler where we'd process services multiple times on service add/remove/update
* Edge Management REST API Transit Router Deprecation
* Edge REST API Split & Configuration Changes
### Edge Management REST API Transit Router Deprecation
The endpoint `/transit-routers` is now `/routers`. Use of the former name
is considered deprecated. This endpoint only affects the new Edge Management API.
### Edge REST API Split
The Edge REST API has now been split into two APIs: The Edge Client API and the Edge Management API.
There are now two Open API 2.0 specifications present in the `edge` repository under `/specs/client.yml`
and `/specs/management.yml`. These two files are generated (see the scripts in `/scripts/`) from decomposed
YAML source files present in `/specs/source`.
The APIs are now hosted on separate URL paths:
- Client API: `/edge/client/v1`
- Management API: `/edge/management/v1`
Legacy path support is present for the Client API only. The Management API does not support legacy
URL paths. The Client API Legacy paths that are supported are as follows:
- No Prefix: `/*`
- Edge Prefix: `/edge/v1/*`
This support is only expected to last until all Ziti SDKs move to using the new prefixed paths and versions
that do not reach the end of their lifecycle. After that time, support will be removed. It is highly
suggested that URL path prefixes be updated or dynamically looked up via the `/version` endpoint (see below)
#### Client and Management API Capabilities
The Client API represents only functionality required by and endpoint to
connected to and use services. This API services Ziti SDKs.
The Management API represents all administrative configuration capabilities.
The Management API is meant to be used by the Ziti Admin Console (ZAC) or
other administrative integrations.
*Client API Endpoints*
- `/edge/client/v1/`
- `/edge/client/v1/.well-known/est/cacerts`
- `/edge/client/v1/authenticate`
- `/edge/client/v1/authenticate/mfa`
- `/edge/client/v1/current-api-session`
- `/edge/client/v1/current-api-session/certificates`
- `/edge/client/v1/current-api-session/certificates/{id}`
- `/edge/client/v1/current-api-session/service-updates`
- `/edge/client/v1/current-identity`
- `/edge/client/v1/current-identity/authenticators`
- `/edge/client/v1/current-identity/authenticators/{id}`
- `/edge/client/v1/current-identity/edge-routers`
- `/edge/client/v1/current-identity/mfa`
- `/edge/client/v1/current-identity/mfa/qr-code`
- `/edge/client/v1/current-identity/mfa/verify`
- `/edge/client/v1/current-identity/mfa/recovery-codes`
- `/edge/client/v1/enroll`
- `/edge/client/v1/enroll/ca`
- `/edge/client/v1/enroll/ott`
- `/edge/client/v1/enroll/ottca`
- `/edge/client/v1/enroll/updb`
- `/edge/client/v1/enroll/erott`
- `/edge/client/v1/enroll/extend/router`
- `/edge/client/v1/posture-response`
- `/edge/client/v1/posture-response-bulk`
- `/edge/client/v1/protocols`
- `/edge/client/v1/services`
- `/edge/client/v1/services/{id}`
- `/edge/client/v1/services/{id}/terminators`
- `/edge/client/v1/sessions`
- `/edge/client/v1/sessions/{id}`
- `/edge/client/v1/specs`
- `/edge/client/v1/specs/{id}`
- `/edge/client/v1/specs/{id}/spec`
- `/edge/client/v1/version`
*Management API Endpoints*
- `/edge/management/v1/`
- `/edge/management/v1/api-sessions`
- `/edge/management/v1/api-sessions/{id}`
- `/edge/management/v1/authenticate`
- `/edge/management/v1/authenticate/mfa`
- `/edge/management/v1/authenticators`
- `/edge/management/v1/authenticators/{id}`
- `/edge/management/v1/cas`
- `/edge/management/v1/cas/{id}`
- `/edge/management/v1/cas/{id}/jwt`
- `/edge/management/v1/cas/{id}/verify`
- `/edge/management/v1/config-types`
- `/edge/management/v1/config-types/{id}`
- `/edge/management/v1/config-types/{id}/configs`
- `/edge/management/v1/configs`
- `/edge/management/v1/configs/{id}`
- `/edge/management/v1/current-api-session`
- `/edge/management/v1/current-identity`
- `/edge/management/v1/current-identity/authenticators`
- `/edge/management/v1/current-identity/authenticators/{id}`
- `/edge/management/v1/current-identity/mfa`
- `/edge/management/v1/current-identity/mfa/qr-code`
- `/edge/management/v1/current-identity/mfa/verify`
- `/edge/management/v1/current-identity/mfa/recovery-codes`
- `/edge/management/v1/database/snapshot`
- `/edge/management/v1/database/check-data-integrity`
- `/edge/management/v1/database/fix-data-integrity`
- `/edge/management/v1/database/data-integrity-results`
- `/edge/management/v1/edge-router-role-attributes`
- `/edge/management/v1/edge-routers`
- `/edge/management/v1/edge-routers/{id}`
- `/edge/management/v1/edge-routers/{id}/edge-router-policies`
- `/edge/management/v1/edge-routers/{id}/identities`
- `/edge/management/v1/edge-routers/{id}/service-edge-router-policies`
- `/edge/management/v1/edge-routers/{id}/services`
- `/edge/management/v1/edge-router-policies`
- `/edge/management/v1/edge-router-policies/{id}`
- `/edge/management/v1/edge-router-policies/{id}/edge-routers`
- `/edge/management/v1/edge-router-policies/{id}/identities`
- `/edge/management/v1/enrollments`
- `/edge/management/v1/enrollments/{id}`
- `/edge/management/v1/identities`
- `/edge/management/v1/identities/{id}`
- `/edge/management/v1/identities/{id}/edge-router-policies`
- `/edge/management/v1/identities/{id}/service-configs`
- `/edge/management/v1/identities/{id}/service-policies`
- `/edge/management/v1/identities/{id}/edge-routers`
- `/edge/management/v1/identities/{id}/services`
- `/edge/management/v1/identities/{id}/policy-advice/{serviceId}`
- `/edge/management/v1/identities/{id}/posture-data`
- `/edge/management/v1/identities/{id}/failed-service-requests`
- `/edge/management/v1/identities/{id}/mfa`
- `/edge/management/v1/identity-role-attributes`
- `/edge/management/v1/identity-types`
- `/edge/management/v1/identity-types/{id}`
- `/edge/management/v1/posture-checks`
- `/edge/management/v1/posture-checks/{id}`
- `/edge/management/v1/posture-check-types`
- `/edge/management/v1/posture-check-types/{id}`
- `/edge/management/v1/service-edge-router-policies`
- `/edge/management/v1/service-edge-router-policies/{id}`
- `/edge/management/v1/service-edge-router-policies/{id}/edge-routers`
- `/edge/management/v1/service-edge-router-policies/{id}/services`
- `/edge/management/v1/service-role-attributes`
- `/edge/management/v1/service-policies`
- `/edge/management/v1/service-policies/{id}`
- `/edge/management/v1/service-policies/{id}/identities`
- `/edge/management/v1/service-policies/{id}/services`
- `/edge/management/v1/service-policies/{id}/posture-checks`
- `/edge/management/v1/services`
- `/edge/management/v1/services/{id}`
- `/edge/management/v1/services/{id}/configs`
- `/edge/management/v1/services/{id}/service-edge-router-policies`
- `/edge/management/v1/services/{id}/service-policies`
- `/edge/management/v1/services/{id}/identities`
- `/edge/management/v1/services/{id}/edge-routers`
- `/edge/management/v1/services/{id}/terminators`
- `/edge/management/v1/sessions`
- `/edge/management/v1/sessions/{id}`
- `/edge/management/v1/sessions/{id}/route-path`
- `/edge/management/v1/specs`
- `/edge/management/v1/specs/{id}`
- `/edge/management/v1/specs/{id}/spec`
- `/edge/management/v1/summary`
- `/edge/management/v1/terminators`
- `/edge/management/v1/terminators/{id}`
- `/edge/management/v1/routers`
- `/edge/management/v1/transit-routers`
- `/edge/management/v1/routers/{id}`
- `/edge/management/v1/transit-routers/{id}`
- `/edge/management/v1/version`
#### XWeb Support & Configuration Changes
The underlying framework used to host the Edge REST API has been moved into a new library
that can be found in the `fabric` repository under the module name `xweb`. XWeb allows arbitrary
APIs and website capabilities to be hosted on one or more http servers bound to any number of
network interfaces and ports.
The main result of this is that the Edge Client and Management APIs can be hosted on separate ports or
even on separate network interfaces if desired. This allows for configurations where the Edge Management
API is not accessible outside of localhost or is only presented to network interfaces that are inwardly facing.
The introduction of XWeb has necessitated changes to the controller configuration. For a full documented example
see the file `/etc/ctrl.with.edge.yml` in this repository.
##### Controller Configuration: Edge Section
The Ziti Controller configuration `edge` YAML section remains as a shared location for cross-API settings. It however,
does not include HTTP settings which are now configured in the `web` section.
Additionally, all duration configuration values must be specified in `<integer><unit>` durations. For example
- "5m" for five minutes
- "100s" for one hundred seconds
```
# By having an 'edge' section defined, the ziti-controller will attempt to parse the edge configuration. Removing this
# section, commenting out, or altering the name of the section will cause the edge to not run.
edge:
# This section represents the configuration of the Edge API that is served over HTTPS
api:
#(optional, default 90s) Alters how frequently heartbeat and last activity values are persisted
# activityUpdateInterval: 90s
#(optional, default 250) The number of API Sessions updated for last activity per transaction
# activityUpdateBatchSize: 250
# sessionTimeout - optional, default 10m
# The number of minutes before an Edge API session will timeout. Timeouts are reset by
# API requests and connections that are maintained to Edge Routers
sessionTimeout: 30m
# address - required
# The default address (host:port) to use for enrollment for the Client API. This value must match one of the addresses
# defined in this webListener's bindPoints.
address: 127.0.0.1:1280
# enrollment - required
# A section containing settings pertaining to enrollment.
enrollment:
# signingCert - required
# A Ziti Identity configuration section that specifically makes use of the cert and key fields to define
# a signing certificate from the PKI that the Ziti environment is using to sign certificates. The signingCert.cert
# will be added to the /.well-known CA store that is used to bootstrap trust with the Ziti Controller.
signingCert:
cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/intermediate.cert.pem
key: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/private/intermediate.key.decrypted.pem
# edgeIdentity - optional
# A section for identity enrollment specific settings
edgeIdentity:
# durationMinutes - optional, default 5m
# The length of time that a Ziti Edge Identity enrollment should remain valid. After
# this duration, the enrollment will expire and not longer be usable.
duration: 5m
# edgeRouter - Optional
# A section for edge router enrollment specific settings.
edgeRouter:
# durationMinutes - optional, default 5m
# The length of time that a Ziti Edge Router enrollment should remain valid. After
# this duration, the enrollment will expire and not longer be usable.
duration: 5m
```
##### Controller Configuration: Web Section
The `web` section now allows Ziti APIs to be configured on various network interfaces and
ports according to deployment requirements. The `web` section is an array of configuration
that defines `WebListener`s. Each `WebListener` has its own HTTP configuration, `BindPoint`s,
identity override, and `API`s which are referenced by `binding` name.
Each `WebListener` maps to at least one HTTP server that will be bound on at least one `BindPoint`
(network interface/port combination and external address) and will host one or more `API`s defined
in the `api` section. `API`s are configured by `binding` name. The following `binding` names
are currently supported:
- Edge Client API: `edge-client`
- Edge Management API: `edge-management`
An example `web` section that places both the Edge Client and Management APIs on the same
`BindPoint`s would be:
```
# web
# Defines webListeners that will be hosted by the controller. Each webListener can host many APIs and be bound to many
# bind points.
web:
# name - required
# Provides a name for this listener, used for logging output. Not required to be unique, but is highly suggested.
- name: all-apis-localhost
# bindPoints - required
# One or more bind points are required. A bind point specifies an interface (interface:port string) that defines
# where on the host machine the webListener will listen and the address (host:port) that should be used to
# publicly address the webListener(i.e. mydomain.com, localhost, 127.0.0.1). This public address may be used for
# incoming address resolution as well as used in responses in the API.
bindPoints:
#interface - required
# A host:port string on which network interface to listen on. 0.0.0.0 will listen on all interfaces
- interface: 127.0.0.1:1280
# address - required
# The public address that external incoming requests will be able to resolve. Used in request processing and
# response content that requires full host:port/path addresses.
address: 127.0.0.1:1280
# identity - optional
# Allows the webListener to have a specific identity instead of defaulting to the root `identity` section.
# identity:
# cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ctrl-client.cert.pem
# server_cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ctrl-server.cert.pem
# key: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/private/ctrl.key.pem
# ca: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ca-chain.cert.pem
# options - optional
# Allows the specification of webListener level options - mainly dealing with HTTP/TLS settings. These options are
# used for all http servers started by the current webListener.
options:
# idleTimeoutMs - optional, default 5000ms
# The maximum amount of idle time in milliseconds allowed for pipelined HTTP requests. Setting this too high
# can cause resources on the host to be consumed as clients remain connected and idle. Lowering this value
# will cause clients to reconnect on subsequent HTTPs requests.
idleTimeout: 5000ms #http timeouts, new
# readTimeoutMs - optional, default 5000ms
# The maximum amount of time in milliseconds http servers will wait to read the first incoming requests. A higher
# value risks consuming resources on the host with clients that are acting bad faith or suffering from high latency
# or packet loss. A lower value can risk losing connections to high latency/packet loss clients.
readTimeout: 5000ms
# writeTimeoutMs - optional, default 10000ms
# The total maximum time in milliseconds that the http server will wait for a single requests to be received and
# responded too. A higher value can allow long running requests to consume resources on the host. A lower value
# can risk ending requests before the server has a chance to respond.
writeTimeout: 100000ms
# minTLSVersion - optional, default TSL1.2
# The minimum version of TSL to support
minTLSVersion: TLS1.2
# maxTLSVersion - optional, default TSL1.3
# The maximum version of TSL to support
maxTLSVersion: TLS1.3
# apis - required
# Allows one or more APIs to be bound to this webListener
apis:
# binding - required
# Specifies an API to bind to this webListener. Built-in APIs are
# - edge-management
# - edge-client
# - fabric-management
- binding: edge-management
# options - variable optional/required
# This section is used to define values that are specified by the API they are associated with.
# These settings are per API. The example below is for the `edge-api` and contains both optional values and
# required values.
options: { }
- binding: edge-client
options: { }
- name: test-remove-me
bindPoints:
- interface: 127.0.0.1:1281
address: 127.0.0.1:1281
options: { }
apis:
- binding: edge-management
options: { }
- binding: edge-client
options: { }
```
All optional values are defaulted. The smallest configuration possible that places the Edge Client
and Managements APIs on the same `BindPoint` would be:
```
web:
- name: client-management-localhost
bindPoints:
- interface: 127.0.0.1:1280
address: 127.0.0.1:1280
options: { }
apis:
- binding: edge-management
options: { }
- binding: edge-client
options: { }
```
The following examples places the Management API on localhost and the Client API on all available interface
and advertised as `client.api.ziti.dev:1280`:
```
web:
- name: client-all-interfaces
bindPoints:
- interface: 0.0.0.0:1280
address: client.api.ziti.dev:1280
options: { }
apis:
- binding: edge-client
options: { }
- name: managmenet-local-only
bindPoints:
- interface: 127.0.0.1:1234
address: 127.0.0.1:1234
options: { }
apis:
- binding: edge-management
options: { }
```
#### Version Endpoint Updates
All Edge APIs support the `/version` endpoint and report all the APIs supported by the controller.
Each API now has a `binding` (string name) which is a global handle for that API's capabilities. See
the current list below
- Client API: `edge-client`, `edge`
- Management API: `edge-management`
Note: `edge` is an alias of `edge-client` for the `/version` endpoint only. It is considered deprecated.
These `bind names` can be used to parse the information returned by the `/version` endpoint to obtain the
most correct URL path for each API and version present. At a future date, other APIs with new `binding`s
(e.g. 'fabric-management` or 'fabric') or new versions may be added to this endpoint.
Versions prior to 0.20 of the Edge Controller reported the following:
```
{
"data": {
"apiVersions": {
"edge": {
"v1": {
"path": "/edge/v1"
}
}
},
"buildDate": "2020-08-11 19:48:57",
"revision": "e4ae43213a8d",
"runtimeVersion": "go1.14.7",
"version": "v0.16.0"
},
"meta": {}
}
```
Note: `/edge/v1` is deprecated
Version 0.20 and later report:
```
{
"data": {
"apiVersions": {
"edge": {
"v1": {
"apiBaseUrls": [
"https://127.0.0.1:1280/edge/client/v1",
"https://127.0.0.1:1281/edge/client/v1"
],
"path": "/edge/client/v1"
}
},
"edge-client": {
"v1": {
"apiBaseUrls": [
"https://127.0.0.1:1280/edge/client/v1",
"https://127.0.0.1:1281/edge/client/v1"
],
"path": "/edge/client/v1"
}
},
"edge-management": {
"v1": {
"apiBaseUrls": [
"https://127.0.0.1:1280/edge/management/v1",
"https://127.0.0.1:1281/edge/management/v1"
],
"path": "/edge/management/v1"
}
}
},
"buildDate": "2020-01-01 01:01:01",
"revision": "local",
"runtimeVersion": "go1.16.2",
"version": "v0.0.0"
},
"meta": {}
}.
```
# Release 0.19.13
@@ -176,8 +633,8 @@ Note that this mechanism replaces setting cost and precedence via the host.v1/ho
## Identity/Edge Router app data
We have an existing tags mechanism, which can be used by system administrators to annotate ziti entities in whatever is useful to them. Tags are an administrator function and are not meant to be visible to SDKs and SDK applications. If an administrator wants to provide custom data for services to the SDK they can use config types and configs for that purpose. Up until now however, there hasn't been a means to annotate identities and edge routers, which are the other two entities visible to SDKs, with data that the SDKs can consume.
0.19.9 introduces `appData` on identities and edge-routers. `appData` has the same structure as `tags`, but is intended to allow administrators to push custom data on identities and edge routers to SDKs. An example use is for tunnelers. The `sourceIp` can contain template information, which can refer back to the `appData` for the tunneler's identity.
We have an existing tags mechanism, which can be used by system administrators to annotate ziti entities in whatever is useful to them. Tags are an administrator function and are not meant to be visible to SDKs and SDK applications. If an administrator wants to provide custom data for services to the SDK they can use config types and configs for that purpose. Up until now however, there hasn't been a means to annotate identities and edge routers, which are the other two entities visible to SDKs, with data that the SDKs can consume.
0.19.9 introduces `appData` on identities and edge-routers. `appData` has the same structure as `tags`, but is intended to allow administrators to push custom data on identities and edge routers to SDKs. An example use is for tunnelers. The `sourceIp` can contain template information, which can refer back to the `appData` for the tunneler's identity.
The CLI supports setting appData on identities and edge routers.
@@ -218,7 +675,7 @@ This is a beta release. It should be relatively feature complete and bug-free fo
### Os Compatibilty
Like ziti-tunnel, `tproxy` mode will only work on linux. `proxy` and `host` modes should work on all operating systems.
Like ziti-tunnel, `tproxy` mode will only work on linux. `proxy` and `host` modes should work on all operating systems.
The converged tunneler/router does not support running in tun mode. This mode may be deprecated for ziti-tunnel as well at some point in the future if no advantages over tproxy mode are evident.
+126 -67
View File
@@ -9,30 +9,30 @@ profile:
# memory:
# path: ctrl.memprof
db: ${ZITI_DATA}/db/ctrl.db
db: ${ZITI_DATA}/db/ctrl.db
identity:
cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ctrl-client.cert.pem
server_cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ctrl-server.cert.pem
key: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/private/ctrl.key.pem
ca: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ca-chain.cert.pem
cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ctrl-client.cert.pem
server_cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ctrl-server.cert.pem
key: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/private/ctrl.key.pem
ca: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ca-chain.cert.pem
# the endpoint that routers will connect to the controller over.
ctrl:
listener: tls:127.0.0.1:6262
listener: tls:127.0.0.1:6262
#options:
# (optional) settings
# set the maximum number of connect requests that are buffered and waiting to be acknowledged (1 to 5000, default 1000)
#maxQueuedConnects: 50
# the maximum number of connects that have begun hello synchronization (1 to 1000, default 16)
#maxOutstandingConnects: 100
# the number of milliseconds to wait before a hello synchronization fails and closes the connection (30ms to 60000ms, default: 1000ms)
#connectTimeoutMs: 3000
# (optional) settings
# set the maximum number of connect requests that are buffered and waiting to be acknowledged (1 to 5000, default 1000)
#maxQueuedConnects: 50
# the maximum number of connects that have begun hello synchronization (1 to 1000, default 16)
#maxOutstandingConnects: 100
# the number of milliseconds to wait before a hello synchronization fails and closes the connection (30ms to 60000ms, default: 1000ms)
#connectTimeoutMs: 3000
# the endpoint that management tools connect to the controller over.
mgmt:
listener: tls:127.0.0.1:10000
#options:
listener: tls:127.0.0.1:10000
#options:
# (optional) settings
# set the maximum number of connect requests that are buffered and waiting to be acknowledged (1 to 5000, default 1000)
#maxQueuedConnects: 50
@@ -41,16 +41,16 @@ mgmt:
# the number of milliseconds to wait before a hello synchronization fails and closes the connection (30ms to 60000ms, default: 1000ms)
#connectTimeoutMs: 3000
#metrics:
#file:
#path: /tmp/ziti-controller-metrics.log
#maxsizemb: 100:wq
# Supported formats: json, plain
# Defaults to json
#format: plain
#metrics:
#file:
#path: /tmp/ziti-controller-metrics.log
#maxsizemb: 100:wq
# Supported formats: json, plain
# Defaults to json
#format: plain
#influxdb:
#url: http://localhost:8086
#database: ziti
#url: http://localhost:8086
#database: ziti
#events:
# jsonLogger:
@@ -84,60 +84,119 @@ mgmt:
edge:
# This section represents the configuration of the Edge API that is served over HTTPS
api:
# (required) The interface and port that the Edge API should be served on.
listener: 127.0.0.1:1280
# (required) The host/port combination that is reported as publicly accessible for the Edge API
advertise: 127.0.0.1:1280
# (optional, defaults to 10) The number of minutes before an Edge API session will timeout. Timeouts are reset by
# API requests and connections that are maintained to Edge Routers
sessionTimeoutMinutes: 30
#(optional, default 90s) Alters how frequently heartbeat and last activity values are persisted
# activityUpdateInterval: 90s
#(optional, default 250) The number of API Sessions updated for last activity per transaction
# activityUpdateBatchSize: 250
#(optional, defaults to the root identity) An alternate "identity" to use for the Edge API. If this section is not
# defined the root identity section will be used. This is useful for situations where Edge API will present a
# publicly signed certificate instead of one generated by a private PKI created by ziti pki create
# identity:
# server_cert: edge/tests/pki/ziti-dev-controller01.external.cert.pem
# server_key: edge/tests/pki/ziti-dev-controller01.external.key.pem
# ca: edge/tests/pki/ziti-dev-controller01.external.chain.cert.pem
# (optional, see individual fields for defaults) Sets Edge API HTTP timeout values
httpTimeouts:
# (optional, default 5s) readTimeoutMs is the maximum duration for reading the entire request, including the body.
readTimeoutMs: 5000
# (optional, default 0) readHeaderTimeoutMs is the amount of time allowed to read request headers.
# The connection's read deadline is reset after reading the headers. If readHeaderTimeoutMs is zero, the value of
# readTimeoutMs is used. If both are zero, there is no timeout.
readHeaderTimeoutMs: 0
# (optional, default 10000) writeTimeoutMs is the maximum duration before timing out writes of the response.
writeTimeoutMs: 100000
# (optional, default 5000) idleTimeoutMs is the maximum amount of time to wait for the next request when keep-alives are enabled
idleTimeoutMs: 5000
# This section is used to define option that are used during enrollment of Edge Routers, Ziti Edge Identities.
# sessionTimeout - optional, default 10m
# The number of minutes before an Edge API session will timeout. Timeouts are reset by
# API requests and connections that are maintained to Edge Routers
sessionTimeout: 30m
# address - required
# The default address (host:port) to use for enrollment for the Client API. This value must match one of the addresses
# defined in this webListener's bindPoints.
address: 127.0.0.1:1280
# enrollment - required
# A section containing settings pertaining to enrollment.
enrollment:
# (required) A Ziti Identity configuration section that specifically makes use of the cert and key fields to define
# signingCert - required
# A Ziti Identity configuration section that specifically makes use of the cert and key fields to define
# a signing certificate from the PKI that the Ziti environment is using to sign certificates. The signingCert.cert
# will be added to the /.well-known CA store that is used to bootstrap trust with the Ziti Controller.
# will be added to the /.well-known CA store that is used to bootstrap trust with the Ziti Controller.
signingCert:
cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/intermediate.cert.pem
key: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/private/intermediate.key.decrypted.pem
# edgeIdentity - optional
# A section for identity enrollment specific settings
edgeIdentity:
# (optional, defaults to 5) The length of time that a Ziti Edge Identity enrollment should remain valid. After
# durationMinutes - optional, default 5m
# The length of time that a Ziti Edge Identity enrollment should remain valid. After
# this duration, the enrollment will expire and not longer be usable.
durationMinutes: 5
duration: 5m
# edgeRouter - Optional
# A section for edge router enrollment specific settings.
edgeRouter:
# (optional, defaults to 5) The length of time that a Ziti Edge Router enrollment should remain valid. After
# durationMinutes - optional, default 5m
# The length of time that a Ziti Edge Router enrollment should remain valid. After
# this duration, the enrollment will expire and not longer be usable.
durationMinutes: 5
duration: 5m
# Only specify the persistence config if you want to migrate data from a PG database to the new bbolt datastore
#
# persistence:
# # See documentation:
# # - https://godoc.org/github.com/lib/pq
# # - https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
# # (required) A Postgres connection string used to connect to a database
# connectionUrl: postgres://postgres:ztpassword@localhost/postgres?sslmode=disable
# # (required) The Postgres database name to use
# dbName: postgres
# web - optional
# Defines webListeners that will be hosted by the controller. Each webListener can host many APIs and be bound to many
# bind points.
web:
# name - required
# Provides a name for this listener, used for logging output. Not required to be unique, but is highly suggested.
- name: all-apis-localhost
# bindPoints - required
# One or more bind points are required. A bind point specifies an interface (interface:port string) that defines
# where on the host machine the webListener will listen and the address (host:port) that should be used to
# publicly address the webListener(i.e. mydomain.com, localhost, 127.0.0.1). This public address may be used for
# incoming address resolution as well as used in responses in the API.
bindPoints:
#interface - required
# A host:port string on which network interface to listen on. 0.0.0.0 will listen on all interfaces
- interface: 127.0.0.1:1280
# address - required
# The public address that external incoming requests will be able to resolve. Used in request processing and
# response content that requires full host:port/path addresses.
address: 127.0.0.1:1280
# identity - optional
# Allows the webListener to have a specific identity instead of defaulting to the root `identity` section.
# identity:
# cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ctrl-client.cert.pem
# server_cert: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ctrl-server.cert.pem
# key: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/private/ctrl.key.pem
# ca: ${ZITI_SOURCE}/ziti/etc/ca/intermediate/certs/ca-chain.cert.pem
# options - optional
# Allows the specification of webListener level options - mainly dealing with HTTP/TLS settings. These options are
# used for all http servers started by the current webListener.
options:
# idleTimeoutMs - optional, default 5000ms
# The maximum amount of idle time in milliseconds allowed for pipelined HTTP requests. Setting this too high
# can cause resources on the host to be consumed as clients remain connected and idle. Lowering this value
# will cause clients to reconnect on subsequent HTTPs requests.
idleTimeout: 5000ms #http timeouts, new
# readTimeoutMs - optional, default 5000ms
# The maximum amount of time in milliseconds http servers will wait to read the first incoming requests. A higher
# value risks consuming resources on the host with clients that are acting bad faith or suffering from high latency
# or packet loss. A lower value can risk losing connections to high latency/packet loss clients.
readTimeout: 5000ms
# writeTimeoutMs - optional, default 10000ms
# The total maximum time in milliseconds that the http server will wait for a single requests to be received and
# responded too. A higher value can allow long running requests to consume resources on the host. A lower value
# can risk ending requests before the server has a chance to respond.
writeTimeout: 100000ms
# minTLSVersion - optional, default TSL1.2
# The minimum version of TSL to support
minTLSVersion: TLS1.2
# maxTLSVersion - optional, default TSL1.3
# The maximum version of TSL to support
maxTLSVersion: TLS1.3
# apis - required
# Allows one or more APIs to be bound to this webListener
apis:
# binding - required
# Specifies an API to bind to this webListener. Built-in APIs are
# - edge-management
# - edge-client
# - fabric-management
- binding: edge-management
# options - variable optional/required
# This section is used to define values that are specified by the API they are associated with.
# These settings are per API. The example below is for the `edge-api` and contains both optional values and
# required values.
options: { }
- binding: edge-client
options: { }
- name: test-remove-me
bindPoints:
- interface: 127.0.0.1:1281
address: 127.0.0.1:1281
options: { }
apis:
- binding: edge-management
options: { }
- binding: edge-client
options: { }
+2 -2
View File
@@ -27,8 +27,8 @@ require (
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d
github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19
github.com/michaelquigley/pfxlog v0.3.7
github.com/openziti/edge v0.19.107
github.com/openziti/fabric v0.16.60
github.com/openziti/edge v0.19.109
github.com/openziti/fabric v0.16.61
github.com/openziti/foundation v0.15.50
github.com/openziti/sdk-golang v0.15.47
github.com/pborman/uuid v1.2.0
+5 -4
View File
@@ -607,6 +607,7 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
@@ -614,10 +615,10 @@ github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e h1:ST9+54UtCr96S5
github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k=
github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo=
github.com/openziti/edge v0.19.107 h1:zzLl3j2vdHY4cnVppQrQEnTNGbxXquwxtOrLAdzYOe8=
github.com/openziti/edge v0.19.107/go.mod h1:W+zveyNeWADsqsBQ9hTfXzlNtptGvN/iNSgxy71VmhM=
github.com/openziti/fabric v0.16.60 h1:Gjb/t2qvSNWTAdgwXbIvoKf/NMgmyG7y2oa68ccoiC0=
github.com/openziti/fabric v0.16.60/go.mod h1:xro2eGr6ilDmz8qZ0sp7KjHMl0KU4l9aOBydGF/tg9E=
github.com/openziti/edge v0.19.109 h1:4YDGFC4t+rAwUBQQ/+7eDIILI15DC4v512ecoO2KsXI=
github.com/openziti/edge v0.19.109/go.mod h1:us0jeq6JzGMl47FEVNN35WKlD5qPkSr0u7+kaw9oVQU=
github.com/openziti/fabric v0.16.61 h1:NtEi9orFtieYPNx6H/XcRHAde1pQKW0gtEov8bsc2aA=
github.com/openziti/fabric v0.16.61/go.mod h1:xro2eGr6ilDmz8qZ0sp7KjHMl0KU4l9aOBydGF/tg9E=
github.com/openziti/foundation v0.15.50 h1:xvID5CAXNLAb0h9nOXCQr4PlcxlPpnPOnNDoEeyl424=
github.com/openziti/foundation v0.15.50/go.mod h1:NnSBTp9ZkcYsv6nYxZR0/NzoHfkIo6tjpBHDvBsPFqw=
github.com/openziti/sdk-golang v0.15.47 h1:6/VUergS4cWcmz4xAn45Q/aTC99steFWsLs3TLdk2Rk=
+1 -1
View File
@@ -1 +1 @@
0.19
0.20
+1 -1
View File
@@ -72,7 +72,7 @@ func run(cmd *cobra.Command, args []string) {
edgeController.SetHostController(fabricController)
edgeController.Initialize()
go waitForShutdown(fabricController, edgeController)
go edgeController.Run()
edgeController.Run()
if err := fabricController.Run(); err != nil {
panic(err)
}
@@ -104,7 +104,7 @@ func runCreateCa(options *createCaOptions) (err error) {
setJSONValue(data, string(options.caPemBytes), "certPem")
setJSONValue(data, options.identityRoles, "identityRoles")
result, err := createEntityOfType("cas", data.String(), &options.edgeOptions)
result, err := createEntityOfType("/edge/management/v1/cas", data.String(), &options.edgeOptions)
if err != nil {
panic(err)
+18 -1
View File
@@ -24,8 +24,10 @@ import (
cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
"github.com/openziti/ziti/ziti/cmd/ziti/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"io"
"net/url"
"path/filepath"
"strings"
)
@@ -47,7 +49,7 @@ func newLoginCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Comm
}
cmd := &cobra.Command{
Use: "login my.controller.hostname[:port]",
Use: "login my.controller.hostname[:port]/path",
Short: "logs into a Ziti Edge Controller instance",
Long: `login allows the ziti command to establish a session with a Ziti Edge Controller, allowing more commands to be run against the controller.`,
Args: cobra.MinimumNArgs(1),
@@ -83,6 +85,20 @@ func (o *loginOptions) Run() error {
host = "https://" + host
}
if certAbs, err := filepath.Abs(o.Cert); err == nil {
o.Cert = certAbs
}
hostUrl, err := url.Parse(host)
if err != nil {
return errors.Errorf("could not parse host, invalid: %v", err)
}
if hostUrl.Path == "" {
host = util.EdgeControllerGetManagementApiBasePath(host, o.Cert)
}
if o.Username != "" && o.Password == "" {
var err error
if o.Password, err = term.PromptPassword("Enter password: ", false); err != nil {
@@ -130,3 +146,4 @@ func (o *loginOptions) Run() error {
return err
}
+38 -1
View File
@@ -78,7 +78,7 @@ func DownloadFile(filepath string, url string) (err error) {
func newClient() *resty.Client {
return resty.
New().
SetTimeout(time.Duration(2 * time.Second)).
SetTimeout(2 * time.Second).
SetRetryCount(5).
SetRedirectPolicy(resty.FlexibleRedirectPolicy(15))
}
@@ -909,3 +909,40 @@ func EdgeControllerRequest(entityType string, out io.Writer, logJSON bool, timeo
return jsonParsed, nil
}
// EdgeControllerGetManagementApiBasePath accepts host as `http://domain:port` and attempts to
// determine the proper path that should be used to access the Edge Management API. Depending
// on the version of the Edge Controller the API may be monolith on `/edge/<version>` and `/` or split into
// `/edge/management/<version>` and `/edge/client/<version>`.
func EdgeControllerGetManagementApiBasePath(host string, cert string) string {
client := newClient()
client.SetHostURL(host)
if cert != "" {
client.SetRootCertificate(cert)
}
resp, err := client.R().Get("/version")
if err != nil || resp.StatusCode() != http.StatusOK {
return host
}
data, err := gabs.ParseJSON(resp.Body())
if err != nil {
return host
}
// controller w/ APIs split
if data.ExistsP("data.apiVersions.edge-management") {
if path, ok := data.Path("data.apiVersions.edge-management.v1.path").Data().(string); !ok {
return host
} else {
return host + path
}
}
return host
}