Skip to content

Instantly share code, notes, and snippets.

@da-blog
Created August 4, 2023 20:43
Show Gist options
  • Save da-blog/9bc3194d72ddbca90ea1de24a422a8ca to your computer and use it in GitHub Desktop.
Save da-blog/9bc3194d72ddbca90ea1de24a422a8ca to your computer and use it in GitHub Desktop.
function (user, context, callback) {
// Hardcoded constants
var ledgerId = 'daml-auth0-example-ledger';
var applicationId = 'daml-auth0-example';
// Read the DAML party identifier from the app metadata
var actAs = [];
if (user.app_metadata && user.app_metadata.daml_ledger_api) {
actAs = [user.app_metadata.daml_ledger_api.partyIdentifier];
}
// Add ledger API claims to the token
var namespace = 'https://daml.com/ledger-api';
context.accessToken[namespace] = {
"ledgerId": ledgerId,
"applicationId": applicationId,
"actAs": actAs,
"admin": false,
};
callback(null, user, context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment