Hi @RS_MOB, welcome to the community!
I just went and filed an issue to document this. Thanks for bringing it up. Update Samples and provide instructions · Issue #40 · openziti/ziti-sdk-csharp · GitHub
The basic flow is the same as any identity. I’ll assume you have already installed an OpenZiti network using one of the quickstarts. You’ll need that first, of course. The instructions I provide below will assume you have a quickstart network deployed.
Once you have your network established, you need a service defined and accessible. Here’s how you do that from start to finish. I also made an 8 minute video you can watch if you want to watch me do it
Steps to Run Weather Sample
Make the Offload Side
This sample expects to use a router as the offload point for traffic. To setup the offload, make a host.v1
config to be used in your service that points to the actual target: in this case, wttr.in
. Do that with:
ziti edge create config weather-svc.host.v1 host.v1 '{"protocol":"tcp", "address":"wttr.in","port":80}'
Find the name of your edge router identity, mine is: ip-172-31-45-134-edge-router
. Use that identity and assign the attribute of “csharp.offload”. This attribute will be used below when authorizing the identity to offload the data from the overlay network.
ziti edge update identity ip-172-31-45-134-edge-router -a "csharp.offload"
Make the Service
Now use the config to make a service, instructing OpenZiti to offloading the connection. Also use an attribute named #csharp.offload
for the service so if there are others, they will all get authorized (see below)
ziti edge create service weather-svc --configs weather-svc.host.v1 -a "csharp.sample"
Authorize the Offload Identity
The offload identity needs to be authorized to ‘bind’ or ‘host’ the service. Here we’re using a router with tunneling enabled and we’ve used a host.v1
config so that we can offload from the overlay to some otehr location. Authorize the offload endpoint now:
ziti edge create service-policy csharp.demos.bind Bind --service-roles '#csharp.sample' --identity-roles '#csharp.offload'
Create the Identity
Here’s where you’ll make that identity you are looking for. Make the identity, use an attribute called '#csharp.demo'
for easy authorization of other services for this identity.
ziti edge create identity user csharp.demo -o csharp.demo.jwt -a "csharp.demo"
For now, use the ziti
cli to enroll the identity, notice that here the output file is put into c:\temp\id.json (or wherever you want to put it, you can change the path of course):
ziti edge enroll -j c:\temp\csharp.demo.jwt -o c:\temp\id.json
Output should look like:
INFO generating 4096 bit RSA key
INFO enrolled successfully. identity file written to: c:\temp\id.json
Authorize the Identity
Finally authorize the identity to be able to ‘dial’ or access the service:
ziti edge create service-policy csharp.demos.dial Dial --service-roles '#csharp.sample' --identity-roles '#csharp.demo'
Test It Out
git clone git@github.com:openziti/ziti-sdk-csharp.git
cd ziti-sdk-csharp/Samples
dotnet run Console.csproj weather C:\temp\csharp\ziti-sdk-csharp\csharp.json