External JWT Signer - Identity Creation and Enrollment

Hello all. I am doing some tests using Keycloak as an external JWT signer and I have a few questions:

Ziti Controller: 2.0.8 ZAC: 4.1.2

First, I want to understand how exactly the process of creating and Identity using external JWT works.

I have set up a signer:
{
"name": "keycloak-jwt",
"issuer": "XXXX",
"audience": "XXXX",
"jwksEndpoint": "XXXX",
"externalAuthUrl": XXXX,
"claimsProperty": "XXXX",
"useExternalId": true,
"enabled": true,
"certPem": "",
"kid": "",
"tags": {}
}

and an auth policy:
{
"name": "keycloak-jwt",
"primary": {
"cert": {
"allowed": false,
"allowExpiredCerts": false
},
"extJwt": {
"allowed": true,
"allowedSigners": [
"keycloak-jwt"
]
},
"updb": {
"allowed": false,
"lockoutDurationMinutes": 0,
"maxAttempts": 0
}
},
"secondary": {
"requireTotp": false,
"requireExtJwtSigner": ""
},
"tags": {}
}

With these in mind I have set up an Admin Identity which can be used to enter ZAC. But I am more interested in creating Identities that correspond to the other users (non-admin) from Keycloak.

I was able to create an identity which corresponds to a 'test' user with the following:
curl -k -sS
-X POST
"${ZITI_EDGE_CLIENT_URL}/edge/client/v1/enroll/token"
-H "Authorization: Bearer ${ZITI_JWT}"
-H "Content-Type: application/json"
--data-binary @token-enrollment-request.json
-o enrollment-response.json
-w '\nHTTP %{http_code}\n'

I also noticed that with the ziti binary I can do:
ziti edge create identity test -P keycloak-jwt --external-id "<sub-value-from-JWT>"

Which also creates the 'test' user. My question is what is the difference between these creation methods?

And also, in the second case, what does the Signer verify exactly? I noticed that I can also do, for example: ziti edge create identity test2 -P keycloak-jwt --external-id "<random-values>"

Even though I don't have a test2 user, the related Identity is created anyway. So what does the Signer do in this case exactly?

Finally I'd like to know, how may I activate this Identity for a Ziti Edge Tunnel? The idea is to utilize the JWT provided by Keycloak in order to register a device on my Ziti. I have seen that the JWT can be used for the Identity creation, but can it also be used for the enrollment of a ziti edge tunnel?

Any help would be appreciated.

Hi @pantmal, welcome to the community and to OpenZiti!

An external JWT signer tells the controller which JWTs to trust. You can toggle on one or both of the toggles in the ZAC to either allow "auto enrollment" as ZAC refers to it. This will allow the controller to generate identities if it needs to during an enrollment event.

So, you would: make an external jwt signer, allow it to make an identity using "Auto-Enroll to Cert" and "Auto-Enroll to Token", and then when a user shows up with a JWT that matches the configured options they would be created automatically.

You can pre-create the identities if you prefer, you just need to map the expected external id to the claim you want matched.

In your example you used curl at first, then used the ziti CLI. Both of these methods end up calling the HTTP API so realistically they are functionally equivalent. the ziti CLI is just a nice wrapper around the HTTP API.

If you pre-create the users, the signer will determine how the user authenticates. In your example, after they add the identity to a tunneler they will need to use the ext-jwt-signer (IdP) to authenticate to the controller before they gain access to the services you assigned to that user.

Maybe it'll be useful to have a look through this lab that I just published a week or so ago Add by URL | NetFoundry Documentation. It also might be worthwhile to read this blog Joining a network with just a URL and watch the short video embedded in it:

And you might find the longer form Ziti TV I did on the topic useful https://www.youtube.com/watch?v=VMg5y1V1eDs (the scripts I used, doc etc located on github ziti-tv/live-stream/2026/10-23 at main · openziti-test-kitchen/ziti-tv · GitHub)

Hope that's not too much detail... Something in there I'm sure will help ! :slight_smile: If not just ask again and we'll check back in with ya... Cheers

Hi @TheLumberjack , pleased to be here!

I was able to proceed with an end to end scenario today, using the JWT method. I have to say that your links were indeed quite helpful because, even though the URL method is a bit different, they helped me understand what is the expected result for an Identity creation/activation using the Keycloak as an external signer.

Now, I do have a few questions. First, to provide some context, in my JWT setup using OIDC for authentication I had to perform the following steps:

sudo ziti-edge-tunnel add \ --jwt "$(cat ziti_net.jwt)" \ --identity test
(ziti_net.jwt refers to the network JWT from the JWT Signers page)

sudo ziti-edge-tunnel run \ -i /opt/openziti/etc/identities/test.json

sudo ziti-edge-tunnel ext-jwt-login \ -i /opt/openziti/etc/identities/test.json \ -p keycloak-jwt

Now the last command does provide a Url which completes the authentication process using the provided Keycloak. I want to ask the following:

  1. First, I notice that the redirect URI is the following: `http://localhost:20314/auth/callback`

Naturally, `localhost` creates a few problems. For our setup we utilize dedicated VMs, not our workstations. This means, for localhost to work, I need to open a 3rd terminal and provide a port forwarding command, sort of: ssh -N -L 20314:[::1]:20314 <user>@<VM-IP>

For our case, this approach does not be very user-friendly. So, my question is: Can the redirect URI be changed? Ideally we would like to utilize the VM's IP for this.

  1. Also, I used the ziti-edge-tunnel binary for the above. But is it possible to complete the setup above using Docker? We almost exclusively use Docker for our partners when it comes to bootstraping their respective tunnelers, since it is faster and requires minimal setup.

I do suspect that your proposed 'URL setup' probably is a solution to the above (I have not looked at all the steps in detail, so please correct if I'm mistaken). While this solution is obviously an improvement over JWT for the reasons you have described, I will have to discuss with my team if this approach is OK for us.

So, optimally, I would like to know if/how we may configure the OIDC option to better suit our use cases.

Thanks again for your detailed reply. I'm waiting for your further responses!

Hi @pantmal,

Ok. So you're trying to complete the OIDC flow to authorize a tunneler on a remote machine. I gotta say that's a first I think. I don't think we really have a good answer to "I want to use my IdP on a remote machine with no browser" just yet. My natural inclination is to simply tell you "don't do that". LOL... I would use certificate based auth and then you don't have this awkward problem. But, I'm old enough to konw there's probably some reason that you -want- to do this? So can you tell me what your goal is what that flow? Normally I would either make my own certificate and use that for auth (3rd party ca) or I would just make an identity, get that identity's enrollment token (.jwt) and then enroll that into a cert that the overlay signed...

So what's the goal with using the IdP in that way? It's a flow nobody has asked for yet, so we just don't have a good answer for "using OIDC auth via external IdP on a remote machine with no browser"... At least, I don't think we have an answer for this yet... Your ssh tunnel --could-- work but as you say, not super friendly at all...

Right now the redirect is hardcoded in the csdk. Can't be changed. But what we could (arguably 'should') do is support remote browserless OIDC auth in some way such as supporting RFC 8628

The only other alternative is to do the by-url enrollment to a device certificate instead of 'user session'. Doing this ties the machine you enroll by certificate to the identity that's created but you will only be able to do this once as it maps the identity to that -one- cert...

I'm not sure I have any great answers for you here at this time. I think we should support RFC 8626 though.... We just don't just yet...

FWIW, I plan on adding device code flow for external OIDC providers. this is useful for headless devices (and other use cases). external OIDC: support device code flow · Issue #1239 · openziti/ziti-sdk-c · GitHub

Hi @TheLumberjack ,

At this time, me and my team are on an investigative type of work, so my answers may seem a bit unclear for now. Not all details are finalized just yet, so I'll try my best to explain what our general goals are for this investigation.

As of now, we have utilized OpenZiti in order to provide access to our respective services to other partners (or vice-versa). Most of our work is Cloud-Based so we, and our partners, utilize VMs, Kubernetes clusters, etc, for our Testbeds and general Infrastructure.

Part of what we want to achieve now, is to have a centralized point of authentication. So far, our logic between Keycloak and OpenZiti is decoupled. We may register users on our Keycloak instances, but for their respective services we need to separately create Domain Identities, issue the OTT and request them to spin up the Ziti Edge Tunneler using Docker.

Ideally, we would like to bridge the gap between Keycloak and OpenZiti, and have the process described above as automated. So our idea for now, is to utilize the JWT provided by a Keycloak user and use it as a way to register him on the OpenZiti side at the same time. We are trying to have this JWT as a way to authenticate the user in other components as well.

With this way, our application would have Keycloak as the "source of truth" and the OpenZiti identities could match based on who is registered as a Keycloak user.

TL;DR: Our use cases almost exclusively rely on Virtual Machines and remote devices.

It's good to know that there is a plan for RFC 8628, since that will probably be ideal for our case. In the meantime, could you think of an alternative based on the information I have provided?