Skip to content

Commit 4c6f31e

Browse files
authored
Merge pull request #665 from openziti/tidy-examples
let examples build checked out sdk
2 parents a195721 + afd095c commit 4c6f31e

File tree

4 files changed

+188
-147
lines changed

4 files changed

+188
-147
lines changed

example/curlz/README.md

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
11
# Overview
2-
This example is a zitified cURL (cURLz) example. In part 1 of this example, a call will be made to an endpoint which
2+
3+
This example is a zitified cURL (cURLz) example. In part 1 of this example, a call will be made to an endpoint which
34
is not on the overlay network. In part 2, a call is made to an endpoint that *is* on the overlay network.
45

56
This example demonstrates:
7+
68
* Dialing a service
79

810
## Requirements
11+
912
* an OpenZiti network. If you do not have one, you can use one of the [quickstarts](https://openziti.github.io/ziti/quickstarts/quickstart-overview.html) to set one up.
1013
* OpenZiti CLI to create services and identities on the OpenZiti Network
1114

1215
## Build the examples
16+
1317
Refer to the [example README](../README.md) to build the SDK examples
1418

1519
## Part 1: Set up a cURLz to a non-zitified endpoint
16-
These steps will configure the service using the OpenZiti CLI. In this example, the traffic starts on the overlay zero
17-
trust network and then is offloaded onto the underlay network.
20+
21+
These steps will configure the service using the OpenZiti CLI. In this example, the traffic starts on the overlay zero
22+
trust network and then is offloaded onto the underlay network.
1823

1924
### Part 1 Architecture Overview
25+
2026
![image](unzitified.png)
2127

2228
At the end of these steps you will have created:
29+
2330
* a service called `web.endpoint`
2431
* an identity to connect to (dial) the service
2532
* the service config to connect the service to the overlay
2633
* the service policies required to authorize the identities for bind and dial
2734

2835
Steps:
36+
2937
1. Log into OpenZiti. The host:port and username/password will vary depending on your network.
3038

39+
```bash
3140
ziti edge login localhost:1280 -u admin -p admin
41+
```
42+
3243
1. Determine your edge router's name and populate this environment variable with it.
3344

45+
```bash
3446
ziti edge list edge-routers
3547
export ZITI_EDGE_ROUTER=<name-of-edge-router>
48+
```
49+
3650
1. Run this script to create everything you need.
3751

52+
```bash
3853
echo Changing to build directory
3954
cd $ZITI_SDK_BUILD_DIR
4055

@@ -54,55 +69,76 @@ Steps:
5469
5570
echo Run policy advisor to check
5671
ziti edge policy-advisor services
72+
```
73+
5774
1. Run the cURLz example for `web.endpoint`
5875

76+
```bash
5977
./curlz https://web.endpoint curlz.json
78+
```
6079

6180
### Example Output
81+
6282
The following is the output you'll see from the cURLz request to `web.endpoint`.
63-
```
83+
84+
```bash
6485
$ ./curlz https://web.endpoint curlz.json
6586
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en">
6687
... <a lot of html code>
6788
</body></html>
6889
```
6990

7091
## Part 2: Set up a cURLz to a zitified endpoint
71-
These steps will utilize the service and identities created in simple-server to provide an example of using cURLz with
72-
a zitified endpoint. In this example, the traffic never leaves the zero trust overlay.
92+
93+
These steps will utilize the service and identities created in simple-server to provide an example of using cURLz with
94+
a zitified endpoint. In this example, the traffic never leaves the zero trust overlay.
7395

7496
### Part 2 Architecture Overview
97+
7598
![image](zitified.png)
7699

77100
At the end of these steps you will have created:
101+
78102
* an identity to connect to (dial) the service
79103

80104
Steps:
81-
1. Follow all steps in the simple-service example up to, and including, running the server but **do not** enroll the
105+
106+
1. Follow all steps in the simple-service example up to, and including, running the server but **do not** enroll the
82107
`simple-client` identity with the Ziti Desktop Edge client. We will do that with the CLI for this example
83108
1. Open a new terminal and cd into the example build directory
84109

110+
```bash
85111
echo Changing to build directory
86112
cd $ZITI_SDK_BUILD_DIR
113+
```
114+
87115
1. Run this script to create everything you need.
88116

117+
```bash
89118
echo Enroll the simple-client identity
90119
ziti edge enroll --jwt simple-client.jwt
120+
```
91121

92122
1. Run the cURLz example for `simpleService`
93123

124+
```bash
94125
./curlz http://simpleService simple-client.json
126+
```
95127

96128
### Example Output
129+
97130
The following is the output you'll see from the cURLz request to `simpleService`.
98-
```
131+
132+
```bash
99133
$ ./curlz http://simpleService.ziti simple-client.json
100134
Who are you?
101135
```
102136

103137
## Teardown
138+
104139
Done with the example? This script will remove everything created during setup.
105-
```
140+
141+
```bash
106142
ziti edge login localhost:1280 -u admin -p admin
107143

108144
echo Removing service policies
@@ -118,4 +154,5 @@ ziti edge delete identity curlz
118154
echo Removing service
119155
ziti edge delete service web.endpoint
120156
```
157+
121158
**NOTE:** If you followed **Part 2** of this example, refer to teardown in the `simple-server` [example README](../simple-server/README.md)

example/go.mod

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ go 1.21
44

55
toolchain go1.22.1
66

7+
replace github.com/openziti/sdk-golang => ../
8+
79
require (
810
github.com/Jeffail/gabs v1.4.0
911
github.com/google/uuid v1.6.0
1012
github.com/gorilla/mux v1.8.1
1113
github.com/michaelquigley/pfxlog v0.6.10
12-
github.com/openziti/foundation/v2 v2.0.47
14+
github.com/openziti/foundation/v2 v2.0.56
1315
github.com/openziti/runzmd v1.0.33
14-
github.com/openziti/sdk-golang v0.23.39
16+
github.com/openziti/sdk-golang v0.0.0
1517
github.com/pkg/errors v0.9.1
1618
github.com/sirupsen/logrus v1.9.3
17-
github.com/spf13/cobra v1.8.0
19+
github.com/spf13/cobra v1.8.1
1820
github.com/spf13/viper v1.17.0
1921
github.com/zitadel/oidc v1.13.5
20-
golang.org/x/text v0.16.0
22+
golang.org/x/text v0.21.0
2123
google.golang.org/grpc v1.59.0
2224
google.golang.org/grpc/examples v0.0.0-20231107231549-482de2224942
2325
gopkg.in/resty.v1 v1.12.0
@@ -50,13 +52,13 @@ require (
5052
github.com/go-openapi/strfmt v0.23.0 // indirect
5153
github.com/go-openapi/swag v0.23.0 // indirect
5254
github.com/go-openapi/validate v0.24.0 // indirect
53-
github.com/go-resty/resty/v2 v2.13.1 // indirect
55+
github.com/go-resty/resty/v2 v2.15.3 // indirect
5456
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
5557
github.com/golang/protobuf v1.5.4 // indirect
5658
github.com/gomarkdown/markdown v0.0.0-20230922112808-5421fefb8386 // indirect
5759
github.com/gorilla/schema v1.4.1 // indirect
58-
github.com/gorilla/securecookie v1.1.1 // indirect
59-
github.com/gorilla/websocket v1.5.1 // indirect
60+
github.com/gorilla/securecookie v1.1.2 // indirect
61+
github.com/gorilla/websocket v1.5.3 // indirect
6062
github.com/hashicorp/hcl v1.0.0 // indirect
6163
github.com/inconshreveable/mousetrap v1.1.0 // indirect
6264
github.com/josharian/intern v1.0.0 // indirect
@@ -76,12 +78,12 @@ require (
7678
github.com/muhlemmer/gu v0.3.1 // indirect
7779
github.com/oklog/ulid v1.3.1 // indirect
7880
github.com/opentracing/opentracing-go v1.2.0 // indirect
79-
github.com/openziti/channel/v2 v2.0.136 // indirect
80-
github.com/openziti/edge-api v0.26.21 // indirect
81-
github.com/openziti/identity v1.0.81 // indirect
82-
github.com/openziti/metrics v1.2.56 // indirect
83-
github.com/openziti/secretstream v0.1.21 // indirect
84-
github.com/openziti/transport/v2 v2.0.138 // indirect
81+
github.com/openziti/channel/v3 v3.0.26 // indirect
82+
github.com/openziti/edge-api v0.26.36 // indirect
83+
github.com/openziti/identity v1.0.94 // indirect
84+
github.com/openziti/metrics v1.2.65 // indirect
85+
github.com/openziti/secretstream v0.1.28 // indirect
86+
github.com/openziti/transport/v2 v2.0.159 // indirect
8587
github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect
8688
github.com/parallaxsecond/parsec-client-go v0.0.0-20221025095442-f0a77d263cf9 // indirect
8789
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
@@ -105,24 +107,25 @@ require (
105107
github.com/valyala/fasttemplate v1.2.2 // indirect
106108
github.com/yusufpapurcu/wmi v1.2.4 // indirect
107109
github.com/zitadel/logging v0.3.4 // indirect
108-
github.com/zitadel/oidc/v2 v2.12.0 // indirect
109-
go.mongodb.org/mongo-driver v1.16.0 // indirect
110-
go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect
111-
go.opentelemetry.io/otel v1.28.0 // indirect
112-
go.opentelemetry.io/otel/metric v1.28.0 // indirect
113-
go.opentelemetry.io/otel/trace v1.28.0 // indirect
110+
github.com/zitadel/oidc/v2 v2.12.2 // indirect
111+
go.mongodb.org/mongo-driver v1.17.0 // indirect
112+
go.mozilla.org/pkcs7 v0.9.0 // indirect
113+
go.opentelemetry.io/otel v1.29.0 // indirect
114+
go.opentelemetry.io/otel/metric v1.29.0 // indirect
115+
go.opentelemetry.io/otel/trace v1.29.0 // indirect
114116
go.uber.org/multierr v1.11.0 // indirect
115-
golang.org/x/crypto v0.25.0 // indirect
117+
golang.org/x/crypto v0.32.0 // indirect
116118
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
117119
golang.org/x/image v0.18.0 // indirect
118-
golang.org/x/net v0.27.0 // indirect
119-
golang.org/x/oauth2 v0.21.0 // indirect
120-
golang.org/x/sync v0.7.0 // indirect
121-
golang.org/x/sys v0.22.0 // indirect
122-
golang.org/x/term v0.22.0 // indirect
120+
golang.org/x/net v0.34.0 // indirect
121+
golang.org/x/oauth2 v0.23.0 // indirect
122+
golang.org/x/sync v0.10.0 // indirect
123+
golang.org/x/sys v0.29.0 // indirect
124+
golang.org/x/term v0.28.0 // indirect
123125
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
124-
google.golang.org/protobuf v1.34.2 // indirect
126+
google.golang.org/protobuf v1.36.2 // indirect
127+
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
125128
gopkg.in/ini.v1 v1.67.0 // indirect
126129
gopkg.in/yaml.v3 v3.0.1 // indirect
127-
nhooyr.io/websocket v1.8.11 // indirect
130+
nhooyr.io/websocket v1.8.17 // indirect
128131
)

0 commit comments

Comments
 (0)