Simplified JWT access token creation in Auth0

Auth0 has recently introduced its new Actions platform as a successor of the Rules and Hooks platform:

I wanted to implement the most simple way of issuing access tokens for a Daml ledger, and found the following:

In Auth0, we can attach arbitrary data to a user profile, so I attached the whole set of custom claims a Daml ledger requires in an access token:

This can be set by an admin, who creates the user in Auth0, through the Auth0 management API, in parallel with allocating the ledger party for the user.

Based on this set of data, we can add the custom claims to the access token with a simple custom action in Auth0:

After creating the custom action, we can include the action into the login flow.

After this, if a Daml application redirects its user to the Auth0 authorize endpoint with this URL:


and the user authenticates on the Auth0 Universal Login screen, the user gets redirected to the Daml application with the access token in the URL hash fragment:


We can check that the access token indeed contains the custom claims we have set in the user profile:

Of course, putting the JWT token into the response URL is not the safest way of access token handling. You have safer options by choosing an alternative authorization flow.

See the details of the Implicit Grant flow which is used here: SPA + API: Solution Overview


This is exactly what I was going to look into next.



The next step is to implement this flow in the React UI, for which Auth0 provides this tutorial: Auth0 React SDK Quickstarts: Login

And of course we have excellent guides on the Daml blog which can be used mutatis mutandis (these guides were written before the new Auth0 Actions platform, using the legacy Rules and Hooks platform):

1 Like

JWT token as a URL parameter is a definite code smell and to be avoided. These are written to logs and are reusable

I haven’t looked at the new Actions capability but the blog post part 2 demonstrated both end user 3 phase oAuth logins and 2-phase service account logins to get valid tokens. I’ll check out Actions to see if we need to update the blog.

The blog repo also provides a very simplistic set of scripts and services for local JWT token generation for local non-Auth0 testing.


Thanks @nycnewman, I agree, this is just the first step. I want to proceed in an agile way, meaning in small steps which work, even if at the beginning in a suboptimal way.

What would be of great help to me is a version of the Daml UI template which uses a really robust way of Auth0 access token handling.

See also my question:


Looks like Robin responded to you on that.

Could you expand a bit on the issue here? As far as I’m aware the fragment is specifically not part of the search params and is not sent by browsers to the HTTP server. Which logs are you concerned about? I’d assume if an attacker has access to your local browsing history you’ve pretty much already lost.

1 Like

Thinking about this more, the main issue I can think of regarding the fragment is that it’s accessible to all JS on the page, not just the bits of JS you intend it for. This should not be an issue if everything else about the page is perfect, but any vector of js code injection (improperly sanitized user content, poisoned dependencies, etc.) would have access to this information. I can’t think of a way to avoid that, though, as long as authentication has to be done purely client-side.

Usually the right solution to this is to put credentials in an httpOnly cookie (on a server that refuses CORS), but that’s only an option if you can control the backend and have your authentication on the same domain as your app.


Thanks foe the information. I’ll be sure to keep an eye on this thread. Looking for the same information.

Official Site

Hi @Godfrey,

In the next Daml SDK version (1.17.0), the create-daml-app template will come out-of-the-box with Auth0 support, and we’ll be adding a documentation page for a fully authenticated Auth0 setup (i.e. the Auth-0 side of this equation). I believe 1.17.0 is currently schedule for some time within the next two weeks.

1 Like

Great news!

I cannot see any mention about this int he snapshot release notes: Release of Daml Connect 1.17.0

It may have fallen through the cracks, or it may have been judged unworthy of the release notes. I’ll reach out internally to figure it out.

In the meantime, you can check with:

DAML_SDK_VERSION=1.17.0-snapshot.20210915.7841.0.b4328b3d daml new --template=create-daml-app t
cat t/

that you do indeed have Auth0 instructions now, as well as look at this preview of the 1.17.0 RC documentation for the broader documentation.

1 Like

Yes, though not mentioned in the release notes, the create-daml-app template does contain Auth0 support.