question

Denis V. avatar image
Denis V. asked ·

User tagging based on JWT value

Our usernames are sent with every client requests in a X-AuthenticationToken header.

This header contains a base64 encoded Json Web Token. We would like to extract the "uid" field from this token and use it for user tagging.

Has anyone already encountered this use-case?

user tagging
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Brendan S. avatar image
Brendan S. answered ·

Looking into this some more, using the JavaScript API to put in our own JS code I'm wondering if it is possible. Taking a function from Stack Overflow on decoding base64. Then use another function to extract just the username from the decrypted token and set it using dtrum.identifyUser(username).

https://www.dynatrace.com/support/help/shortlink/user-tagging#user-tagging-via-the-dynatrace-javascript-api

I'm not sure if this would add extra response time to the transaction or even work.. but just an idea.


Example:

<script type="text/javascript">

function parseJwt (token) {

var base64Url = token.split('.')[1];

var base64 = decodeURIComponent(atob(base64Url).split('').map(function(c) {

return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);

}).join(''));

var username = extractUsername(base64);

dtrum.identifyUser(username);

};

function extractUsername(decryptedToken) {

..... (this code we'd need to figure out, how to get the username out of the JSON or XML or whatever format it's in)

return (username)

};

</script>

2 comments Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

In general if you have option to modify code of your application you can always decode JWT and store result in global JS variable, cookie or send via JavaScript api to dynatrace directly. It’s quite simple code but you should be sure to pick place where it will be executed for all users and only once (for example on first page after signin). This important to not add extra and not necessary code just for monitoring on every pageload :)

Sebastian

1 Like 1 · ·

Thanks Sebastian, will keep that in mind :)

0 Likes 0 · ·
Sebastian K. avatar image
Sebastian K. answered ·

There is no option to make base64 decode in Dynatrace request attributes post production settings. Only regexes and similar options are there. For now still it is impossible to accomplish such task.

Sebastian

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Brendan S. avatar image
Brendan S. answered ·

I just got this ask. Were you able to find anything on this?

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Space Topics

mobile monitoring dotnet synthetic monitoring reports iis chat kubernetes servicenow amazon web services mysql mainframe rest api errors cassandra dashboard oneagent sdk cmc application monitoring openkit smartscape request attributes monitoring developer community user tagging log monitoring services ufo syntheticadvisory activegate ip addresses auto-detection high five award oracle hyperion webserver uem usql iib test automation license web performance monitoring ios news migration management zones index ibm mq web services custom event alerts notifications sso host monitoring knowledge sharing reports browser monitors java hybris sap vmware maintenance window user action naming javascript appmon ai synthetic classic availability tipstricks automation extensions session replay diagnostic tools permissions davis assistant faq documentation problem detection http monitors server easytravel apdex aws-quickstart network docker tags and metadata cloud foundry google cloud platform synthetic monitoring process groups account usability dynatrace saas gui paas openshift key user actions administration user actions postgresql synthetic locations oneagent security Dynatrace Managed user management custom python technologies mongodb openstack user session monitoring continuous delivery citrix configuration alerting NGINX action naming linux nam installation masking error reporting database mission control jmeter recorder apache mobileapp RUM php threshold azure purepath davis scripting agent aix nodejs android