Created
August 4, 2023 20:43
-
-
Save da-blog/9bc3194d72ddbca90ea1de24a422a8ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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