Skip to content

Instantly share code, notes, and snippets.

@stofte
Created December 12, 2018 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stofte/1f0565144e1f1b7bd56fbe2faa85a51f to your computer and use it in GitHub Desktop.
Save stofte/1f0565144e1f1b7bd56fbe2faa85a51f to your computer and use it in GitHub Desktop.
<inbound>
<set-header name="x-rejsekort-jwt-clientid" exists-action="append">
<value>@{
string clientID = string.Empty;
string token = context.Request.Headers.GetValueOrDefault("Authorization", "");
if (token?.Length > 0)
{
string[] tokenParts = token.Split(' ');
if (tokenParts?.Length == 2 && tokenParts[0].Equals("bearer", StringComparison.InvariantCultureIgnoreCase))
{
Jwt jwt;
if (tokenParts[1].TryParseJwt(out jwt))
{
clientID = jwt.Claims.GetValueOrDefault("client_id", string.Empty);
}
}
}
return clientID;
}</value>
</set-header>
<base />
</inbound>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment